In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use the chmod command in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.
Linux common commands chmod commands are commands that control users' permissions on files. The file call rights of Linux/Unix are divided into three levels: file owners (Owner), user groups (Group), and other users (Other Users).
Chmod is used to change the permissions of files or directories
Summary chmod [OPTION]... MODE [, MODE]... FILE... Chmod [OPTION]... OCTAL-MODE FILE... Chmod [OPTION]... -- reference=RFILE FILE... The main purpose is to change the permissions of the target file or directory by combining symbols.
Change the permissions of the target file or directory by octal number.
Change the permissions of the target file or directory by referring to the permissions of the file.
Parameter mode: octal number or symbol combination.
File: specify one or more files for which you want to change permissions.
Option-c,-- changes: outputs operation information when the permissions of the file are changed. -- no-preserve-root: do not specialize'/'. Default option. -- preserve-root: cannot operate recursively in the root directory. -f,-- silent,-- quiet: suppress the output of most error messages. -v,-- verbose: output operation information regardless of whether the file has changed permissions or not. -- reference=RFILE: use the permissions of the reference file or the reference directory RFILE to set the permissions of the target file or directory. -R,-- recursive: recursively change permissions on directories and files under directories. -- help: displays help information and exits. -- version: displays version information and exits. The return status of the return value is successful unless an illegal option or parameter is given.
For example, refer to the DESCRIPTION paragraph of the man chmod document to learn:
The u symbol represents the current user.
The g symbol represents a user who is in the same group as the current user, hereinafter referred to as the group user.
The o symbol represents other users.
The a symbol represents all users.
The r symbol represents read permissions and the octal number 4.
The w symbol represents write permissions and the octal number 2.
The x symbol represents the execution permission and the octal number 1.
The X symbol means that if the target file is an executable file or directory, you can set executable permissions to it.
The s symbol stands for setting permissions suid and sgid, the ID bit of the user of the file is set with the combination of permissions, and the ID bit of the group user is set by GDSs.
The t symbol means that only the owner of the directory or file can delete the file under the directory.
The + symbol means to add the appropriate permissions for the target user.
-the symbol represents the deletion of the corresponding permissions of the target user.
The = symbol means to add the appropriate permissions for the target user and remove the permissions that are not mentioned.
User rights description for linux files: # View the long format of the current directory (containing hidden files). Ls-la-rw-r--r-- 1 user staff 651 Oct 12 12:53. Gitmodules # the first bit represents a directory if it is d, and a-represents an ordinary file. # for more details, please see the'- l' option section of info coreutils'ls invocation' (the info document for the ls command). # bits 2 to 4 represent the permissions of the current user. # 5 to 7 represent the permissions of group users. # 8 to 10 represent the permissions of other users. # add write permissions for group users. Chmod Grouw. / test.log # removes all permissions from other users. Chmod o =. / test.log # makes all users have no write permission. Chmod a Murw. / test.log # the current user has all permissions, the group user has read and write permission, and other users only have read permission. The octal equivalent of chmod u=rwx, g=rw, otakr. / test.log # means: chmod 754./ test.log # sets the directory and the files in the directory so that all users have read and write permissions. # Note that the execution and read permissions of the current user must be retained when using the'- R 'option, otherwise an error will be reported! Chmod-R a=rw. / testdir/ # sets file permissions based on permissions of other files. Chmod-- reference=./1.log. / test.log Note that this command is a command in the GNU coreutils package. For help, please see man chmod or info coreutils' chmod invocation'.
The permissions of the symbolic link cannot be changed, and if the user modifies the permission of the symbolic link, the change will affect the original file being connected.
Use the-R option must retain the current user's execute and read permissions, otherwise an error will be reported!
Thank you for reading this article carefully. I hope the article "how to use chmod commands in Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.