On Linux there are two commands to get superuser access: su and sudo. Which one you should use depends on the task at hand.

Key in a lock

Depending on your Linux setup, you can perform administrative tasks with either the su command or sudo. It is easy to confuse these two commands as they both have similar functions.

So which command should you use? Let's find out.

Su gives you full root access

The traditional way to access the root account to configure a Linux system dates back to Unix times by using the su command:

su –

That ""means that you have the same environment as if you were to log in directly as root. The system prompts you for your password. If you are successful, the prompt changes to"#"Sign. You can then run any commands you need as root.

Type Log out or hit Ctrl + D to return to the default user right when you are done.

While su is useful, the main problem is that it is an all-or-nothing option. You have full root access or normal permissions. If you have multiple administrators on a server, you must use the same root password.

Sudo gives you more control

More Linux distributions like Debian and Ubuntu install sudo by default because it's safer than using su. It's a mature tool that has been around since 1980.

Sure, you only need to remember one password, but the full power of sudo is managing multiple administrators on multiple computers. It's so useful that Sudo was immortalized in geek culture in a famous XKCD comic. You can even configure sudo to run without a password, but this is obviously not recommended for servers where security is paramount.

In addition to full root access as with su, you can specify which users have which commands on which systems in the / etc / sudoers File. Because of the flexibility of sudo, the / etc / sudoers Syntax is complex.

Debian Chromebook Sudoers file

Related: How to Add a User to the Sudoers List in Linux

Use sudo if you can

Because sudo is more granular and secure than su, it is set as the default superuser command by more Linux distributions. Usually the first user is called the "administrative" user and is thus set up to use sudo.

If sudo is not installed on a system, you can easily get it through the package manager. After installation, all other users with administrator rights just need to add one user to the correct group, usually "admin", "sudo" or "wheel". These user groups are also distribution specific.

You can now safely manage your Linux system

With sudo you can easily manage your Linux system with your user password. Users often overlook the flexibility of this tool. While Linux is a secure operating system, no operating system is perfect. There are still some security concerns with Linux that you should be aware of.

Linux immune viruses

Is Linux Really Immune to Viruses and Malware? Here is the truth

You heard that Linux isn't really affected by viruses and malware. But why is it like that? And above all: is that true?

Continue reading

About the author

David Delony
(42 published articles)

David is a freelance writer based in the Pacific Northwest but originally from the Bay Area. He has been passionate about technology since childhood. David's interests include reading, watching quality TV shows and movies, retro games, and collecting records.

More
By David Delony

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

Click here to subscribe