Understanding root, sudo and Linux users
On a VPS, root can do everything: change the system's logical core, delete files, alter permissions, listen on ports. Working as root all the time multiplies the consequences of a typo. sudo exists to grant that power briefly to a named account, without sharing the root password.
root, the UID 0 user
root is identified by UID 0, not by its name. Kernel permission checks compare numeric identifiers: renaming the account changes nothing about its power. root bypasses most permission checks and can read, write and delete almost anything.
id
whoamiid shows the UID, GID and groups. A named account has a UID above 1000; root has uid=0(root). The 0 matters, not the word "root".
sudo, a one-command delegation
sudo runs a command with another user's privileges, root by default. You authenticate with your password, not root's, and the power lasts only for that command.
sudo systemctl restart nginx
sudo -l
sudo -isudo -l lists what your account may run. sudo -i opens a full root shell: handy, but return to your account afterwards. sudo -s does the same without resetting the environment, which can surprise you with PATH.
The sudo group and sudoers
On Debian 13, members of the sudo group get full rights through a rule shipped in /etc/sudoers. To grant sudo:
sudo usermod -aG sudo utilisateurThe user must log in again for the new group to apply. For a narrower rule, create a file in /etc/sudoers.d/ and edit it only with visudo -f. visudo checks syntax: an error in that file can lock you out of sudo.
Sessions and audit trail
sudo logs the command, the user and the time. With journald:
journalctl SYSLOG_IDENTIFIER=sudo --since todayAn open root session stays active even after a password change. Close unused shells and never leave a root terminal in a shared multiplexer. su - asks for the root password and opens a full environment; prefer sudo -i when your account is already authorised.
Best practices
- One named account per person, never a shared account.
- root reserved for repairs, not daily work.
sudofor precise commands, notsudo bashout of habit.- No
chmod 777to "make a service work". - Check
sudo -lafter every rights change. - Disable direct SSH root login once a sudo user is tested.
Advertisement
Was this article helpful?
Read next
- Update Debian on a VPSapt update and upgrade, required reboots and precautions before a release upgrade.
- Change the root password of a VPSpasswd, reset from the panel and updating every access that used the old password.
- Publish your first page on a VPSInstall Nginx, create a page under /var/www, open port 80 and test over both IPv6 and IPv4.