The multi-user capability of Unix-like systems is a feature that is deeply ingrained into the design of the operating system.
On a Linux system, each file and directory is assigned access rights for the owner of the file.
You can check the permission settings with
$ ls -l drwxr-xr-x. 13 root root 1027 Jan 3 12:32 bin/cat
Let's explore what
drwxr-xr-x. 13 root root 1077 Jan 3 12:32 bin/cat means one by one.
|13||Number of links|
|root||The owner of the file|
|root||The group the file belongs to|
|1027||Size of the file|
|Jan 3 12:32||Time Stamp|
|bin/cat||The name of the file/directory|
r letter means the user has permission to
read the file/directory. The
w letter means the user has permission to
write the file/directory. And the
x letter means the user has permission to execute the file/directory.
Let's take a look at the 9 letters in the command.
The first 3 letters show the permissions for the file owner, the second 3 letters show the permissions for the group owner and the last 3 letters show the permissions for other users.
rwx/ r-x/ r-x/ Owner: rwx Group: r-x Users: r-x
chmod command is used to change the permissions of a file or directory.
Each permission may be specified with an octal number:
read = 4;
write = 2;
execute = 1;
no permission = 0.
The command below means giving permissions to
execute(1) to the owner and permissions to
execute(1) to the group user and permissions to
read(4) to other users.
chmod 754 myfile
The below is the basic syntax of
% chmod who operator permission filename
You can use the following commands to change modes.
|a(all)||user, group, and other access|
|+||add specified permissions|
|-||remove specified permissions|
|=||set the specified permissions|
In the following example, read permission are taken away from others.
% chmod o-r filea
In the following example, read and execute permissions are added for user, group, and others.
$ chmod a+rx fileb
In the following example, read, write, and execute permissions are assigned to the group.
$ chmod g=rwx filec