8/4/2023 0 Comments Su vs sudo su![]() ![]() Su will switch you to another user environment will open a session of that user, and you will become that user, it can be root or any other, sudo will upgrade your privileges and let you run commands as root, provided you have the rights, that is you are listed in sudoers file. That will ask user's password and then run ls command as root, you have to configure the sudoers fileĪs you can see, one can achieve same goal (run privileged commands) with both su and sudo they work in different ways and they are made for different things, it is up to you to use the most appropriate command deppending on your needs and general scenario. Sudo is a different beast, if you want to give some users access to perform some tasks as root without given them root's password, you will have to use sudo command, in this case those users just have to enter their own passwords and run something like this: sudo ls / Will switch you to root, you will have to know root's password Will switch your current user to john, provided you know john's password, if you want to get all environment variables that john get when he logs in you can use: su - johnĪfter that you can run commands in john's environment su. ![]() 'su -' gives you roots environment also-just as if you had logged in as root. In few words su command switches user, from your current user to any other one, it may be root or not su john Rep: 'su' gives you root powers, but keeps your regular user environment. ![]() sudo: Execute the command with super user which is root usually. For su command, we need the password from the user which after the switch not before. The optional argument - may be used to provide an environment similar to what the user would expect had the user logged in directly sudo -i root, sudo - root, sudo -i, sudo -, sudo root have same effect, when asked, enter the password for the current user, the user must be in the sudoers group. Invoked without a username, su defaults to becoming the superuser. The su command is used to become another user during a login session. Edit: BTW - the reason for the difference between sudo renew and sudo su - renew is that the latter causes the shell definitions to be redefined by. ‘su’ Vs ‘sudo’ ‘su‘ forces you to share your root password to other users whereas ‘sudo‘ makes it possible to execute system commands without root password. With Linux like with most things in life you have different ways to accomplish a specific task, this is the case of su and sudo they are different commands with different goals but they are usually used one instead the other. NOTE This article is more applicable to Ubuntu based distributions, but also applicable to most of the popular Linux distributions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |