Using the root account for day-to-day work is a bad idea. It’s better to use sudo to act like root when you need to do a little system administration. Ken Hess shows you how.
A Linux system has two kinds of users: ordinary users and the root user. Each ordinary user has a robust set of permissions to manage his or her own files (and files that belong to a group that he or she is a member of), but an ordinary user cannot affect system configuration, start or stop essential services such as the SSH daemon, and cannot reserve a so-called privileged port, or any networking port numbered less than 1,024. The root user, though, is free to access and modify any file, perform any task, and affect the system at will.
Of course, as Spider-Man says, ‘With great power comes great responsibility.’ root must be cautious, because a small typo can lead to disaster. For example, there’s a big difference between the command rm -rf /a and rm -rf /. Given the potential for such accidental cataclysms, it’s considered a best practice to never log in as root, lest you forget or misdirect the (remaining in the Marvel Comics universe) Thor-like power you wield.
Indeed, many Linux distributions preclude root logins, preferring instead to grant the initial user the right to act like root when necessary. This special privilege, which can be extended to other users on the system, is managed via the sudo (pronounced ’soodoo’) utility. sudo controls who can act like root, and can further control what a user can do as root.
When a task requires root powers, and assuming the user has the right to perform the task…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: