In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
In linux, there is still a lot of content about the permissions of files, which is intended to be introduced systematically and comprehensively today.
File permissions and attributes
First, let's take a look at the concept of the owner, the group to which it belongs, and others.
In linux, each user belongs to a group and is not allowed to be outside the group alone.
Owner, when a user creates a new file, the default owner of the file is the user
The group to which the user belongs, when the user creates a new file, the group of the file is the group in which the user belongs
Other people, the users who do not enter the owner and the group to which they belong are other people.
File attribute
Let's use ls to look at the properties of the file.
# ls-l 1.php Apr Apr 15 10:30 1.php | 12345678910 11 12 13 14 15 16 parameter meaning 1 indicates file type,-indicates file. D is represented as a directory. B is represented as a block device. 2234 is divided into a group to indicate owner permissions. At present, the owner permissions are divided into rw5567 groups to indicate the group permissions to which they belong. At present, the group permissions to which they belong are R88, 9 and 10, which are divided into a group to indicate the permissions of others. At present, other permissions are R11 to indicate the number of links to this file 12 to indicate that the owner of this file is root13, which means that the group to which the file belongs is root14 to indicate the file size, and the unit is 15 bytes to indicate the last modification time of the file.
Modify file properties
Three commands will be introduced below
Chmod changes permissions for a file or directory
Chown changes the file owner
Chgrp changes the group to which the file belongs
First create a new directory and file
# mkdir study_file # echo 'learn to create files using chmod, chown and chgrp' > study_file/1.txt #
Change the owner of the file
# chown www study_file/1.txt # change the file owner # ll study_file/1.txt-rw-r--r-- 1 www root 34 May 5 12:22 study_file/1.txt
Change the group and owner at the same time
# chown www:www study_file/1.txt # change the file owner and group at the same time # ll study_file/1.txt-rw-r--r-- 1 www www 34 May 5 12:22 study_file/1.txt
Recursively modify the owner and group to which it belongs
# touch study_file/2.txt# touch study_file/3.txt# chown-R www:www study_file/ # Recursive modification # ll study_file/ Total usage 4 Mustang www www-1 www www 34 May 5 12:22 1.txt Mustang rkashi-1 www www 0 May 5 13:13 2.txtMuhashi r Mustang-1 www www 5 May 5 13:13 3.txt
Use chgrp to change the group
# ls-d study_file/-ldrwxr-xr-x 2 www www 4096 May 5 13:13 study_file/# chgrp root study_file/# ls-d study_file/-ldrwxr-xr-x 2 www root 4096 May 5 13:13 study_file/
Use chmod to change file permissions, either numerically or alphabetically. Generally speaking, we are used to setting permissions digitally.
# chown-R root:root study_file/# chmod 700study_file/# Digital method set permissions # ll-d study_file/drwx- 2 root root 4096 May 5 13:13 study_file/# chmod upright rwx Grunr Total amount of txt# ll 4 root root-1 root root 34 May 5 12:22 1.txt 1.txt# chmod-1 root root 0 May 5 13:13 2.txt 1.txt# chmod r-1 root root 0 May 5 13:13 3.txt
The meaning of directory and file permissions
Rwx has different meanings for directories and files. Below I have made a table that describes the meaning of different types of permissions for.
Meaning of file type permissions filercat, less, more, filewvim and other filex execution permissions
Dirxcd such as dirrlsdirwtouch, rm, cp, mv, etc.
File default permissions
When we create a new file, the general permission of the new file is rw-r--r--,. If you create a new directory, the permission of the directory is rwx-r-xr-x. This is the default permission for the file, and the way to view the default permission is to use umask.
# umask-Su=rwx,g=rx,o=rx
The default permission minus x is the default permission for the file.
The way to modify the default permissions is also very simple, or use the umask command
Umask 0770
The above is a comprehensive introduction to the details of file permissions and attributes under linux, please pay attention to other related articles!
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.