Linux users, group accounts, and permissions (Learn note nine)

Source: Internet
Author: User
Tags add numbers crypt

First, the user classification
    • Super User: Root
    • Normal User: Created by Superuser and administrator, generally only have full permissions in their own directory
    • Program Users:
Second, user account management

Common commands:

Useradd: Adding users

Userdel: Deleting users

passwd: Set User password

Groupadd: Add group account

Groupdel: Delete group account

GPASSWD: Add/Remove Group members

2.1.useradd: Add user

Tar] # useradd  20150222  test1       tarpasswd for   Short  passwdtar]# useradd test2
2.2.Userdel: Delete User

Tar] # Userdel Test2-tarls -l/home/4drwx44096  - :tar
2.3. PAPASSWD: Set User password

[[Email protected]Tar]#passwd-S test1test1 PS -- Geneva- + 0 99999 7-1(Password set, SHA512 crypt.) [[Email protected]Tar]#passwd-l test1locking Password foruser test1.passwd: Success[[email protected]Tar]#passwd-S test1test1 LK -- Geneva- + 0 99999 7-1(Password locked.) [[Email protected]Tar]#passwd-u test1unlocking Password foruser test1.passwd: Success[[email protected]Tar]#passwd-S test1test1 PS -- Geneva- + 0 99999 7-1(Password set, SHA512 crypt.) [[Email protected]Tar]#passwd-d test1removing Password foruser test1.passwd: Success[[email protected]Tar]#
2.4. Groupadd: Add group account

[[Email protected] ~
2.5, Groupdel: Delete group account 2.6. GPASSWD: Add/Remove Group members

[Email protected] ~~]# gpasswd-~]# gpasswd-~
2.7 User Group modifications
-N  new_group_name old_ group_name
2.8. View the current user group
Groups
2.9. Modify user Information

To modify the user Information command:
[[email protected] opt] #usermod parameter user name
Parameters:
-C Description
-G Group name Initial user group
-E Expiration date format: YYYY-MM-DD
-G group name other user groups
-L Modify User name
-L Lock Account (two exclamation mark in front of user's password password string in/etc/shadow file) )
-U unlock

Third, the Authority
[Email protected] documents]#ls-Altotal thedrwxr-xr-x.7Root root4096Feb -  on: the. Dr-xr-x---. -Root root4096Feb -  -:xx ..-rw-r--r--.1Root root AboutFeb +  at: theA.TXTDRWXR-xr-x.4Root root4096Feb - xx: +com-rw-r--r--.1Root root148Feb -  on: atC.Tar. GZ-rw-r--r--.1Root root theFeb -  on: theC.txt-rw-r--r--.1Root root -Feb -   -file1.txt.gz-rw-r--r--.1Root root34419Feb - xx: -HTTPD.CONFDRWXR-xr-x.3Root root4096Feb -  on: the Tar-rw-r--r--.1Root root inFeb -   -TESTDRWXR-xr-x.4Root root4096Feb +  A: -TEST1DRWXR-xr-x.2Root root4096Feb +  A: +test4-rw-r--r--.1Root root theFeb -  on: +Test4.Tar. GZDRWXR-xr-x.4Root root4096Feb -   -Tests[[email protected] documents]#

The columns of the list are defined as follows:
[Permission Property Information] [Number of connections] [owner] [owner-owned user group] Size [Last Modified time] FileName

The permission attribute list is 10 characters:
The first character indicates the file type, D is the directory-for normal file L for connection b for the storage interface device C for keyboard and mouse input device
2, 3, 4 characters represent owner permissions, 5, 6, 7 characters represent owner-group user Rights, 8, 9, 10 for other user rights

The second character represents the owner Read permission, or R if there is permission, or-
The third character represents the owner write permission, or W if there is permission, or-
The fourth character represents the owner execution permission, or X if there is a permission, or-
The fifth character indicates that the owner is in the same group as the user Read permission, if the permission is R, no permission is-
The sixth character indicates that the owner is the same as the group user write permission, if the permission is W, no permission is-
The seventh character indicates that the owner performs the permissions with the group user, and if the permission is x, no permission is-
The eighth character represents other non-identical read permissions, and if there is a permission R, no permission is-
The nineth character represents the other non-identical write permissions, if the permission is W, no permission is-
The tenth character represents the other non-identical group execution permissions, if the permission is x and no permission is-

Iv. Representation of permissions

Digital form and character form

R, W, X can be represented by octal 4,2,1, which, when represented by a combination, need to add numbers.

Five, permission setting chmod 5.1. chmod [Ugoa ...] [+-=] [rwx] File or directory

Ugoa: For the user class, u represents the owner of the file, G represents the user in the user group where all the files are located, o any other user, a represents all users (u,g,o sum)

+-=: Set the action of the permission, + means to increase the appropriate permissions, minus the corresponding permissions, = means to set the appropriate permissions only

RWX: The character combination of permissions, which can be used either individually or in combination such as: R,W,X,RW,RX,WX,

5.2, chmod nnn file or directory

5.3 chmod-r Options

Add-r option to set subdirectories under directory, files to the same permissions

vi. setting file Attribution

Chown: Can be set to owner, belong to group

Chgrp: Modify the genus group only

So chown often use

6.1, Chown

Chown owner [: [Genus]] file or directory

Set-up at the same time: delimited

If a group is set individually, group: genus

Linux users, group accounts, and permissions (Learn note nine)

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.