linux用戶管理

1.刪除用戶 userdel:linux

  userdel [option] USERNAMEbash

    默認不會刪除用戶的家目錄app

    -r  同時刪除家目錄ui

 

  id:查看用戶的帳號屬性信息this

    -u  -g   -G  -nspa

     -g, --group
              print only the effective group ID

       -G, --groups
              print all group IDs

       -n, --name

2.修改用戶帳號屬性orm

 usermodblog

  -g, --gid GROUP
           The group name or number of the user?s new initial login group. The group must exist.
     -u, --uid UID
           The new numerical value of the user´s ID.token

   -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] 附加組
           If the user is currently a member of a group which is not listed, the user will be removed from the group.
           This behaviour can be changed via the -a option, which appends the user to the current supplementary group
           list.(-a 不刪除以前的附加組)接口

   -c, --comment COMMENT
           The new value of the user´s password file comment field. It is normally modified using the chfn(1) utility.

       -d, --home HOME_DIR(爲用戶指定新的家目錄,原來的家目錄就沒法訪問了)
           The user´s new login directory.

           If the -m option is given, the contents of the current home directory will be moved to the new home
           directory, which is created if it does not already exist. If the current home directory does not exist the
           new home directory will not be created(移動此前的文件至新的家目錄中去和-m一塊兒使用)

    -l, --login NEW_LOGIN
           The name of the user will be changed from LOGIN to NEW_LOGIN. Nothing else is changed. In particular, the
           user´s home directory or mail spool should probably be renamed manually to reflect the new login name.

   -L, --lock
           Lock a user´s password.
  
       -U, --unlock
           Unlock a user´s password. This removes the ´!´ in front of the encrypted password. You can´t use this option
           with -p or -L.

cnfn:修改註釋信息

3.密碼管理:

  passwd [USERNAME]

  若是使用腳本自動怎麼改呢(linux重要哲學思想之一:避免捕獲用戶接口)

  --stdin  echo "redhat" | passwd --stdin

[root@good eric ~]# echo "root1"|passwd --stdin test
Changing password for user test.
passwd: all authentication tokens updated successfully.
[root@good eric ~]# 

 

     -l   鎖定密碼

    -u   解鎖

            -n

    -w

     -i

     -d 刪除用戶密碼
PAM:

 pwck:檢查用戶帳號完整性

4.組管理

    建立組:groupadd

          -g  指定gid

          -r  添加一個系統組(id1-499)
    修改組:groupmod

 

          -g 修改組名

          -n groupname

    給組設定密碼:gpasswd

      更改用戶的基本組newgrp  GROUPNAME<--->exit




相關文章
相關標籤/搜索