
su command and sudo command in linux
su – Substitute User
If one user needs to login as another user in the same CLI(shell)
eg: su -l user-name
Note:
- Root user can login as any of the other user without needing the password of the other users
- Normal user can login as any of the other user with password
In some cases where a normal user wants to execute a command(that can normally executed only by root) if the local system administrator(root) is not available, sharing the root’s password is not recommended, so sudo command can be used
sudo
To exec any command with root privilege – prepend sudo in front of the command
eg:sudo useradd testuser
but, not all users are sudo users by default.
To Make a user as a Sudo User in RHEL
Add a user to wheel group
usermod -aG wheel testuser
Now testuser can exec any command with root privilege without needing root password
and all the commands executed by a sudo user will be logged in a file /var/log/secure
if non-sudo user tries to give command it will be reported as a mail(auto-generated) to root
Share this:
Related
Calendar
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 |
Leave a Reply