Linux Users and user groups

Source: Internet
Author: User
Tags stdin

User Category
Super User: Uid range 0 Root User: uid=0 (root) gid=0 (root) groups=0 (root) Normal User: Created by Administrator, UID Range (500-65535)--   EG:OMC User: uid=502 ( OMC) gid=502 (OMC) groups=502 (OMC) intended users: to meet the needs of the file or program to create, system optimization can delete the UID range (1-499) end of file/noligin
Files that record user passwords

/ETC/PASSWD # Log User's information

/ETC/PASSWD User name  password   uid     gid    User Description home directory  Shell interpreter OMC:  x  :  502  :  502  :           :  /HOME/OMC  :  /bin/bash

/etc/shadow # Log User password information

User name     password       last changed the   number of days to prevent password changes   to the user must change the number of days of password   alarm changing password term inactivity      time     flag            OMC  [ Email protected] :   17394:       0          :             99999   :         7       :         ::

/etc/group # Record Group information

User name   password    Group IDOMC  :   x  :  502:

About user-controlled commands
Chage: View/Modify password information, such as password chage-l OMC-E: Change account expiration chage-e "Space" OMC ==> set permanent chage-e "2017/08/11" OMC==>USERADD-E "2017 /08/11 "Omc==>usermod-e" 2017/08/11 "omcchage-m7-m60-w10-i30 OMC-->m (min) m (max) W (warning)-I (inactive) ==> Passwd-n 7-x 60-i 30-w FTL--N (min)-X (max)-W (warning)-I (inactive) chmod: Change the chmod 755-r of property values/system default critical 77 7-022/777-002chmod 644/system default critical 666-022/666-002usermod: change user Information--most of the parameters root Useadd consistent, master Useradd can usermod-e "2017/06 /08 "OMC only modifies the current OMC user useradd: Add user-and also directly edit the file to add the default file in:/etc/default/useradd--> at the same time controlled by:/ETC/LOGIN.D Efs--> modified files in:/etc/passwd Shadow Group Gshadowuseradd omc-p passwd-g: Adding user groups to user names or numbers as the starting group for user Login-G: Add multiple user groups to the user, with commas, Partition-S: Specify login shell-u: Specify UID-C:COMMENT-E: Specify expiration Time-R Create SYSTEM account-D: Change home directory, no system will create-m: User directory does not exist will automatically create-m: Do not set up user home directory, more for virtual users nologin-d : useradd-d View Default system default Add new user parameter-D-?   : Change the parameters in the system default file (/etc/default/useradd)-d-e: Default plus D after changing the profile (Useradd file) in the account termination time YYYY-MM-DD useradd-d-E "2017/06/08" OMC  -->-d By default Modify the Usermod-e "2017/06/08" in the file at the same time, only modify the current OMC user useradd-e "2017/06/08" OMC only modify the current OMC user-M: does not mean Home Directory--More for virtual users
         # Add a user who is a user of MySQL, and the user cannot log in to useradd-g MySQL mysql-s/sbin/nologin  (if you do not specify a group, the default is to add a uid-like GID)         # Add User ID 502 and group uses is OMC user
         # Add an FTL user with a user ID of 666 group root and home directory/FTL useradd-c "Handsomeboy"-u 666-g root,omc-s/bin/sh-d/ftl ftlgrep "\ftl\b"/etc/pass WD   --Filter only rows containing Oldboy
Userdel: Delete User and user information--also can directly edit the file, generally we in the work directly commented out this user can-R delete the user's home directory--do not easily use this parameter, will delete the user's home directory files at the same time             1. Make sure to do a backup before deleting a file, and control your return key unless you are sure that it is no problem 2. It's better to comment out the file than delete 3. Delete user, can # also can use/bin/nologin     4.pawd-l OMC-Lock account 5.chage-e "20170812" omc-f Delete the user login directory and all files in the directory.            Userdel-r omcchgrp: Changing the change group-r for a group: Recursive change Permissions Users/home/omc/h.txt-Change the group of H.txt to users  ==> chgrp Root h.txt-point. Before representing the default property Groupadd: Add user group Groupadd sa add user group named SA--here's the default add Groupadd-g 666 My Add a group named my and GID 666 groupadd users-g 502 Add user Group 502 Usergroupdel: Delete user group Groupdel Sachown: change user already user group                    Command-r: Recursive change permissions chown OMC h.txt chown omc.users h.txtpasswd: superuser: passwd OMC-Modify OMC User's password passwd---Default change root user password Normal User: Log in to OMC user, enter passwd default modify OMC user's password--stdin:echo   [EMAIL&NBSP;PROTECTED]|PASSWD--stdin OMC-->stdin accepts the echo input character as the OMC password ==>passwd OMC <[email protected] ==&GT;PASSWD--stdin FTL <6.txt-->6.txt is a file that uses the standard input passwd-n 7-x 60-i 30-w FTL-- > N (min)-X (max)-W (warning)-I (inactive) view user password information; chage-l FTL
ID: View the user's Uid,gidid omcuid=500 (OMC) gid=500id (OMC) groups=500 (OMC) id-unw:show who logged on and what the he is doing ********      W > Who > users****************** 17:43:13 up 10:55, 2 users, Load average:0.00, 0.00, 0.00USER TTY From [email protected] IDLE jcpu PCPU whatroot pts/0 192.168.25.100 06aug17 0.00s 1 .95s 0.08s wroot pts/1 192.168.25.100 15:30 2:13m 0.01s 0.01s-bashwho: Can view login information, than W simple # who root pts/ 0 2017-08-01 20:54 (192.168.25.100) Users: Display only the current terminal with what user login, than who also simple whoami: View the current object last: Display a detailed list of logins and the current status of the corresponding directory: last ==>l Ast/var/log/wtmp root pts/1 192.168.25.100 Sat 14:45-15:30 (00:44) root pts/0 192.               168.25.100 Sun 6 08:25 still logged in Lastlog: View user's login lastlog log file ==>/var/log/lasglog Oldboy **never logged in** h **never logged in**su: Role switching su and Su-the difference: Su-: Will switch the root user, will also switch the user variable to root environment variable Su: Only the root user will be switched, butThe current environment variable is also the previous user's environment variable does not switch the user directly executes the command: to OMC the user to execute the command: su-root-c "ifconfig" needs to enter the password and so on the same time creates the file OMC the user's 
Files used by users and groups
/etc/skel/: The directory where the new user profile is stored, when we add a new user, all the files in this directory (including the implied files) are automatically copied to the newly added user's home directory, and the default is hidden files. By modifying, adding, deleting files under the/etc/skel directory, we can provide a unified, standard, initialized user environment for newly created users/etc/login.defs: Describes system User Configuration files, home directory permissions 700 (file configuration umask is 077)  Message directory and other information   from the file can see the maximum value of Uid,gid is the 500-60000   file by default delete users when the user group   password encryption method Md5/etc/default/useradd: The default file file for the Useradd command is set by default when adding a user some actions can be edited with useradd-d  useradd-d-E 2015/06/09 passwd Summary: 1. We can change the password of the account via the passwd and chage settings via the/etc/login.defs profile or/etc/default/ Useradd Global modification for all accounts 2. The limitation of setting up user account has advantages and disadvantages. Advantages: The system administrators can be regularly forced to make password changes, improve the security of the system. Cons: Some users will not be able to log on because they are out of date 3. In a large-scale operation environment, we can use LDAP service to unify the authentication and batch management of Linux accounts.
Log of the user log on (all available with ID-lastlog)

All: ll    /var/log/secure*                        lastlog ==>/var/log/wtmp         

User Management Summary

Useradd-u-g-g-s-m-e-c-D                /etc/skel,/etc/default/useradd,/etc/login.defs            Userdel-r (not recommended, use other methods, comments, Nologin ,-L, etc.)             usermod-u-g-g-s-m-e-c-d-l             -u ID            chage-l-e-m-m-w passwd             --stdin-n-i-x-W (suid location) 
   su            Sudo-l-K             

Group Management Summary

User query commands
W    idwho last    usersfinger      lastlog

Linux Users and user groups

Related Article

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.