This is the old ROX web-site. Please use the new website instead.
Linux runs different programs with different privileges. This reduces the risk from having several people using the same computer; one person shouldn't be able to mess up another's files. Even if one user gets a virus, it shouldn't be able to infect other users of the machine.
All the users on the system are listed in the file /etc/passwd (so called because it used to contain their passwords, but they've moved to a different file now). Each user has a login name, a home directory, a user ID (a unique number) and a few other details listed here. The system uses the user ID numbers internally, but displays them as names, using the passwd file to convert. Your distribution probably has a graphical tool, or at least a command-line utility like adduser, to help with creating new users.
As well as one user for each real user of the machine, there are a number of system users. Various important activities are run as these users. This helps to ensure that a security breach to one part of the system doesn't affect the whole system. For example, the lp 'user' runs the printer daemon. Thus, the printing system can't delete users' files, even if it goes wrong.
The root user (with user ID 0) has access to everything. Therefore, running anything as root is rather dangerous.
There is a similar system of groups. They are listed in /etc/group. Users can belong to several groups. This can be used on larger systems to share files between groups (for example, there may be a group for each project being worked on). Sometimes, access to certain system resources requires being in a certain group. Eg, only users in the dialout group can use the modem.
Every running instance of a program (a process) runs as a particular user, and with membership of a number of groups. When you log in, your session script is given your user ID, and granted membership of the groups listed in /etc/group (therefore, if you add yourself to a group, you'll need to log out before the changes take effect).
Every file and directory in the system has a set of permissions, which restrict processes' access to them. Each file also has an owner (a user ID) and a group (a group ID).
There are three groups of permissions: user (owner), group and other (world).
There are also three types of access allowed (read, write and execute), giving a total of nine bits, plus a few other flags. A typical set of permissions looks like this:
rw-,r--,---
Here:
The execute bit is listed as a permission, but for files is really more of a hint that it can be run. Do not rely on the execute bit to prevent a program from being run!
For directories, the execute bit allows the directory to be used as a means to access the files inside it.
Normally, when you run a program, that program runs as you. So, if Bob runs a program owned by Mary, the program can access Bob's files, but not Mary's. However, if the special SetUID (set user ID) permission bit is set on the program, it runs with the user ID of the program's owner. SetUID programs are often owned by root, and therefore are potential security risks (you don't want too many of these around!).
There is a similar SetGID bit, which does the same thing with the file's group.
When you need to make a change to the system that affects other users, you'll need to get root privileges. There are several ways to do that:
su and sudo are both SetUID programs, because they are run by ordinary user processes but must get additional privileges to do their jobs.