Get the App
SLTechnology News&Howtos  ›  Servers  › 

How linux modifies read-only permissions

Shulou Source: shulou.com Published: 2022-05-31 11:05:05 09月21日 Update

In this article, the editor introduces in detail "how linux modifies read-only access". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to modify read-only access in linux" can help you solve your doubts.

In linux, you can use the chmod command to modify file read-only permissions, which is used to control the user's permissions on the file. Setting the parameter "r" indicates read permissions, "w" indicates writable permissions, "x" indicates executable permissions, and the syntax is "chmod [- cfvR] [--help] [--version]".

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

How to modify read-only permissions for linux

The Linux chmod command is a command that controls the user's permissions on a file.

Only file owners and superusers can modify the permissions of a file or directory. You can use absolute mode (octal number mode), and symbolic mode specifies the permissions of the file.

Grammar

Chmod [- cfvR] [--help] [--version] mode file...

Parameter description

Mode: permission setting string, in the following format:

[ugoa...] [[+-=] [rwxX]...] [,...]

Where:

U indicates the owner of the file, g indicates that the owner belongs to the same group (group) as the owner of the file, o indicates someone other than others, and an indicates all three.

+ means to increase permissions,-to cancel permissions, and = to set permissions uniquely.

R means readable, w means writable, x means executable, and X means only if the file is a subdirectory or if the file has been set to executable.

Description of other parameters:

-c: if the permission of the file has indeed been changed, the change action will be displayed.

-f: do not display an error message if the file permissions cannot be changed

-v: displays the details of permission changes

-R: make the same permission changes for all files and subdirectories in the current directory (that is, change them one by one recursively)

-- help: displays auxiliary instructions

-- version: display version

For example, add executable permissions to a shell file:

Chmod + x test3.sh

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

Chmod ugo+r file1.txt

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

Chmod Aguilr file1.txt

Set the file file1.txt and file2.txt as the owner of the file, which can be written by those who belong to the same group, but not by others:

Chmod ug+w,o-w file1.txt file2.txt

Add executable permissions to the owner of the ex1.py file:

Chmod uplix ex1.py has read this article, "how to modify read-only permissions in linux" article has been introduced, want to master the knowledge of this article still need to be hands-on practice in order to understand, if you want to know more related articles, welcome to follow the industry information channel.

Tags: Permissions files commands owners parameters articles patterns users directories content only owners groups syntax control proper same size all spelling octal Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi Huawei MariaDB Microsoft