Study notes: UOS server user management

Add user test

useradd test -d /home/test -m -s /bin/bash -G sudo,users -c 备注内容

set password

passwd test

The above command creates the default group and user home directory at the same time, and adds the sudo and users groups.
Because the sudo group in the /etc/sudoers file is set to be able to perform all sudo operations, if you want to have sudo permissions, you can add the user to the sudo group.
The following is the content of the /etc/sudoers file

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

View the group the user belongs to

groups test

Delete users, their home directories and default groups

useradd test -r

reference

Linux user and user group management

Guess you like

Origin blog.csdn.net/sinat_37014456/article/details/118053060