Skip to content
hostcomplex

What Is sudo?

Maarten Soetens 3 min read

How sudo Grants Temporary Elevated Privileges

sudo is a Linux command that lets a permitted user run a single command with root privileges, without logging in as root. The name is short for "superuser do", and it applies root's rights only to the command that was typed.

A user who types sudo in front of a command is normally asked for their own password, not the root password. The system checks whether that user is allowed to run the command and, if so, runs it as root. Afterwards the session returns to ordinary privileges, so elevation lasts only as long as it is needed.

Each use is usually recorded in the system logs, so an administrator can see which account ran which command and when. This record is one of the main reasons sudo is preferred to shared root access, as the root user article explains.

The sudoers Rules and Why Permission Is Specific

Which users may use sudo, and for which commands, is set in a configuration called sudoers. On most systems the main file is /etc/sudoers, with optional extra rule files in a drop-in folder. The file is edited with a dedicated tool that checks its syntax, because a broken rule can lock every administrator out.

The rules can be broad or narrow. An administrator can allow a user full root access, or allow only one specific command, such as restarting a single service. Rules can apply to groups as well, so a team's access can be managed by changing group membership. This ties directly to how users and groups are organised on the system.

Why sudo Is Preferred Over Direct Root Logins

Logging in directly as root has practical drawbacks. If several people administer a server, they must share the root password, and a shared secret is hard to revoke once many people know it. Every action also appears under the name root, so the logs do not show which person made a change.

With sudo, each administrator has a personal account and password. Access can be removed by changing that person's rules, without changing a password everyone else uses. The log then shows the real user behind each privileged command. Administrators usually connect to these accounts over SSH, so the same personal account works for remote sessions too.

Frequently asked questions

Does sudo Ask for the Root Password?

On most systems, sudo asks for the password of the user running it, not the root password. This means ordinary administrators do not need to know the root password at all. Exact behaviour, including how long a password is remembered, depends on the sudoers configuration.

Can I Use sudo on Shared Hosting?

Usually not. Shared hosting accounts typically have no root access and no sudo rights, because the host manages the whole server. If you have a VPS or dedicated server, sudo may be available as long as your account has been given administrative rights. Check your host's documentation for your plan.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.