To manage the many combinations and define the access mode of each file or directory in a more efficient way, the assigned numbers are also used for the access mode setting. The numbers are assigned for each permission as shown below.
r
: 4w
: 2x
: 1-
: 0Using the sum of all numbers, you can represent all access modes with a single digit for one user type. To cover the three user types, you need only three digits. Here are some examples.
755 : typical access mode when the superuser creates a directory
rwx
r-x
r-x
775 : typical access mode when a normal user creates a directory
rwx
rwx
r-x
644 : typical access mode when the superuser creates a file
rw-
r--
r--
664 : typical access mode when a normal user creates a file
rw-
rw-
r--
700 : typical .ssh directory permission
rwx
---
---
600 : typical ssh private key permission
rw-
---
---
To check the initial permission, create four types of documents:
To create the documents, run the commands below.
mkdir dir_ubuntu
touch file_ubuntu
sudo su
mkdir dir_root
touch file_root
Run the ls -l
command to see the permission of each document. You can see that the initial permission settings are the same as the ones explained in this section.
ls -l
drwxr-xr-x 2 root root 4096 Jan 3 01:36 dir_root
drwxrwxr-x 2 ubuntu ubuntu 4096 Jan 3 01:37 dir_ubuntu
-rw-r--r-- 1 root root 0 Jan 3 01:36 file_root
-rw-rw-r-- 1 ubuntu ubuntu 0 Jan 3 01:37 file_ubuntu
To change the access mode of dir_ubuntu to 700
and file_ubuntu to 600
, run the command below.
chmod 700 dir_ubuntu
chmod 600 file_ubuntu
ls -l
drwxr-xr-x 2 root root 4096 Jan 3 01:36 dir_root
drwx------ 2 ubuntu ubuntu 4096 Jan 3 01:37 dir_ubuntu
-rw-r--r-- 1 root root 0 Jan 3 01:36 file_root
-rw------- 1 ubuntu ubuntu 0 Jan 3 01:37 file_ubuntu
To manage the many combinations and define the access mode of each file or directory in a more efficient way, the assigned numbers are also used for the access mode setting. The numbers are assigned for each permission as shown below.
r
: 4w
: 2x
: 1-
: 0Using the sum of all numbers, you can represent all access modes with a single digit for one user type. To cover the three user types, you need only three digits. Here are some examples.
755 : typical access mode when the superuser creates a directory
rwx
r-x
r-x
775 : typical access mode when a normal user creates a directory
rwx
rwx
r-x
644 : typical access mode when the superuser creates a file
rw-
r--
r--
664 : typical access mode when a normal user creates a file
rw-
rw-
r--
700 : typical .ssh directory permission
rwx
---
---
600 : typical ssh private key permission
rw-
---
---
To check the initial permission, create four types of documents:
To create the documents, run the commands below.
mkdir dir_ubuntu
touch file_ubuntu
sudo su
mkdir dir_root
touch file_root
Run the ls -l
command to see the permission of each document. You can see that the initial permission settings are the same as the ones explained in this section.
ls -l
drwxr-xr-x 2 root root 4096 Jan 3 01:36 dir_root
drwxrwxr-x 2 ubuntu ubuntu 4096 Jan 3 01:37 dir_ubuntu
-rw-r--r-- 1 root root 0 Jan 3 01:36 file_root
-rw-rw-r-- 1 ubuntu ubuntu 0 Jan 3 01:37 file_ubuntu
To change the access mode of dir_ubuntu to 700
and file_ubuntu to 600
, run the command below.
chmod 700 dir_ubuntu
chmod 600 file_ubuntu
ls -l
drwxr-xr-x 2 root root 4096 Jan 3 01:36 dir_root
drwx------ 2 ubuntu ubuntu 4096 Jan 3 01:37 dir_ubuntu
-rw-r--r-- 1 root root 0 Jan 3 01:36 file_root
-rw------- 1 ubuntu ubuntu 0 Jan 3 01:37 file_ubuntu