> useradd USERNAME -- to create a new user named by USERNAME, it will be grouped to g(USERNAME)
> userchmod -g existedGroup USERNAME -- to change the USERNAME's group.
> userchmod -a -G wheel USERNAME -- add the user USERNAME to an existed group: wheel to make the user: USERNAME have sudo permission.
> cat /etc/sudoer
## Allows people in group wheel to run all commands, the users in the group wheel have the sudo permission.
%wheel ALL=(ALL) ALL
## Same thing without a password, '#' used to disable the such function.
# %wheel ALL=(ALL) NOPASSWD: ALL
Add an Existing User to a Group
The usermod command can be used to modify the group affiliation of an existing user. To add an existing user to a group, use usermod -a -G [group] [user name]. For example, "usermod -a -G wheel joeblow" adds the user "joeblow" to the "wheel" group, allowing joeblow to become a superuser using the "su" command.
Add a New User to an Existing Group
If the user you wish to add to a group does not already exist, you can create the user and add it to a group in one step using the "useradd" command. The -G flag adds a user to a group, much like with usermod. So, "useradd -G wheel joeblow" creates a new user named joeblow and adds that user to the "wheel" group.
Create a New Group
If the group does not already exist, it will have to be created first. The "groupadd" command creates new groups; its argument is the name of the new group. Newly created groups are empty, so any users will have to be added to it afterward.
chown
> chown -R usergrid:wheel *
> ls -l
perm x usergrid wheel size date file
3. Given the user login base home dir.
puser:x:505:500::/home/root/users/:/bin/bash
-d, --home HOME_DIR
The new user will be created using HOME_DIR as the value for the
user’s login directory. The default is to append the LOGIN name to
BASE_DIR and use that as the login directory name. The directory
HOME_DIR does not have to exist but will not be created if it is
missing.
当用户puser登录后,直接跳到了/home/root/users 目录下。