The sudo program allows a user to start a program with the credentials of another user. Before this works, the system administrator has to set up the /etc/sudoers file. This can be useful to delegate administrative tasks to another user (without giving the root password). The screenshot below shows the usage of sudo.
User ‘rd’ received the right to run useradd with the credentials of root. This allows ‘rd’ to create new users on the system without becoming root and without knowing the root password.
#/usr/sbin/useradd -m paul
First the command fails for user rd.
But with sudo it works.
su – $username
By default, the su command maintains the same shell environment. To become another user and also get the target user’s environment, issue the su – command followed by the target username.
#su - john
Visudo edits the sudoers file in a safe fashion. Visudo locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors. Check the man page of visudo before playing with the /etc/sudoers file.
sudo su –
On some Linux systems like Ubuntu and Xubuntu, the root user does not have a password set. This means that it is not possible to login as root (extra security). To perform tasks as root, the first user is given all sudo rights via the /etc/sudoers. In fact all users that are members of the admin group can use sudo to run all commands as root.
#sudo grep rd /etc/sudoers
The end result of this is that the user can type sudo su – and become root without having to enter the root password. The sudo command does require you to enter your own password. Thus the password prompt in the screenshot below is for sudo, not for su.
#sudo su -
Latest posts by Ruwantha Nissanka (see all)
- 4 ways to hide your identity using linux - January 18, 2021
- How To Install Kali Linux in Virtualbox - December 31, 2020
- Kali Linux : The OS That Hackers Use - December 31, 2020
- How to monitor user activity in Linux with Acct - December 30, 2020
- Debsecan : You will not miss another security update - December 28, 2020