1.6 Common UNIX / Linux command - user and rights management class command

User rights management class command


1. User rights management classes and commands:

  • User Management command:
    useradd usermod passwd userdel su id whoami w finger
  • User Group Management command:groupadd groupmod groupdel
  • File permissions management class command:chmod chown chgrp

2. User:

  • Linux users are divided into three categories
    • Supervisor : Has the highest authority
    • Users of the system : services related to system, but can not be used to log in
    • Ordinary users : Created by super users and assigning privileges, can only operate their own files and directories permissions, can only manage their own process started

3. User Information:

  • Username : unique, letters, numbers and symbols.
  • Password
  • User ID (UID): a unique identification number of each user has. Super User is 0, the system user 1-499, ordinary users from 500 begins
  • User Group ID (GID)
  • The user's home directory
  • Full name : Additional information about the user account can be empty
  • Login Shell : default Bash

4. associated with the user's files

  • User account information file / etc / password
    • Each file in a user's behavior information
    • File in each field from left to right: user name, password, user ID, user group, full name, home directory and login Shell.
    • X filled with the password field, the encrypted password is stored in / etc / shadow
      file.
  • User password information file / etc / shadow
    • shadow file only super users can view and modify its contents, and storage encryption

5. User Group:

  • Linux users the same characteristics classified as the same user group, it can greatly simplify user management, easy to share files between users, any user belongs to at least one user group.
  • A user can belong to one user group, but may belong to a plurality of additional groups simultaneously. Users not only have permission to its user group, also have both rights attach group.
  • User group includes system user group and private user groups

6. The user group associated with the file

  • User Group account information file / etc / group
    • Each act a user group information
    • File in each field from left to right: User group name, password, user ID, and additional user group list.
  • User group password information file / etc / gshadow
    • 同/etc/shadow

7. User Management command:

  • useradd

    • Function: Create a new user account (super user available)
    • Format: useradd [parameter] <user name>
      • -d (directory) specified when the user's home directory sign
      • -e (end) account termination date
      • -g (group) belongs to the user group account
      • Additional group -G designated account belongs
      • shell after -s (shell) is used to specify the account login
      • -u (userid) specify a user ID number
    • Example: new user zhangsan, user group net04
      useradd -g net04 zhangsan
  • passwd

    • Function: Set or modify a user password and a password attribute
    • Format: passwd [parameter] <user>
      • -d (delete) delete the user's password
      • -l (lock) temporarily locked specified user account
      • -u (unlock) to lift the specified user account locked
      • -s (show) the display state of the specified user account
    • For example:
      • Set and modify the properties:
        passwd zhangsan
      • Delete password:
        passwd -d zhangsan
      • Lock / Unlock user account:
        passwd -l zhangsan
        passwd -u zhangsan
      • Display user account status:
        passwd -s= zhangsan
  • usermod

    • Function: modify the user's attributes (super user available)
    • Format: usermod [parameter] <user name>
      • -d specifies the home directory when the user logs in
      • -e account termination date
      • -G specified user group account belongs
      • Additional group -G designated account belongs
      • -s shell after the designated account used to log
      • -u specify a user ID number
      • -l new user name (used to modify the user name)
    • Example: The modified bit zhangs zhangsan
      usermod - l zhangs zhangsan
  • userdel

    • Function: delete the specified user account (super user available)
    • Format: userdel [parameter] <user name>
      • -r: not only delete the user account, and delete local user's home directory and message store directory or file
      • -f: delete user login directory and all files in a directory
    • If you delete a user belongs to a private group, and this group is no other user groups are also deleted.
    • Is using the system users can not delete
  • his

    • Function: Switching user identity
    • Format: su <user name>
      • Super user can switch to any ordinary user, without the need to enter a password; password is required to be converted user ordinary users into other users
      • Use exit to return to the original user identity;
  • id

    • Function: View user's UID, GID and user information belongs to the user group, if you do not specify a user,
      information about the current user is displayed.
    • Format: id <user name>
  • whoami

    • Function: View the current user name
  • w

    • Function: View the current system and user login details

8. The user group management commands:

  • groupadd
    • Features: new group (super user available)
    • Format: groupadd [parameter] <User group name>
      • -g: group ID specifies the user
      • -o: Allow group ID is not unique
  • groupmod
    • Function: modify the properties of the specified user group (super user available)
    • Format: groupmod [parameter] <User group name>
      • -g: Specifies the new user group ID
      • -n: Specifies the name of the new user group
      • -o: Allow group ID is not unique
  • groupdel
    • Function: delete the specified user group (super user available)
    • Format: groupdel <User Group Name>
    • Note: Before deleting a specified user group must ensure that the user group is not in any user's primary group, or delete this user group for the first main group of users can delete the user group

9. File Permissions:

  • Read permission : Browse the file / directory content rights;
  • Write permissions :
    • For the file is modified contents of the file permissions
    • For directory is deleted, added and rename files within the directory permissions;
  • Execute permissions :
    • For executable files are allowed to execute permissions
    • For permission to access the directory is the directory.

10. Based on the user's file permissions management:

  • Files user classification

    • Owner of the file : the establishment of user files and directories;
    • Owner's user group file : the file owner belongs to another user in the user group;
    • Other users : neither the owner of the file, but not all of the user's group for all other set of files.
    • Supervisor : Responsible for the management and maintenance of the entire system, with full access to all files in the system
  • Letter notation :


11. Modify the file permissions chmod command

  • Function : to modify the file's access permissions
  • Format : chmod <mode> <file>
    • mode:
      • Object: u file owner, g the same group of users, o other users
      • Operators: + increases, - delete, imparting =
      • Permissions: r read, w write, x execution, s user ID provided
  • For example :
    • Cancel the same group of users write access to the file documents
      chmod g-w file
    • The access to the directory to 775 pict
      chmod 775 pict
    • Setting set user ID bit file documents
      chmod u+s file

12. chown command to modify the file owner

  • Function : The owner of the specified file is changed to the specified user or group of users
  • Format : chown [options] <owner / group> <file> ...
    • -c display information change part
    • -f ignore the error message
    • -h repair a symbolic link
    • -R processing specified directory and all files in subdirectories
    • -v display detailed processing information
    • -deference act on symbolic links pointing to, not the link file itself
    • User is the user name or user ID, user group may be a group name or group ID
    • File is a list of files to change permissions separated by spaces, wildcard support
  • For example : The owner of ex1 changed from root hellen
    • chown hellen ex1

13. The modified file belongs to user group command chgrp

  • Function : change the file's user group
  • Format : chgrp [options] <group> <file>
    • -c output debugging information when changes
    • -f Do not display an error message
    • -R processing specified directory and all files in subdirectories
    • -V displays detailed process information Runtime
    • --dereference act on symbolic links point to, rather than the symbolic link itself
    • --no-dereference acting on the symbolic link itself
    • User group name or group may be a group ID
  • Example : The user group ex1 file belongs to the root staff
    • chgrp staff ex1

Guess you like

Origin www.cnblogs.com/DengSchoo/p/12640674.html