User Management for Linux Study Notes

Source: Internet
Author: User

Linux Study Notes user management www.2cto.com 1. User Management Configuration File user data file:/etc/passwd [root @ CentOS-Test software] # grep test/etc/passwd test: x: 500: 500: test:/home/test:/bin/bash user account information: test: User Name, user name used for Logon x: Password 500: UID, user ID 500: default group ID test: annotation description, such as storing the user's full name and other information/home/test: Your home directory/bin/bash: shell used by the user, the default is bash linux User Account classification: divided into three: Super User (root, UID = 0) has all the operation permissions ordinary user (UID500-65536) operation permissions are restricted. pseudo users (default users): (UID 1-499). Note: User UID Except 0, users are not allowed to take the same value for other values. pseudo users are related to system and program services, such as bin, daemon, shutdown, and halt, by default, these pseudo users are available in any Linux system. If the pseudo user does not have a logon password or a home directory, each user belongs to at least one user group. Each user group can include multiple users, users of the same user group have the permissions of this group. The user password file www.2cto.com:/etc/shadow stores important information such as the user password. Only root users can read and write user group files: /etc/group user group password file:/etc/gshadow user configuration file:/etc/login. defs/etc/default/useradd new user information file:/etc/skel logon information:/etc/motd 2. User Account maintenance command to create a user (to the specified group) and set the password: [root @ CentOS-Test ~] # Useradd-g operator user3 // create a user3 user and add it to the operator group [root @ CentOS-Test ~] # Passwd user3 // set user3 password to change user3 password. New Password: re-enter the new password passwd: All authentication tokens have been successfully updated. Display the default value of the useradd command: When we use the useradd command to add a user, if no parameter is specified, the default value of useradd will be used. The default value is in/etc/default/useradd, you can edit this file to modify the default parameters of the useradd command. The useradd-D usermod command is used to set the logon attribute of an existing account, including the user's home directory, private group, logon shell, etc. Change the user Account name: user-l newname oldname // This command is to modify the user's login name, however, the Home Directory is not updated. You also need to modify the new home directory [root @ CentOS-Test ~] # Usermod-l user5 user1 modify the Home Directory [root @ CentOS-Test ~] # Usermod-d/home/user5 user5 modify user group information [root @ CentOS-Test home] # usermod-g operator ciscoserver lock user account and contact lock [root @ CentOS- test ~] # Usermod-L user8 is locked by the password [root @ CentOS-Test ~] # Passwd-l user8 is locked by the password [root @ CentOS-Test ~] # Usermod-U user8 is used to unlock the password [root @ CentOS-Test ~] # Passwd-u user8 unlock the password to delete the user account [root @ CentOS-Test ~] # Userdel user3 delete user user3 but its home directory is not deleted/home/user3 still exists [root @ CentOS-Test ~] # Userdel-r user3 Delete the user3 user and then delete the user password in the home directory [root @ CentOS-Test default] # passwd-d yangweiwei Delete only the password used, use passwd username to reset the password to clear the user's yangweiwei. Passwd: The operation is successful. Set the user's finger information [root @ CentOS-Test default] # chfn fangguo Changing finger information for fangguo. name []: Zhang Search Office []: sales Office Phone []: 025689 Home Phone []: 15455155 3. Create a group by using the group account maintenance command: groupadd group name is used to add group accounts to the system. The GID of the group account is greater than 500 [root @ CentOS-Test home] # groupadd ZBS Delete group: groupdel group name is used to delete the group, before deleting a group, you must first Delete the users in the group, that is, you cannot delete a group containing users [root @ CentOS-Test ~] # Rename the groupdel operator group: groupmod-n newgroupname oldgroupname, after modification, the user is also affiliated to the new group name [root @ CentOS-Test default] # groupmod-n yizhidui ZHBA to add the user to the group: gpasswd-a user account name group account name this user account name must first exist [root @ CentOS-Test default] # useradd sunzhaohui [root @ CentOS-Test default] # gpasswd-a sunzhaohui yizhidui Adding user sunzhaohui to group yizhidui. Of course, the above two commands can be directly run with the useradd command to complete useradd-g yizhidui sunzhaohui. The premise is that the group account must exist, and create The user only belongs to yizhidui. Instead, the user created by using useradd sunzhaohui also belongs to his own private group and deletes the user from the group: gpasswd-d user account name group account name set the user as the Group Administrator: [root @ CentOS-Test default] # gpasswd-A sunzhaohui yizhidui 4. The maintenance command displays the available shell [root @ CentOS-Test default] # chsh- l/bin/sh/bin/bash/sbin/nologin/bin/tcsh/bin/csh set the shell for user logon [root @ CentOS-Test default] # chsh-s/bin /bash root 5. user and group status command id: displays the uid, gid, and group list of the current user. [root @ CentOS-Test Default] # id uid = 0 (root) gid = 0 (root) group = 0 (root) environment = unconfined_u: unconfined_r: unconfined_t: s0-s0: c0.c1023 displays the name of the current user [root @ CentOS-Test default] # whoami root converts the current user to another user su username [root @ CentOS-Test default] # su sunzhaohui if it is converted root User: the su-root command is used to display the group information of a specified user: groups user name [root @ CentOS-Test ~] # Groups sunzhaohui: yizhidui uses the RedHat User Manager to manage users: system-config-users

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.