Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the chmod command in linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use the chmod command in linux, which has certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

In linux, the chmod command allows users to change access to files and folders; like other commands, chmod commands can be executed through command line or script file execution.

Chmod command syntax

This is the correct syntax when using the chmod command:

Chmod [options] mode [, mode] file1 [file2...]

Here are some common options used by chmod:

●-f,-silent,-quiet (suppresses most error messages)

●-v,-verbose (output diagnostic information for each processed file)

●-c,-changes (similar to detailed but only reported when changes are made)

●-R,-recursive (recursively change files and directories)

●-help (Show help and exit)

●-version (output version information and exit)

The following is a list of several digital permissions that can be set for users, groups, and everyone else on the computer. Next to the number is the read / write / execute letter equivalent.

● 7: indicates rwx, with read, write, and execute permissions

● 6: indicates that rw-, has read and write permissions

● 5: indicates rx, with read and execute permissions

● 4: indicates Rmuri, with read-only permission

● 3: indicates-wx, with write and execute permissions

● 2: indicates-wmurf, with write-only permission

● 1: means-x, with execute permission only

● 0: indicates -, no permission

Note: if you need to list permissions for files, you need to use the ls command.

Example of chmod command

If the user wants to change the permissions of the file "participants" so that everyone can fully access the file, you need to enter the following command:

Chmod 777 participants

Description: the first 7 sets the permissions of the user, the second 7 sets the permissions of the group, and the third 7 sets the permissions of other owners.

If the user wants to be the only one who can access it, you can use the following command:

Chmod 700 participants

Users who want to provide full access to themselves and their team members can use the following command:

Chmod 770 participants

If users want to retain full access for themselves, but want to prevent others from modifying the file, you can use the following command:

Chmod 755 participants

The following uses the letters above to change the permissions of the file "participants" so that the owner can read and write to the file, but does not change the permissions of anyone else:

Chmod u=rw participants

Setting mode

Use the chmod command to set other file system modes for files and directories. For example, to set the stickiness bit-which means that only the file owner, directory owner, or superuser can delete the file, regardless of the file's read and write group permissions-add 1 before the number sequence:

Chmod 1755 participants

Other:

You can also use the chgrp command to change the group ownership of existing files and folders, and the newgrp command to change the default group for new files and folders.

Keep in mind that the symbolic links used in the chmod command affect the real target object.

Thank you for reading this article carefully. I hope it will be helpful for everyone to share how to use the chmod command in linux. At the same time, I also hope you can support us, pay attention to the industry information channel, and find out if you have any problems. Detailed solutions are waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report