Home > Operation and Maintenance > Linux Operation and Maintenance > How to modify read-only permissions in Linux

How to modify read-only permissions in Linux

WBOY
Release: 2022-03-11 10:51:36
Original
23060 people have browsed it

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]".

How to modify read-only permissions in Linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to modify read-only permissions in Linux

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...
Copy after login

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
Copy after login

Change the file file1 .txt Set to be readable by everyone:

chmod ugo+r file1.txt
Copy after login

Set the file file1.txt to be readable by everyone:

chmod a+r file1.txt
Copy after login

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
Copy after login

Add executable permissions to the ex1.py file owner:

chmod u+x ex1.py
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template