Problem Statement
What is the purpose of the sudo command?
Explanation
Sudo (superuser do) allows authorized users to execute commands with elevated privileges, typically as root, without logging in as root. This provides better security through auditing (all sudo commands are logged), accountability (tracking who ran what), and least privilege principle (users only get root access when needed, not permanent root access).
Basic usage: sudo command runs command as root after password verification. Sudo -u username command runs as different user. Sudo -i opens root shell. Configuration is in /etc/sudoers file, edited with visudo command (never edit directly). Grant sudo access by adding users to sudo group (Debian/Ubuntu) or wheel group (RHEL/CentOS).
Sudoers file allows fine-grained control: which users can run which commands, on which hosts, as which users, with or without password. Example entry: username ALL=(ALL:ALL) ALL gives username full sudo access. NOPASSWD option allows running sudo without password for specific commands. Understanding sudo is crucial for secure multi-user system administration.
