Simple operations and file permissions for linux users and user groups

Source: Internet
Author: User
Simple operations on linux users and user groups, and file permissions can be created only with root permissions. new linux users adduserab can be created with the name AB. new users do not have a password, note that users without passwords cannot log on. Passwdad sets a password for User AB. On the terminal, you can... simple operations on linux users and user groups, and file permissions can be created only with root permissions. new linux users adduser AB can be created with the name AB. new users do not have a password, note that users without passwords cannot log on. Passwd ad sets a password for User AB. On the terminal, you can see: Changing password for user AB. new UNIX password: bad password: it is based on a dictionary wordRetype new UNIX password: passwd: all authentication tokens updated successfully. id AB on the terminal, you can see the user's basic information uid = 509 (AB) gid = 509 (AB) groups = 509 (AB) 1-500 is the system reserved uid, therefore, the new user number starts from 501. We use the same method to create another user tq and add tq to the user group 0 (root) uid tq. we can see that uid = 508 (tq) gid = 508 (tq) groups = 508 (tq), 0 (root) uid = 508 (tq) indicates that the uidgid of tq = 508 (tq) is the default group that the uid of tq belongs. Groups = 508 (tq). The uid 0 (root) tq belongs to the root user. The tq group has the root permission and can add a user to other groups. Cat/etc/group [root @ AY12081302515006590e3 tq] # cat/etc/grouproot: x: 0: root, tqbin: x: 1: root, bin, daemondaemon: x: 2: the red part of root, bin, and daemon is the newly added information. But note that only root can modify the file/etc/group. why? Ll/etc/group-rw-r -- 1 root 775 04-13/etc/group the first root represents the owner of this file, the second root indicates the group to which the file belongs-rw-r -- indicates the user's permission on the file on linux. The first character represents the file type, the d represents the directory, and the next three characters represent the permissions of the file owner, the next three characters indicate the permissions of the users in the file owner group. The last three characters indicate the permissions of other users [root @ AY12081302515006590e3 tq] # ll total 4-rw-rw-r -- 1 tq 0 04-13 1drwxrwxr-x 2 tq 4096 04-13 20:05 2-rw-rw-r -- 1 tq 0 04-13 text note that here "total 4" indicates the total of the Directory and the files below the number of blocks used. This is a file under tq. su AB switches to user AB and finds that the ls command has insufficient permissions. lsls :.: The permission is insufficient because ls needs to access the/home/tq directory, and we find that drwx ------ 4 tq 4096 04-13 20:12 tq indicates that the permissions of other users are empty, no permission. It can be seen that if you do not have permissions on a directory, you do not have the corresponding permissions on the files under it, even if the following files are configured with permissions. In addition, the root permission is greater than everything else. ========================================================== ================================== You can use chmod to change the file permission syntax format: the chmod [who] [opt] [mode] file/directory name indicates the object, which is one or both of the following letters: u: indicates the file owner g: indicates the same group of users o: other user a: indicates that all users opt indicates an operation. you can add a permission to the operation: +: cancel a permission =: Grant the given permission, and cancel the original permissions, while the mode indicates the permission: r: readable w: writable x: executable for example: to increase the read and write permissions for file a.txt for users in the same group: chmod g + rw a.txt

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.