chmod command

LINUX-Frequently used commands

chmod command Change access permissions
Syntax
chmod  [Option]  [Access permissions] [File name or directory name]
The chmod command changes the access rights of the specified file.
The access privileges to be changed can be written either as letters or numbers.
If you specify a directory, only that directory will have its access rights changed.
If you specify the "-R" option, you can change the access rights for all files and directories under the specified directory.
If the "-R" option is specified at the same time, access rights can be changed for all files and directories under the specified directory.
※ However, general users can only change access rights to files that they own.
In contrast, root can change access rights to any file. On the other hand, root can change the access rights of any file.
In contrast, root can change access rights for any file.
Frequently used options
-R   Change the access rights of all files under the specified directory.
-f    Do not display an error message if access privileges could not be changed.
Example: Change access permissions.
$  ls -l  temp.txt
-rw-rw-r-- 1 koro koro 0 Feb 02 02:02 temp.txt  ← Current access  rw-rw-r--
$  chmod 755 temp.txt
$  ls -l  temp.txt
-rwxr-xw-x 1 koro koro 0 Feb 02 02:02 temp.txt ← Access changed to rwxr-xw-x
Example: Change the access rights under the specified directory at the same time.
$  chmod -R 777 temp
$  ls -ld temp
drwxrwxrwx 2 koro koro 3333 Mar 03 03:03 temp  ←The access rights of the directory will be changed.
$  ls -l temp
-rwxrwxrwx 1 koro koro 0 Mar 03 03:04 temp.txt  ←The access rights of the file will be changed at the same time.
Copied title and URL