![]() The shell will follow whichever configuration you have in root’s home folder. Loading the user shell by using sudo -s yields a drastically different result. But if you run anything else, you’ll immediately notice how different things can be!įor example, let’s say you’re running the fish shell for your user account and keep the root shell in bash. In most instances, elevating to root through either shell will not result in any noticeable change. If you use an unmodified bash shell for your user account, the difference is mostly philosophical. Using sudo -i is virtually the same as the sudo su command with one exception: it does not directly interact with the root user. While you could do this in the meantime, you should still reset the root password at some point. ![]() This is useful in situations where you may have forgotten the root password if it’s different from the password for your user account. Root is given with sudo su by requesting the current user’s password, which makes it possible to gain root without the root password. Though there isn’t a large divergence between sudo su and su, the former is still a very useful command for one important reason: when a user is running su to gain root access on a system, they must know the root password. If any command is run with sudo in front of it, it is given root privileges. When sudo su is run, “.profile,” “.bashrc” and “/etc/profile” will be started, much like running su (or su root). You can ask any questions or share your thoughts via the comment section below.It’s essentially the same as just running su in the shell, save for one crucial difference: instead of telling the system to “switch users” directly, you’re telling it to run the su command with superuser privileges. We hope you find this article informative. You will also land into root’s home directory: $ suĪlso check out: How to Show Asterisks While Typing Sudo Password in Linux You will be given root’s default environment, including path to executable files changes. Importantly, when you run su without a username, you will automatically become the superuser. ![]() In this case, the user tecmint is provided his own default login environment, including path to executable files he also lands into his default home directory. All the commands below are equivalent to each other. Secondly, when you invoke su with a -, or -l or -login flags, it offers you a login interface similar to when you are logging on normally. : Permission denied” is displayed.īut at the end, user tecmint can list his home directory after running cd command without any options. $ su tecmintĬonsidering the scenario in the screenshot above, it is significant to note that the user tecmint keeps the environment from user aaronkilik’s original login session, the current working directory and the path to executable files also remain the same.Īs a result, when user tecmint tries to list the working directory (which is still user aaronkilik’s working directory), the error: “ ls: cannot open directory. Usually, to become another user or login to other user, you can invoke the following command, then you will be prompted for the password of the user you’re switching to. This article will help you briefly understand the difference between “su” and “su -“ in Linux systems. If executed without a username, for example su -, it will login as root user by default.Ī common challenge faced by new Linux users is understanding the difference between “su” and “su -“. The su command is used to switch to another user, in other words change user ID during a normal login session (that is why it is sometimes referred to as switch (-) user by a number of Linux users). These are two important commands used to implement security in Linux, in regards to user management policy and user permissions. In an earlier article, we have explained to you the difference between sudo and su commands in Linux.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |