A user is an identity used by an operating system to determine who or what is allowed to access files, run programs, change settings, and perform other actions. A user normally has a username, a numeric identifier, permissions, and often a home directory containing their files and settings.
Users are not always people. Operating systems also create system users for services and background processes. A web server, database, or other service may run as its own user so that it only receives the permissions it needs.
How It Works
On Linux, each user has a numeric User ID, or UID. The operating system primarily uses the UID to identify the user, while the username provides a human-readable name.
For example:
sam:x:1000:1000:Sam:/home/sam:/bin/bash
This entry describes a user named joe with UID 1000, a home directory at /home/sam, and /bin/bash as their shell.
Linux stores local user information in:
/etc/passwd
We can see the users known to the system with:
getent passwd
On Ubuntu, users generally fall into three groups: pre-installed system users normally have UIDs from 0 to 99, dynamically created system users normally use 100 to 999, and regular human users normally start at UID 1000. Other Linux distributions may use different ranges.
Root
The special Linux user root is the superuser. It has UID 0 and effectively has permission to access or modify anything on the system.
Because root has unrestricted access, we normally work using a regular user account and temporarily request elevated privileges when required. On many Linux systems this is done with sudo:
sudo apt update
Here, our normal user asks the system to run the command with elevated privileges, usually as root.
A root shell may sometimes appear like this:
root@server:~#
A normal user's shell may look more like:
sam@server:~$
The # is commonly used by shells to indicate a root prompt, while $ commonly indicates a regular user.
System and Reserved Usernames
Linux distributions create usernames for the operating system and installed services. These accounts may own files or run processes, but they are generally not accounts that a person logs into.
There is no single universal reserved username list for every Linux distribution. The exact accounts depend on the distribution and installed software. Debian and Ubuntu, for example, reserve or predefine a number of usernames for system use.
Common core system usernames include:
root
daemon
bin
sys
sync
games
man
lp
mail
news
uucp
proxy
www-data
backup
list
irc
gnats
nobody
Other software packages can create additional special user-account.
Before creating a new Linux user, we should therefore avoid names already used by the operating system or installed software. We can see the usernames already present on a machine with:
cut -d: -f1 /etc/passwd
User vs Group
A user identifies a person, service, or process. A group collects multiple users so that permissions can be granted to them together.
For example:
User: sam
Groups: sam, developers, sudo
Here, sam is the user. Membership in the developers group may grant access to development files, while membership in the sudo group may allow the user to run approved commands with elevated privileges.