Access modes of files and directories is a helpful feature that restricts the users to allow only specified operations on the files. A file can be accessed with different modes by different users. The chmod command in Linux helps us to set the access modes of files and directories. In this article, we will discuss various options and examples of the chmod command.
chmod Command in Linux
The chmod command is used to modify the access mode of a file in Unix-like and Linux operating systems. Change mode is abbreviated in the name. The syntax is:
chmod [reference][operator][mode] file...
Options and Examples of chmod command
+rwx : This is used to add permissions on files and directories
-rwx : This is used to remove permissions from files and directories.
+x : This is used to set executable permissions.
-wxr : This is used to remove write, read, and executable permissions.
This option is used to display information about the version of the command
This option is identical to verbose, except it reports whether or not a change has been made.
-f, —silent, —quiet
It is used to silence or suppress the error messages and warnings.
This option displays a diagnostic for each file that is handled.
This option prevents the backslash sign ('/') from being treated (the default).
If this option is used, the recursive operation on backslash ('/') will fail.
It specifies the RFILE's mode instead of the MODE settings.
This option is used to recursively alter files and directories.
This option displays the help manual, which includes a brief overview of how to use this command and its options.
Mapping permissions to numeric digits
In this article, we went through the chmod command in Linux, which is used to change the access modes of the files. It provides options like recursive alteration of files, displays diagnostic for files, notify the change, etc.
People are also reading: