linux (RHEL) 添加和刪除用戶


linux添加新用戶使用 useradd -----create a new user or update default new user information 

刪除用戶使用userdel  -----delete a user account and related files

useadd options:

-c, --comment COMMENT set the GECOS field for the new user account

-d, --home-dir HOME_DIR home directory for the new user account 

-p, --password PASSWORD use encrypted password for the new user
account

 -g, --gid GROUP               force use GROUP for the new user account
-s, --shell SHELL the login shell for the new user account
-u, --uid UID force use the UID for the new user account
 

常用的 :  -d 設置新用戶的home

              -p 設置新用戶密碼

             -g 設置group

              -s 設置login 的shell 類型

              -u 設置UID

              -c 新用戶描述信息

1. useradd rhel -d /home/rhel -p zxcv5678

添加新用戶 rhel  默認home /home/rhel

發現使用該用戶登錄不上,使用passwd 修改密碼,報錯

Authentication token manipulation error

google之后發現,可以使用 root權限 passwd -d rhel 清空用戶密碼

之后su rhel 重新設置

2.使用-g 指定的gid 應該大於500

可以從/etc/group 看到對應的的gid

刪除用戶:

Usage: userdel [options] LOGIN

Options:
-f, --force force removal of files, even if not owned by user

-r, --remove remove home directory and mail spool

  -f 強制刪除

  -r刪除home和mail 

 

userdel -r rhel

 

           

       

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM