What Is Root?
On Linux and Unix-like operating systems, root refers to two basic concepts: the most privileged user on the system and the starting point of the file system.
The root user
Root is the system administrator. Its user ID (UID) is 0 and it is not subject to permission checks: it can read, modify and delete every file, install programs, add users and shut the system down. Other users are limited to the files and operations they are allowed.
The root directory
The top of the file system is shown with the / sign and is called the root directory. Every directory branches from this point: /home holds user files, /etc holds configuration files and /var holds changing data. The root user's own home directory is /root.
sudo: taking privileges when needed
Instead of doing everyday work as root, the right way is to work as a normal user and run only the command that needs it with administrator privileges. sudo is used for this:
sudo apt update # runs a single command as root
sudo -i # switches to a root shell
whoami # shows the effective user
When working as root
- Commands given as root are carried out without asking for confirmation; one wrong delete command can make the whole system unusable.
- On servers, direct remote (SSH) login for root with a password should be disabled; key-based login and
sudoshould be preferred. - Services such as the web server and the database should run under their own restricted users, not as root.
Other meanings
The term is used for "the top level" in other areas too: the root servers at the top of the domain name system, the root directory of a site in a hosting account, or "rooting" a phone to gain administrator rights.
Read on: What Is Linux?