Sudo runs a single command with root privileges it doesn’t switch to the root user or require a separate root user password. Su switches you to the root user account and requires the root account’s password. The sudo command is controlled by your /etc/sudoers file and can be configured to permit privilege escalation without a password. This is a key difference between su and sudo. Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen. su someuser -c echo hello world They have slightly different semantics. ![]() Just use those commands with caution, so you don’t wind up wreaking havoc on your Linux desktop or server. However, if there’s a command you must run, and it fails with a minimal sudo command, either sudo – or sudo su – will always work. Both commands can be used to run commands as another user compare: sudo -u someuser echo hello world With: su someuser -c echo hello world They have slightly different semantics. Most often, you’ll only have to run basic sudo or su commands. 1 Answer Sorted by: 2 The sudo method uses the sudo command, and the su method uses the su command. bashrc files by root, but only if the user running the command is defined in the /etc/sudoers file, effectively becoming the root user, even if the root user is disabled, such as it is in Ubuntu.įinally, if you issue the command sudo su, you switch to the root user, without resetting the environment variables, so you have the root user privileges, but not the environment. If you run the command sudo su – you will switch to the root user which will then execute all /etc/profile. If you use just sudo, you execute a command with admin privileges. SEE: Linux file and directory management commands (TechRepublic Premium) Execute the command su – and you invoke a login shell after switching the user, which resets most environment variables, providing a clean base. Understanding the differences between the two is crucial for system administrators to choose the best option for their use case and ensure the security of their systems. If you issue the command su, you switch your user to root which then executes only the. The su command grants root access by switching to the root account, while sudo grants elevated privileges to a specified user without switching accounts. There are different ways to use sudo and su. Even though most every Linux distribution uses sudo, some of them (such as Fedora and openSUSE) allow you to su (switch user) to the super user account–otherwise known as root. Sudo stands for “super user do” and allows standard users to take admin-level actions, such as installing software. If you’re a new Linux admin, you probably at least know about sudo.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |