In Linux, to modify the file and folder permissions, first take a look at the file attributes. in the shell environment, enter ls-l to view the current directory file. Such as: drwxr-xr-x2nsfusers102412-1017: 37 download file backup are corresponding to: file property connections file has...
In Linux, to modify the file and folder permissions, first take a look at the file attributes. in the shell environment, enter ls-l to view the current directory file. For example, drwxr-xr-x 2 nsf users 1024 12-10 download file backup corresponding: file attribute connections file owner group file size file modification time file name here r is readable, w writable, x executable, where File attributes are divided into four sections, ---- --- 10 locations for example: the first character of d rwx r-x specifies the file type. In general, a directory is also a file. If the first character is a horizontal line, it indicates a non-directory file. If it is d, it indicates a directory. The second part is the attributes of the file owner, and the third part of www.2cto.com is the attributes of the file group to which the file belongs. The fourth part is the attributes of other users, such as the access permission for the "download file backup" folder above, the "download file backup" folder is a directory file. The owner of the "download file backup" folder has the read and write permissions; users in the same group as the folder "download file backup" have only the read and executable permissions. other users also have the read and executable permissions.
After determining the access permission for a file, you can use the chmod command provided by Linux to reset different access permissions. You can also use the chown command to change the owner of a file or directory. Use the chgrp command to change the user group of a file or directory. Chmod command function: the chmod command is very important for changing the access permissions of files or directories. you can use it to control the access permissions of files or directories. Syntax: this command has two usage methods. One is the text setting method that contains letters and operator expressions, and the other is the number setting method that contains numbers. 1. text setting method chmod [who] [+ |-| =] [mode] file name? Parameter: the operation object who is one of the following letters or their combination: u indicates "user", that is, the owner of a file or directory. G indicates "group users", that is, all users with the same group ID as the file owner. O indicates "other (others) users ". Www.2cto.com a indicates "all (all) users ". It is the default value of the system. The operation symbol can be: + add a permission. -Cancel a permission. = Grant the given permission and cancel all other permissions (if any ). Set the permissions expressed by mode to any combination of the following letters: r readable. W writable. X executable. X adds the x attribute only when the target file is executable to some users or the target file is a directory. S sets the owner or group ID of the process to the file owner during File execution. In the format of "u + s", set the user ID bit of the file, and "g + s" to set the group ID bit. Www.2cto.com t saves the program text to the Switch device. U has the same permissions as the file owner. G. users in the same group have the same permissions as file owners. O has the same permissions as other users. File name: List of files separated by spaces to change permissions. wildcards are supported. Multiple permission methods can be provided in a command line, separated by commas. For example, chmod g + r, o + r example enables the same group and other users to have the read permission on the file example. The chgrp command function is used to change the group to which a file or directory belongs. Syntax: chgrp [option] group filename? This command changes the user group to which the specified file belongs. The group can be either the user group ID or the group name of the user group in the/etc/group file. A file name is a list of files separated by spaces to change the group. wildcards are supported. If the user is not the owner or super user of the file, the file group cannot be changed. Parameter:-R recursively modifies the group of all subdirectories and files under a specified directory. Example 1: $ chgrp-R book/opt/local/book changes the group of all files in/opt/local/book/and its subdirectories to book. Chown command www.2cto.com function: change the owner and group of a file or directory. This command is also very common. For example, if the root user copies a file to xu, the root user should set the owner of the file to xu to allow xu to access the file. otherwise, user xu cannot access this file. Syntax: chown [option] user or group File description: chown changes the owner of the specified file to the specified user or group. Users can be user names or user IDs. A group can be a group name or group ID. Files are separated by spaces to change the permission list. wildcards are supported.
Parameter:-R recursively modifies the owner of all subdirectories and files under a specified directory. -V: displays the work done by the chown command. Example 1: Change the owner of the shiyan. c file to wang. $ Chown wang shiyan. c Example 2: Change the owner of the directory/his and all files and subdirectories to wang and change the group to users. $ Chown-R wang. users/his
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.