Linux Basic Administration Concepts

Permissions and ownership

In UNIX, every file must be owned by some user and by some group. This is usually the user id and group id of the user who created the file. The user who owns the file can change the file's permissions, specifying what other users can do with the file.

File permissions and ownership information can be viewed using ls -l(long). The output looks as follows:

-rwxr-xr-x    1 root     root       579384 Feb 25  2002 /bin/bash
-r-------- 1 root root 1594 Aug 25 23:09 /etc/shadow
drwxr-xr-x 18 root root 4096 Sep 1 14:41 /usr
drwx--x--x 212 alon alon 28816 Sep 19 00:47 /home/alon/

The first column is the file permissions(details below). The thrid and fourth columns list the user and group the file belongs to.

The first letter in the permissions specifies the type of the file: "-" is a regular file, "d" is a directory. The next three letters specify read(r) write(w) and exectute(x) permissions of the file's owner. The next three letters are for users in the file's group, and the last three of for the rest of the users on the system. Note that the exectute permission for directories actually means the permission to enter the directory and its subdirectories.

Permissions can be changed using the chmod command. Ownership can be changed by root only using the chown command. The default permissions for new files are set using the umask command. See the man pages of these commands for details.

Valid HTML 4.01!Alon Altman