Skip to content
Log In Sign Up info@muvcloud.com

What sudo Does

sudo stands for "superuser do". Put it in front of a command to run that command with root privileges:

sudo apt update
sudo systemctl restart nginx

It asks for your own password, not the root password. Before it runs anything, it checks the rules in /etc/sudoers to see whether you are allowed; how those rules are written is in the sudoers file. On Ubuntu the root account has no password by default, so sudo is the normal way to administer the system. On Debian, the first user gets sudo rights when you leave the root password empty during installation.

sudo can also run a command as a user other than root:

sudo -u www-data ls /var/www
sudo -u postgres psql

sudo vs su vs su -

CommandPasswordResult
sudo commandYour ownOne command as root
sudo -iYour ownRoot login shell
sudo -sYour ownRoot shell, your environment
suRoot'sRoot shell, current environment
su -Root'sRoot login shell
su - deployDeploy'sLogin shell as deploy

The dash in su - makes the switch behave like a fresh login: root's home directory, root's search path, and root's profile files. Without it, much of your own environment stays, and commands in /usr/sbin may not be found. sudo -i gives the same clean root shell as su - but with your own password, so it also works where root has no password.

Why sudo Is Preferred on a Server

  • No shared root password: each admin logs in with a personal account, and removing one person means removing one account from a group.
  • A trail per person: the log shows who ran which command.
  • Limited rights: a rule can allow only certain commands.
  • Fewer accidents: you raise your privileges for the one command that needs them, not for a whole session.

The Password Timeout

After you type your password, sudo remembers it for a few minutes in that terminal: 15 by default on Debian and Ubuntu, including sudo-rs, and 5 on AlmaLinux and Rocky Linux. That way a series of commands does not ask every time. sudo -v renews the period, and sudo -k ends it at once, which is useful before you step away from a session.

See What You May Run

sudo -l

The output lists the rules that apply to your account. A line ending in (ALL : ALL) ALL means full rights.

Where sudo Is Logged

On AlmaLinux and Rocky Linux, sudo writes to /var/log/secure. On Debian and Ubuntu it goes to /var/log/auth.log where rsyslog is installed, and to the system journal in every case:

sudo journalctl --since today | grep sudo

More on reading these files is in Linux log files and journalctl.

"User Is Not in the sudoers File"

This message means your account has no sudo rule. It is fixed from an account that already has rights: another admin, a root shell with su - if root has a password, or your provider's console. Add the user to the admin group, which is sudo on Debian and Ubuntu and wheel on AlmaLinux and Rocky Linux:

usermod -aG sudo deploy
usermod -aG wheel deploy

Group membership is read at login, so the user has to log out and back in. Check the result with groups. The full steps are in how to create a sudo user.

sudo on Ubuntu 25.10 and 26.04

From Ubuntu 25.10 on, the sudo command is sudo-rs, a rewrite in Rust. The everyday options in this guide, -i, -s, -u, -l, -v, and -k, behave the same, and it reads the same sudoers files. Its messages are worded differently from classic sudo, so search for the meaning of an error rather than its exact text.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations