If you run the following commands: $ sudo -sįrom this, you can see that sudo -s does not simulate an initial login, and does not change $HOME. Meanwhile, sudo -s starts a new shell but without simulating initial login - login files are not read and $HOME is still set to your user's home folder. This also means sudo -i reads login files like. For example: 'su -' can give different PATH, accessing other tools, Can give other HOME with different configuration ( /.ssh /.Xauthority etc) Share. Hence, you can see that sudo -i simulates an initial root login, including changing the home folder ( $HOME) to root's, rather than your own. I will create a question from it but sudo su - and sudo su -l differs. difference i usually meet is difference in environment variables. If you run the following commands: $ sudo -i If username is not specified with su and su -, the root account is implied as. Hence, if you are on a default *buntu install, where root login is disabled, sudo -i can be used while su and its variants cannot. The main difference is : su - username sets up the shell environment as if it were a clean login as the specified user, it access and use specified users environment variables, su username just starts a shell with current environment settings for the specified user. The primary difference between sudo -i and su - is that sudo -i can be executed using a sudoer's password, while su - must be executed with the root account's password. These options are documented under man sudo. The -u user option means to run the command as the specified user rather than root. The -s option means to run the shell specified in the environment variable SHELL if this has been set, or else the users login shell. 1) switches from the current directory to the home directory of the new user (e.g., to /root in the case of the root user) by. sudo -su user is short for sudo -s -u user. Sudo -i runs a login shell with root privileges, simulating an initial login with root, acting similar to su -. The difference between '-' and 'no hyphen' is that the latter keeps your existing environment (variables, etc) the former creates a new environment (with the settings of the actual user, not your own). Depending on the configuration, it might prompt for the source users password, both to mitigate the risk of an. ![]() sudo checks whether the source user is authorized to run the command (the authorization is specified in /etc/sudoers ). Su switches you to the root user account and requires the root accounts password. Note: This answer has been heavily edited since its last iteration based on Eliah Kagan's comments. The difference between sudo and su is how they perform authentication: su prompts for the target users password. This is a key difference between su and sudo.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |