標籤:增加和刪除使用者
useradd 建立使用者
-u 數字 指定uid
-g 數字 指定gid
-d 指定家目錄
-s 指定shell
-M 不建立家目錄
-G 指定向外延展群組
說明:一個使用者可以有自己的組,也可以有其他的組。
#舉例
[[email protected] ~]# useradd wyy2
[[email protected] ~]# tail -3 /etc/passwd
tcpdump:x:72:72::/:/sbin/nologin
wyy:x:500:500::/home/wyy:/bin/bash
wyy2:x:501:503::/home/wyy2:/bin/bash
#指定uid、gid
[[email protected] ~]# useradd -u 505 -g 502 user1
[[email protected] ~]# tail -2 /etc/passwd
wyy2:x:501:503::/home/wyy2:/bin/bash
user1:x:505:502::/home/user1:/bin/bash
#查看
[[email protected] ~]# id user1
uid=505(user1) gid=502(grp1) 組=502(grp1)
#指定向外延展群組
[[email protected] ~]# useradd -u 506 -g 501 -G 502 user2
[[email protected] ~]# id user2
uid=506(user2) gid=501(users1) 組=501(users1),502(grp1)
userdel 刪除使用者
-r 刪除家目錄
#舉例(不加-r不能刪除家目錄)
[[email protected] ~]# userdel user1
[[email protected] ~]# ls -ld /home/user1
drwx------ 3 505 grp1 4096 9月 21 21:00 /home/user1
如果刪除不了,就手動刪除它的家目錄
rm -rf /home/user1
也要把這個刪除掉
rm -rf /var/spool/mail/user1
本文出自 “linux” 部落格,轉載請與作者聯絡!
增加和刪除使用者