一、创建一个用户
wang@wang:~/workpalce/threading$ sudo useradd -m python # -m创建家目录 wang@wang:~/workpalce/threading$ ls ~/.. python wang
wang@wang:~/workpalce/threading$ cat /etc/passwd python:x:1001:1001::/home/python:
wang@wang:~/workpalce/threading$ cat /etc/group python:x:1001:
二、给账户添加密码
wang@wang:~/workpalce/threading$ sudo passwd python 输入新的 UNIX 密码: 重新输入新的 UNIX 密码: passwd:已成功更新密码
wang@wang:~/workpalce/threading$ sudo cat /etc/shadow python:$6$4XBAyRRm$Xioo/N5W8JYAyvt1LmJ36LryvXU8N0iApxhyStLlN3bN.ca.Mh0DKKkiagdRXbW0OTHKKVIqbU2CbR71OTq0l.:17519:0:99999:7:::
三、创建组
wang@wang:~/workpalce/threading$ sudo groupadd proc wang@wang:~/workpalce/threading$ cat /etc/group proc:x:1002:
四、切换账户
wang@wang:~/workpalce/threading$ su python 密码: python@wang:/home/wang/workpalce/threading$
python@wang:/home/wang/workpalce/threading$ groups python
五、给账户改组
wang@wang:~/workpalce/threading$ sudo usermod -g proc python wang@wang:~/workpalce/threading$ su python 密码: python@wang:/home/wang/workpalce/threading$ groups proc
wang@wang:~/workpalce/threading$ sudo usermod -G python python # 追加 wang@wang:~/workpalce/threading$ su python 密码: python@wang:/home/wang/workpalce/threading$ groups proc python
六、使自己创建的用户拥有sudo执行命令的权限
wang@wang:~/workpalce/threading$ sudo usermod -G sudo python wang@wang:~/workpalce/threading$ su python 密码: To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. python@wang:/home/wang/workpalce/threading$ sudo cat /etc/passwd [sudo] python 的密码: root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
七、删除账户
wang@wang:~/workpalce/threading$ sudo userdel -r python userdel:组“python”没有移除,因为它不是用户 python 的主组 userdel: python 邮件池 (/var/mail/python) 未找到 wang@wang:~/workpalce/threading$ ls ~/.. wang
八、删除组
wang@wang:~/workpalce/threading$ sudo groupdel python wang@wang:~/workpalce/threading$ sudo groupdel proc