In Linux, you can use the chmod command to modify the read-only permissions of files. This command is used to control the user's permissions on files. Set the parameter "r" to indicate read permissions, and "w" to indicate write permissions. , "x" indicates executable permission, and the syntax is "chmod [-cfvR] [--help] [--version]".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
Linux chmod (English full spelling: change mode) command is a command to control user permissions on files
Only file owners and super Users can modify the permissions of files or directories. You can use absolute mode (octal number mode) and symbolic mode to specify file permissions.
Syntax
chmod [-cfvR] [--help] [--version] mode file...
Parameter description
mode: Permission setting string, the format is as follows:
[ugoa...][[ -=] [rwxX]...][,...]
Among them:
u represents the owner of the file, and g represents the owner of the file. In the same group, o means other people, and a means all three.
means adding permissions, - means canceling permissions, = means setting only permissions.
r means readable, w means writable, x means executable, and X means only when the file is a subdirectory or the file has been set to be executable.
Other parameter descriptions:
-c: If the file permissions have indeed been changed, the change action will be displayed
-f : Do not display an error message if the file permissions cannot be changed
-v : Display details of permission changes
-R : Make the same permission changes to all files and subdirectories in the current directory (that is, change them one by one recursively)
--help : Display auxiliary instructions
--version: Display version
For example, add executable permissions to a shell file:
chmod +x test3.sh
Change the file file1 .txt Set to be readable by everyone:
chmod ugo+r file1.txt
Set the file file1.txt to be readable by everyone:
chmod a+r file1.txt
Set the files file1.txt and file2.txt to The file owner can write to the same group as the file owner, but others cannot write to it:
chmod ug+w,o-w file1.txt file2.txt
Add executable permissions to the ex1.py file owner:
chmod u+x ex1.py
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to modify read-only permissions in Linux. For more information, please follow other related articles on the PHP Chinese website!