Gain temporary elevated privileges to administer the system without a persistent root session. 08.05.2026 | reading time: 2 min One command gives controlled root access: `sudo` lets a user run a single program with another user's privileges, by default root; use it to edit system files, install packages or run administrative scripts without logging in as root. Try it: edit a protected file Do this on a test machine to see behavior: ``` $ nano /etc/hosts Error opening /etc/hosts: Permission denied $ sudo nano /etc/hosts [sudo] password for user: # nano opens with root privileges and you can save changes $ sudo -l Matching Defaults entries for user on hostname: (ALL : ALL) ALL User user may run the following commands on hostname: (ALL : ALL) ALL ``` Flags that matter Run as another user with `sudo -u username command`, start a login shell with `sudo -i`, run an interactive shell with `sudo -s`, list permitted commands with `sudo -l`, refresh authentication with `sudo -v` and invalidate the timestamp with `sudo -k`—use these to script safely and to minimize time spent at elevated privileges. Configure sudo safely Edit privileges with `visudo` to avoid syntax errors, grant minimal command sets instead of full root where possible, set `NOPASSWD` sparingly, and check logs in `/var/log/auth.log` or the system journal to audit sudo activity; limit scope, not power. Other privilege systems `su` switches identity to another user and usually requires that user's password, `doas` is a lightweight alternative available on some systems, and `polkit` provides fine-grained policy control for desktop and system services; choose the tool that fits the environment and threat model. Next step Mastering `sudo` reduces risk and increases productivity: practice least-privilege patterns, read `/etc/sudoers` examples, and try per-command rules in a sandboxed VM; deepen your skills and consider formal certification like CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. utilities security processes scripting