Root account

On this page 7

The root account is the superuser of a Linux system, identified by user ID 0, for which the kernel bypasses ordinary permission checks on files, processes and system settings. In Linux permissions, root is the account that can read or change any file, kill any process, load kernel modules and reconfigure the entire machine.

Because root has unlimited authority by design, it is both indispensable and dangerous. Modern administration practice therefore keeps direct root logins rare and grants elevated rights through controlled, audited mechanisms such as sudo.

How root privileges work in Linux permissions

Root is not special because of its name but because of its numeric user ID. The kernel checks the effective UID of a process, and when it is 0, most permission checks in the Linux permissions model are skipped. Any account given UID 0 in /etc/passwd would have the same power, which is why duplicate UID 0 entries are a classic sign of compromise.

Internally, the kernel splits root’s power into capabilities, around forty distinct privileges such as CAP_NET_BIND_SERVICE for binding ports below 1024 or CAP_SYS_ADMIN for many administrative operations. A process running as UID 0 normally holds all of them, but capabilities can also be granted individually to non-root programs, which narrows the privilege to what is needed.

The table shows what root can do that an ordinary user cannot, and the restrictions that still apply.

ActionOrdinary userRoot account
Read or modify any fileOnly with matching permissionsAllowed regardless of mode bits
Change file ownershipNot allowedAllowed with chown
Signal other users’ processesNot allowedAllowed
Bind ports below 1024Not allowed by defaultAllowed
Load kernel modulesNot allowedAllowed unless locked down
Override mandatory access controlNot allowedStill restricted by SELinux or AppArmor policy
Root compared with an ordinary account

Ways to obtain root privileges

There are several paths to root privileges, and they differ mainly in auditability and in which password is required. The choice of path is a central security decision on every multi-user system.

MethodPassword requiredAuditabilityTypical use
Direct root loginRoot password or keyLow, actions appear as root onlyConsole recovery
suRoot passwordLow to mediumLegacy administration
sudoThe user’s own passwordHigh, logged per command and userDaily administration
Setuid programNoneDepends on the programSpecific tasks such as changing a password
File capabilitiesNoneMediumGranting one privilege to one binary

sudo is the preferred method because each command is attributed to a named person, privileges can be limited per command in the sudoers policy, and no shared secret is needed. Some distributions, such as Ubuntu, lock the root password by default and rely entirely on sudo for administration.

The commands sudo -i and su - start a full root login shell with root’s environment, while plain sudo runs a single command. Administrators should prefer single commands with sudo, because each one is logged separately and the elevated session ends automatically.

Root and file permission settings

Root interacts with the other permission tools in particular ways. chmod and chown run as root can change any file, and files created by root are owned by root unless ownership is changed afterward, a common cause of applications that later fail with permission errors.

The umask of root shells is usually 022, so files created as root are readable by everyone. Sensitive files such as keys therefore need explicit modes such as 600. Linux ACL entries do not restrict root, because root bypasses discretionary access control entirely, including ACLs.

Some limits apply even to root. Immutable attributes set with chattr block changes until removed, read-only mounts reject writes, and root squashing on NFS servers maps a client’s root user to an unprivileged account, so remote root does not become root on the server.

Hardening the root account

The guiding principle is least privilege: grant elevated rights only when needed, to named people, for specific commands, with logs. The practical measures below are common in production baselines.

MeasureSetting or toolBenefit
Disable remote root loginPermitRootLogin no in sshd_configRemoves the most attacked login name
Use sudo with named accountssudoers and group membershipPer-person accountability
Lock or randomize root passwordpasswd -l or a vaulted secretPrevents password guessing
Protect the consoleBootloader and recovery passwordsLimits physical bypass
Run services unprivilegedDedicated service users, capabilitiesLimits damage of a compromise
Root hardening measures

Services should drop root privileges as soon as possible. A web server may start as root to bind port 443, then switch worker processes to an unprivileged user; containers should run as non-root users wherever the image allows it.

Risks and common mistakes

Working as root removes the safety net of permission errors. A mistyped recursive delete or permission change that would fail for a normal user succeeds instantly for root and can destroy a system.

  • Staying in a root shell for routine work multiplies the impact of every typing error.
  • Sharing the root password among administrators makes actions impossible to attribute.
  • Running applications as root turns any application vulnerability into full system control.
  • Overly broad sudo rules, such as allowing an editor or shell, are equivalent to full root access.
  • Assuming container root is harmless ignores escape risks when user namespaces are not used.

Privilege escalation attacks target exactly this account. Attackers who gain an ordinary shell look for writable scripts run by root, misconfigured setuid binaries, permissive sudo rules and unpatched kernel flaws. Regular audits of sudoers files, setuid programs and cron jobs owned by root therefore belong in every hardening routine, together with prompt kernel updates.

In plain words

Think of a building where every employee has a key card that opens only certain doors. The building manager has a master key that opens every door, including the server room and the power switches.

The root account is that master key for a Linux computer. It can change anything, so careful organizations lend it out briefly and record every use instead of letting anyone carry it all day.

A real-world example

A company runs 60 Linux servers managed by five administrators who used to share one root password. After an unexplained configuration change that nobody could attribute, the security team disables root login over SSH and gives each administrator a named account with sudo rights.

The root password is replaced with a long random value stored in a password vault for emergency console access only. Sudo rules allow the support team to restart specific services without full root rights. Every privileged command is now logged with the person, time and exact command, and the next unexpected change is traced to its author within minutes.