This is the 12th day of my participation in the August Challenge

The Linux operating system is a multi-user operating system that allows multiple users to log in to the system and use resources simultaneously. The system will distinguish each user’s files, tasks and working environment according to the account, so that each user can work without interference.

The user category

  • Super user: root user whose UID is 0
  • False user: the UID ranges from 1 to 499
    • The pseudo user cannot log in to the system and does not have a host directory
    • For example, system and service related: bin, Daemon, shutdown, etc., process related: Mail, news, games, etc
  • Common user: the UID ranges from 500 to 60000
  • To switch from a common user to the root user: $su -> Enter the password to switch to the root user
  • To switch to a common user, run the following command: $su < username > To switch to a specified user without entering a password

The configuration file

/etc/passwd: saves user information

  • usecat /etc/passwdView files, contentsformatTo:

  • Root – User name: indicates the user name for logging in to the system
  • X – Password: indicates the password bit
  • 0-uid: indicates the user ID
  • 0 -gid: indicates the id of the default group
  • Root – Description: Stores the user description
  • /root – Host directory: the default directory for logging in to the system. The default directory is /home/
  • /bin/bash – Command parser: the Shell used by the user. The default is bash

/etc/shadow: File to save the password

  • Using the commandcat /etc/shadowView, the content format is shown in the figure, and the meanings are shown in sequence:
  • User name: User name for logging in to the system
  • Password: encryption password
  • Last change: specifies the number of days since the password is last changed
  • Minimum Interval: Specifies the minimum interval between two password changes
  • Maximum interval: ~
  • Warning time
  • Account Limit time
  • The failure time
  • mark

/etc/group: Saves the file of the user group

  • Each user belongs to at least one group. Each group can contain multiple users; Users in the same group have group permissions.
  • Group name:
  • Group password: the password bit is not used
  • GID: indicates the group ID
  • Intra-group user list: The list of users that belong to the reshuffled group

/etc/gshadow: Saves the user group password

/etc/default/useradd: User profile

Operation command

The user operation

  • useradd :Add user
    • -u: specifies the uid, which specifies the user ID
    • -g: gid specifies the ID of the group to which it belongs
    • -g: Groups, specify multiple Groups, use commas, spacing
    • -c: comment indicates user description
    • -e: expire date, expire time
    • For example, the command to create user du:useradd -u 888 -g users -G sys,root -c "hr du" du passwd du
  • usermod: user modify,Modify the user
    • -l: Changes the user name. For example, the command to change the name of user A to user B is as follows:usermod -l a b
    • -g: adds the sys group for user Tom.usermod -g sys tom
    • -g: Add multiple groups, separated by commas
    • -l: Lock locks the account password
    • -u: Unlock, Unlock the account password
  • userdel: user delete,Delete user
    • -r: remove: deletes an account and deletes the directory related to the account

The operations group

  • Groups: displays the user group
  • Groupadd: Adds a group
    • -g: Specifies the group GID
  • Groupmod: Changes the group
    • -n: new group: changes the group name
  • Groupdel: deletes a group

Permission Operation Command

Three basic permissions

  1. R (read) Read permission;
  2. W (write) Write permission;
  3. X (execute) Execution permission;

File Permission Information

  • Bit 1: indicates the file type, D – directory, – common file, I- linked file
  • Bit 2-4: Indicates the permission of the owning user, which is represented by U (user)
  • Bit 5-7: indicates the permission of the owning group. The value is g (group)
  • Bit 8-10: Other user rights, denoted by O (other)
  • All permissions are identified by a (all) with 2 to 10 digits
  • -rwxrw-r--: indicates a common file. Owning users have read, write, and execute permissions. Group users have read and write permissions, and other groups have only read permissions

Change file permissions

  • Chmod: change mode to modify file permissions
    • -r: Receusive: indicates that files and subdirectories under this interface have the same permission
    • Such as:chmod u+x a.txt: Adds execution permission to the owner of the a.txt file
  • Use numbers to indicate permissions: r=4, w=2, x=1, -=0
    • Such as:chmod 750 b.txt: indicates file B. tuck. Owning users have read, write, and execute permissions, owning groups have read, execute, and execute permissions, but others have no permissions