Sudo (super user do)
Sudo command allows us to run a command as another user does. Sudo stands for "super user do" . If we want to permit a normal user to execute some commands that are only run by root , we can use sudo.
Granting user redhat to run "ls" command as root
1. Getting the full path of "ls" command
Sudo command allows us to run a command as another user does. Sudo stands for "super user do" . If we want to permit a normal user to execute some commands that are only run by root , we can use sudo.
Granting user redhat to run "ls" command as root
1. Getting the full path of "ls" command
2. Open the /etc/sudoers, add the following line at the bottom of the file.
3. Add the line at the bottom of the file
4. Testing the Newly granted permission.
Before executing every command add the word sudo before the command.
Before executing every command add the word sudo before the command.
5. Granting sudo permissions to execute all user administration related commands.
We are going to grant permissions to execute commands such as useradd, userdel, usermod, password to the user clado. For this we need to find out absolute path of each command. We use "which" command to do this.
We are going to grant permissions to execute commands such as useradd, userdel, usermod, password to the user clado. For this we need to find out absolute path of each command. We use "which" command to do this.
Open the /etc/sudoers and add the following line and save it.
Listing all the commands that are allowed to execute through the sudo
Suppose the user clado wants to know what all commands he can execute using sudo, we can list the sudo by using the switch -l
Command: sudo -l
Suppose the user clado wants to know what all commands he can execute using sudo, we can list the sudo by using the switch -l
Command: sudo -l
Testing
Sudo format
UserName Host=(Run as user) Commands
Giving permission to user "myuser" to run all commands as root
UserName Host=(Run as user) Commands
Giving permission to user "myuser" to run all commands as root
Use the key word "ALL" instead of specifying the commands. Now myuser can execute every command as root.
Allow sudo users to execute commands without password
Allow sudo users to execute commands without password