In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The purpose of this article is to share with you the content of an example of file permissions knowledge points in Linux learning. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
Any file in Linux has three permissions of "user, user group and other users", and a user can belong to multiple user groups. The information about all users is recorded in the / etc/passwd file, the password is recorded in the / etc/shaodw file, and the user group is recorded in the / etc/group file.
Root users have the highest privileges, not counting other users
File attributes ls-al-rw-r--r--@ 1 zhoust staff 58503 Dec 8 07:50 antigen.zshdrwxr-xr-x 2 zhoust staff 64 Apr 10 18:19 databasedrwxr-xr-x 6 zhoust staff 192 Apr 9 22:12 h6drwxr-xr-x 4 zhoust staff 128 Nov 20 16:15 logsdrwxr-xr-x 3 zhoust staff 96 Mar 18 17:42 node_modules-rw-r--r-- 1 zhoust staff 120 Mar 18 17 08 package-lock.jsondrwxr-xr-x 7 zhoust staff 224 Dec 8 07:20 softwaredrwxr-xr-x 9 zhoust staff 288 Nov 20 16:32 storedrwxr-xr-x 3 zhoust staff 96 Apr 4 15:43 vkdsdrwxr-xr-x 8 zhoust staff 256 Oct 23 15:06 Photo drwxr-xr-x 12 zhoust staff 384 Apr 19 08:36 Learning Video
It is divided into seven parts:
File types and permissions
File types: normal file (-), directory file (d), linked file (l)
Permissions: current user, permissions of the same user group, and other user rights. Rwx is the number of file names linked to this node (inode) with the user name of the file. The file size of the user group to which the file belongs: default is the time when Byte was created.
File name
Related tutorials: Linux Video tutorial
The significance of rwx to files and directories
For a file, w means that the contents of the file can be modified (but does not include deleting the file), and x means that the file has permission to be executed (whether it can actually be executed or not is related to the contents of the file).
The directory is mainly responsible for recording the list of file names
R: it means that the directory structure can be read w: the files (or directories) under the directory can be deleted, added, modified, moved, renamed, etc., with great permissions x: can enter the directory
If the user only has r permission to a directory, he can only view the file name and type in that directory, and can't even see the file size and various attributes. For example, zst users only have read permissions in the / home/zhoust directory and can only see the file names in that directory.
[zhoust@MyPersonalCentOS ~] $ls-altotal 36drwxr Murray XRMI-5 zhoust zhoust 4096 Apr 21 14:55. [zst@MyPersonalCentOS ~] $ls-l / home/zhoust/ls: cannot access / home/zhoust/learn: Permission deniedtotal 0d?? Minimum permission for learn to complete the task
If the user does not have x permission on a directory, he cannot execute any commands in that directory or query the contents of the files in that directory.
Action / dir1/dir1/file1/dir2 explain reading file1 content xr- must be able to enter / dir1 to read the file data inside! Modify file1 content xrw- can enter and delete file1 files wx-- can enter / dir1 has the permission to modify the directory! Copy file1 to / dir2xrwx to be able to read file1 and modify data in / dir2 to modify file attributes and permissions
Three commands, chown, chgrp and chmod, respectively, indicate the user to which the file belongs, the user group to which the file belongs, and the permissions to modify the file.
Chmod syntax is divided into two types, one is to modify with numbers, and the other is to use symbols to modify file permissions.
Use numeric modification, which is 421 to add the numbers in the corresponding position, for example:
# under the / home/zhoust directory, no other user is allowed to enter [zhoust@MyPersonalCentOS ~] $ls-aldrwxrwxr-x 2 zhoust zhoust 4096 Apr 21 14:55 learn [zst@MyPersonalCentOS ~] $cd / home/zhoust/bash: cd: / home/zhoust/: Permission denied# using chmod to modify it to be accessible to other users, and zst can enter this directory [zhoust@MyPersonalCentOS ~] $chmod 705. [zhoust@MyPersonalCentOS ~] $ls-aldrwx---r-x 5 zhoust zhoust 4096 Apr 21 14:55.
Use symbol type to modify file permissions in the format of [scope] [modify] [permission], u user, g user group, o other users, an all users, the symbols used for modification are +-=, permissions are still those three rwx. Now turn off the other user rights in the / home/zhoust directory:
[zhoust@MyPersonalCentOS] $chmod o-rx. [zhoust@MyPersonalCentOS ~] $ls-altotal 36drwx-5 zhoust zhoust 4096 Apr 21 14:55. Thank you for reading! On Linux learning file permissions knowledge point example is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
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.