Linux User management commands are checked every time, and they can't be remembered. I 'd like to take a note here.
Both useradd and adduser can add users. The difference is: 1. adduser will prompt you to set the password, but useradd will not. 2. adduser will create a user directory, for example,/home/freebird is a user, and useradd will not 3. adduser creates a user group. By default, the user name is the same as www.2cto.com. adduser will ask the full name, room number, phone number and other user information, useradd will not be the following example created with adduser: [plain] root @ ubuntu1204-dell :~ # Adduser gerrit2 Adding user 'gerrit2 '... adding new group 'gerrit2' (1002 )... adding new user 'gerrit2' (1002) with group 'gerrit2 '... creating home directory '/home/gerrit2 '... copying files from '/etc/skel '... enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for gerrit2 Enter the new value, or press ENTER for the default Full Name []: gerrit2 Room Number []: 101 Work Phone []: 186525810 ** Home Phone []: 186525810 ** Other []: www.2cto.com Is the information correct? [Y/n]. Therefore, adduser is more convenient and preferred. View User cat/etc/passwd to view all user information, for example, the created gerrit2 user [plain] gerrit2: x: 1002: 1002: gerrit2, 101,186525810 **, 186525810 **:/home/gerrit2:/bin/bash basic format: User name: Password: User ID: Group ID: Comment Description: main directory: logon Shell, intermediate use: note: 1. the password uses x to indicate that the real password is stored in the/etc/shadow file. This is the gerrit2 password in the shadow file: [plain] gerrit2: $6 $ v7uh0ctV $ example. hbcW. ouk2A05CyChx7zZlRV3wZMuH0hE0: 15480: 0: 99999: 7: Already encrypted, so it is safer. 2. Delete the user [plain] userdel-r gerrit in the/etc/group line gerrit2: x: 1002: www.2cto.com corresponding to the group ID. This command deletes both the gerrit user and the user directory. The change owner chown indicates that the change owner is chown username: groupname filepath or chown-R username: groupname folderpath author sheismylife.