![]() It is best used when you want to access the root account with its $SHELL environmental value. Unlike the other two commands, it will not read or change any of the user’s environmental files. The other sudo su and sudo -i commands take the user of root environment variables. Do you think it is similar to the above two commands? Then you are wrong. It allows you to run the command as root and does not require a root account password. : ~ $ sudo -i echo $testĪs you can see, sudo su and sudo-i are very identical, only sudo -i is a cleaner and simpler way to gain root access without directly interacting with the root user.Īlso Read: How to run sudo command without passwordĪnother difference is that sudo -i does not create multiple setuid commands in the background, which makes it easier to figure out which environmental variable will be kept and which one will be changed. : ~ $ sudo -iĪnd the best part about using this command is that you can share the environment variables with the root account without worrying about them being changed. If you want to completely switch to the root account, then execute the sudo -i command without any arguments. It is similar to the sudo su command but way better because you do not have to directly interact with the root user.įor example, if you want to execute the whoami command without switching to the user, then specify the command as an argument to the sudo -i command and then it will ask for the current account password, as shown below. To prevent it from happening and get a cleaner version we will use the sudo -i command, which you are about to learn. However, sudo su creates multiple setuid which makes it more challenging to know which variable will be kept and which one will be changed.Īlso Read: How to Disable ‘su’ Access for Sudo Users in Linux When you access or switch to another user account, you are able to set environment variables. Same with the superuser account, which will require my current password when accessed using the sudo su command. It is recommended to give access to sudo and su to only trusted users and disable them for untrusted users.Īlso Read: Revoke Users SUDO privileges in LinuxĪs you see below, I will try to access the jake account without knowing its password but using my current password. ![]() Note: Giving access to sudo will let users switch to any account using the sudo su command, which might be unnecessary for them and system security. However, using sudo su to switch to another user account or superuser requires the current user password. ![]() The sudo su is similar to the standard su command, only the difference is that executing su will ask for that user account password. However, it also prevents a user from accessing the account if they do not know the target account password.įor example, in order to access the root account, I need to know the root account password otherwise, I’ll not be able to gain access.Īlso Read: Create New User with Sudo Privileges using Command-Lineīut don’t worry, there are a few more ways to access another user’s account or gain access to superusers without knowing their password, which we are about to learn. :/home/trendoceans# whoamiĪs you see, the su command is effective for switching to another account or superuser if you know their account password. To switch to a superuser or root account, execute su without any arguments, and then it will ask for the root account password, as shown below. If you want to switch to any specific user, like trendoceans, then specify the su with username as an argument and then it will ask for a user password that you need to enter in order to get account access, as shown below. The su command is the most basic command to switch a current user to another account or superuser without changing the current working directory and user environment. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |