增加和刪除使用者

來源:互聯網
上載者:User

標籤:增加和刪除使用者

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” 部落格,轉載請與作者聯絡!

增加和刪除使用者

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.