Skip to content
On this page

adduser指令


标签:linux/cmd  

在 Linux 上添加用户

bash
sudo adduser ubuntu

可以通过su指令切换到用户

新添加的用户没有 sudo 权限: `

bash
usr1@0f6670548ed3:/$ sudo addusr usr2
[sudo] password for usr1:
usr1 is not in the sudoers file.  This incident will be reported.

修改 /etc/sudoers

bash
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
usr1 ALL=(ALL) ALL    # 添加这行

删除用户使用 userdel 指令:

bash
userdel -r username # -r 代表删除用户目录等文件

这个命令也可以删除用户,但是不能删除家目录

bash
sudo deluser

Last updated: