Linux Good trouble ah ~ ~ Even the editor is the command line. Really can't stand it, or use the FlashFXP band SFTP connection better. But want to use SSH still have an account. Search the Internet to find Linux to add an account basic command.
First, the Linux system user account management
User account management is mainly related to the user account to add, modify and delete.
Adding a user account is to create a new account in the system, and then assign a user number, user group, home directory, and login shell to the new account. The account you just added is locked and cannot be used.
1, add a new user account using the Useradd command, the syntax is as follows:
Useradd option User Name
The meanings of each option are as follows:
-C Comment Specifies a section of an annotation description.
The-D directory specifies the home directory, and if this directory does not exist, the-m option can be used to create the main catalog.
The-G user group specifies the user group to which the user belongs.
-G user group, where the user group specifies the additional group to which the user belongs.
-S Shell file specifies the user's login shell.
The-u user number specifies the user's user number, and if the-o option is available, the other user's identification number can be reused.
User name Specifies the login name of the new account.
# useradd–d/usr/sam-m Sam
This command creates a user sam,111cn.net
Where the-D and-m options are used to generate a home directory/usr/sam (/usr as the parent directory for the default user home directory) for the login Sam.
# useradd-s/bin/sh-g group–g adm,root Gem
This command creates a new user gem, whose login shell is/bin/sh, which belongs to the group user groups and also to the ADM and root groups, where the group groups are the primary groups.
New groups may be created here: #groupadd Group and Groupadd ADM
Adding a user account is to add a record to the new user in the/etc/passwd file, while updating other system files such as/etc/shadow,/etc/group, etc.
Linux provides an integrated system management tool, userconf, which can be used to manage user accounts uniformly.
2, delete the account
If a user's account is no longer in use, it can be removed from the system. Deleting a user account is to remove the user record from the system files such as/etc/passwd and, if necessary, delete the user's home directory. Delete an existing user account using the Userdel command, in the following format:
Userdel option User Name
The commonly used option is-r, which is to delete the user's home directory together.
# Userdel Sam
This command deletes the user Sam's record in the system file (mainly/etc/passwd,/etc/shadow,/etc/group, and so on) while deleting the user's home directory.
3, modify the account
Modify the user account is based on the actual situation to change the user's related properties, such as user number, home directory, user group, login shell and so on.
Modify the information of an existing user using the Usermod command, in the following format:
Usermod option User Name
Common options include-C,-D,-M, G, G, S,-u, and-O, and the meanings of these options are the same as those in the Useradd command, which can specify a new resource value for the user. In addition, some systems can use the following options:
-L New User name
This option specifies a new account that will change the original username to the new username.
# usermod-s/bin/ksh-d/home/z–g developer Sam
This command modifies the login shell of the user Sam to Ksh, the home directory to/home/z, and the user group to developer.
4, the User password management
One important aspect of user management is the management of user passwords. The user account was created without a password, but is locked by the system and cannot be used, and must be assigned a password before it can be used, even if a null password is specified.
The shell command that specifies and modifies a user's password is passwd. A superuser can specify a password for himself and other users, and a normal user can only use it to modify his or her password. The format of the command is:
passwd option User Name
Options you can use:
-L locks the password, that is, the account is disabled.
-u password unlock.
-D makes the account password-free.
-F forces the user to modify the password at the next logon.
If the default user name, the password for the current user is modified.
For example, if the current user is a SAM, the following command modifies the user's own password:
Re-enter New password:*******
If you are a superuser, you can specify any user's password in the following form:
# passwd Sam
Re-enter New password:*******
Ordinary users modify their own password, the passwd command will ask the original password, verify that the user input two times after the new password, if the password entered two times, the password will be assigned to the user, and the root user to specify the password, you do not need to know the original password.
For the sake of system security, users should choose a more complex password, for example, preferably with a 8-bit long password, which contains uppercase, lowercase letters, and numbers, and should be different from names, birthdays, and so on.
When you specify a blank password for the user, the following form of command is performed:
# passwd-d Sam
This command deletes the password for the user Sam so that the system will no longer ask for the password the next time the user Sam logs on.
The passwd command can also lock a user with the-l (lock) option so that it cannot log on, for example:
# passwd-l Sam
New User exception:
useradd-d/usr/hadoop-u 586-m hadoop-g Hadoop
1 Creating mailbox file: Files already exist
Delete to rm-rf/var/spool/mail/user name
2 useradd:invalid numeric argument ' Hadoop '
This is because the Hadoop group does not exist please build the Hadoop group first
You can view the pass of a user through CAT/ETC/PASSWD
Cat/etc/shadow can view user names
Cat/etc/group can view groups
Create users under Linux (ii)
second, the Linux System user Group management
Each user has a group of users that the system can centrally manage for all users in a user group. Different Linux systems provide a different set of user groups, such as users under Linux who belong to a user group with the same name, which is created at the same time as the user group.
The management of a user group involves adding, deleting, and modifying user groups. The addition, deletion, and modification of groups is actually an update to the/etc/group file.
1, add a new user group to use the Groupadd command. The format is as follows:
Groupadd Option User Group
The options you can use are:
-G GID Specifies the group identification number (GID) of the new user group.
-O is commonly used concurrently with the-G option, which means that the GID for the new user group is the same as the GID of the system already has a user group.
# Groupadd Group1
This command adds a new group group1 to the system, and the group identification number of the new group is based on the currently existing maximum group identification number plus 1.
This command adds a new group group2 to the system and specifies that the group identification number for the new group is 101.
2, if you want to delete an existing user group, use the Groupdel command, the format is as follows:
Groupdel User Group
This command deletes the group group1 from the system.
3, modify the properties of the user group using the groupmod command. The syntax is as follows:
Groupmod Option User Group
The common options are:
-G GID Specifies a new group identification number for the user group.
With the-O and-g option, the new GID for the user group can be the same as the GID for the system already has a user group.
-N New user group to change the name of the user group to a new name
# GROUPMOD-G 102 Group2
This command modifies the group identification number of the group group2 to 102.
# groupmod–g 10000-n Group3 group2
This command changes the identification number of the group group2 to 10000 and the group name to Group3.
4. If a user belongs to more than one user group at the same time, the user can switch between user groups to have other user group permissions. The user can switch to another user group after logging in using the command newgrp, and the command's parameter is the destination user group. For example:
$ NEWGRP Root
This command switches the current user to the root group, provided that the root group is indeed the user's primary or additional group. Similar to user account management, user group management can also be accomplished through integrated system management tools.
Let the average user have root privileges
2.adduser User Name
3.PASSWD User Name
4. Modify/etc/passwd to change the ID and ID Group of the username to 0.