AIX-chmod command

Source: Internet
Author: User
Tags bit set

The AIX-chmod command chmod is used to change the access permissions of files or directories. You can use it to control access to files or directories. This command can be used in two ways. One is the text setting method that contains letters and operator expressions, and the other is the number setting method that contains numbers. 1. set the text in French: the options in the chmod [who] [+ |-| =] [mode] file name command are as follows: 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 ". 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" to set the user ID of the file, and "g + s" to set the group ID. T save the program text to the swap 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 read permission on the file example. 2. to set the number, we must first understand the meaning of the attributes represented by numbers: 0 indicates no permission, 1 indicates executable permission, 2 indicates writable permission, and 4 indicates readable permission, and then add them. Therefore, the format of the numeric attribute should be three Octal numbers from 0 to 7. The order is (u) (g) (o ). For example, if you want the owner of a file to have the "read/write" permission, you need to set 4 (readable) + 2 (writable) to 6 (read/write ). The general format of the number setting method is: Syntax: chmod [mode] file name [B] command instance: [/B] chmod a + x sort %, which sets the attributes of the file sort: the file owner (u) adds the execution permission. The file owner and the same group of users (g) Add the execution permission. Other users (o) Add the execution permission. chmod ug + w, o-x text % sets the file text attribute to: file owner (u) To add write permission and file owner to the same group of users (g) to add write permission to other users (o) delete the execution permission chmod u + s. out % assume that. the out permission is (you can use ls-l. out command):-rws -- x 1 inin users 7192 Nov 4. and the execution file needs to use a text file shiyan1.c. Its file access permission is "-rw -------", that is, the file has read and write permissions only for its owner. When other users execute. when the program is out, his identity is changed to inin (because the s option is used in the chmod command) for the moment ), therefore, he can read the shiyan1.c file (although this file is set to be inaccessible to others), which is the function of s. Therefore, in the entire system, especially the root itself, it is best not to set too many files of this type (unless necessary) to ensure system security, avoid system intrusion due to bugs in some programs. Chmod a-x mm.txt chmod ugo-x mm.txt % to delete the execution permission of the mm.txt file with these three commands, the object set by the command is all users. $ Chmod 644 mm.txt % specifies that the attributes of the file mm.txt are:-rw-r -- file owner (u) inin. The read and write permissions are set to the same as those of the file owner (g) others (o) have read permission. chmod 750 wch.txt % sets the property of the wchtxt file to-rwxr-x --- file owner (u) inin readable/writeable/executable right is the same as the file owner group (g) readable/executable right others (o) do not have any permission to add additional content: sticky bit The most common use of the sticky bit today is on directories, where, when set, items inside the directory can only be renamed or deleted by the item's owner, the directory's owner, or the superuser. generally this is set on the/tmp directory to prevent ordinary users from deleting or moving other users 'files. examplesThe sticky bit can only be set by superuser root. using the chmod command, it can be set using its octal mode 1000 or by its symbol t (s is already used by the setuid bit ). for example, to add the bit on the directory/usr/local/tmp, one wocould type chmod + t/usr/local/tmp. or, to make sure that directory has standard tmp permissions, one cocould also type chmod 1777/usr/local/tmp. in Unix symbolic file system permission notation, the sticky bit is represented by the letter t in the final character-place. for instance, on Solaris 8, the/tmp directory, which by default has the sticky-bit set, shows up: $ ls-ld/tmp drwxrwxrwt 4 root sys 485 Nov 10/tmp If the sticky-bit is set on a file or directory without the execution bit set for the others category (non- user-owner and non-group-owner ), it is indicated with a capital T: # ls-l test-rw-r -- 1 root other 0 Nov 10 12:57 test # chmod + t test; ls-l test-rw-r -- r-T 1 root other 0 Nov 10 12:57 test

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.