Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".(Japanese Version)

Change the default permissions for files and directories

Change the default permissions for files and directories

When you create a new file or directory, it will have default permissions. To change the default permissions, use the umask command.

Permissions in octal notation
flag notation     rwx
corresponding octal number      421

●Check the current default permissions

Check the current default permissions
[nuy@Lion nuy]$ umask ←Run the "umask" command

0022 ←The default permissions will be displayed

Checking permissions on directories and files

[nuy@Lion nuy]$ mkdir sampdir ←Create the directory sampdir
[nuy@Lion nuy]$ ls -ld sampdir
drwxr-xr-x 2 nuy nuy 4096 Sep 12 15:45 sampdir/
↑Permissions are 777-022=755
[nuy@Lion nuy]$ touch samptxt ←Create the file samptxt

[nuy@Lion nuy]$ ls -l samptxt
-rw-r--r-- 1 nuy nuy 0 Sep 12 16:00 samptxt
↑Permissions are 666-022=644

●Changing the permission value

[nuy@Lion nuy]$ umask 0002 ←Run the umask command
[nuy@Lion nuy]$ mkdir sampdir2 ←Create the directory sampdir2
[nuy@Lion nuy]$ ls -ld sampdir2
drwxrwxr-x 2 nuy nuy 4096 Sep 12 17:00 sampdir2/
↑Permissions are 777-002=775
[nuy@Lion nuy]$ touch samptxt2
[nuy@Lion nuy]$ ls -l samptxt2
-rw-rw-r-- 1 nuy nuy 0 Sep 12 18:00 samptxt2
↑Permissions are 666-002=664
Copied title and URL