If you’re a new Linux admin, you probably at least know about sudo. Sudo stands for “super user do” and allows standard users to take admin-level actions, such as installing software. 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.
There are different ways to use sudo and su. Let’s strip away the mystery.
If you issue the command su, you switch your user to root, which then executes only the .bashrc file owned by root. Execute the command su – and you invoke a login shell after switching the user, which resets most environment variables, providing a clean base.
SEE: Linux file and directory management commands (TechRepublic Premium)
If you use just sudo, you execute a command with admin privileges. If you run the command sudo su – you will switch to the root user which will then execute all /etc/profile, .profile, and .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.
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. Most often, you’ll only have to run basic sudo or su commands. 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.
Just use those commands with caution, so you don’t wind up wreaking havoc on your Linux desktop or server.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.