歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux 的用戶和組命令

Linux 的用戶和組命令

日期:2017/2/28 14:49:22   编辑:Linux教程
本文僅為個人學習筆記總結及一些中英文互譯,僅作學習參考之用,希望能給初入門者以幫助。

useradd 命令

useradd - create a new user or update default new user information 創建一個新賬戶或者更新默認新賬戶的信息



-c, --comment 添加賬戶時對該賬戶的描述

-d, --home 指定賬戶的HOME_DIR 家目錄

-e, --expiredate 設置賬戶的EXPIRE_DATE 過期時間

-f, --inactive INACTIVE 創建該賬戶時,是否啟用過期機制

-g, --gid GROUP 指定組ID號

-G, --groups GROUP1[,GROUP2,...[,GROUPN]]] 建立賬戶的附加組

-m, --create-home 建立賬戶時,建立家目錄

-M Do not create the user′s home directory, even if the system wide setting from /etc/login.defs (CREATE_HOME) is set to yes. 建立用戶賬戶時,不建立家目錄



-N, --no-user-group 不指定用戶同名組

-r, --system 指定該帳號是系統帳號

-s, --shell SHELL 指定登錄shell

-u, --uid UID 指定用戶ID號

-U, --user-group 指定用戶創建用戶同名組

-o 創建用戶是可以uid重復



example

zhang:x:1234:1234:TEST USER:/home/zhang:/bin/bash 使用一段時間後希望修改為

zhang:x:2345:2345:haha:/tmp/zhang:/bin/csh



usermod 命令

usermod - modify a user account 修改用戶賬戶的配置

-a, --append 追加。。。把用戶追加到指定組

-L, --lock 鎖定賬戶

U, --unlock 解鎖賬戶

-m, --move-home with -d



刪除用戶賬戶命令

userdel - delete a user account and related files

-f, --force

-r, --remove



chage 命令

-d, --lastday LAST_DAY set date of last password change to LAST_DAY

-E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE

-h, --help display this help message and exit

-I, --inactive INACTIVE set password inactive after expiration to INACTIVE

-l, --list show account aging information

-m, --mindays MIN_DAYS set minimum number of days before password change to MIN_DAYS

-M, --maxdays MAX_DAYS set maximim number of days before password

change to MAX_DAYS

-W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS



group manager 組的管理



groupadd 添加一個新組

groupadd - create a new group



-g, --gid GID

-r, --system



groupmod 修改組的配置信息

groupmod - modify a group definition on the system



-g, --gid GID

-n, --new-name NEW_GROUP



刪除組

groupdel

groupdel - delete a group



passwd 命令

-l lock 鎖定一個賬戶

-u unlock 解鎖一個賬戶

-d delete a passwd for an account 刪除某個賬戶的密碼,允許其空密碼登錄

-S This will output a short information about the status of the password for a given account.輸出某個既有賬戶的密碼狀態的簡單信息(或者叫概述)

--stdin

echo linux |passwd --stdin vfast 1 > 0



gpasswd newgrp(臨時加入到組)

gpasswd - administer /etc/group and /etc/gshadow

-a, --add USER add USER to GROUP

-d, --delete USER remove USER from GROUP

-r, --remove-password remove the GROUP's password

-R, --restrict restrict access to GROUP to its members

-M, --members USER,... set the list of members of GROUP

-A, --administrators ADMIN,...set the list of administrators for GROUP



/etc/passwd User account information,文件中存儲了用戶賬戶信息,其文件格式為:



[用戶名]:[密碼]:[UID]:[GID]:[身份描述]:[主目錄]:[登錄shell]



/etc/shadow Secure user account information.該文件中存放的是安全賬戶信息



用戶名:這是用戶登錄系統時使用的用戶名,它在系統中是惟一的

口令:此字段存放加密的口令

最後一次修改的時間:標識從某一時刻起到用戶最後一次修改口令的天數

最小時間間隔:兩次修改口令之間的最小天數

最大時間間隔:口令保持有效的最多天數,即多少天後必須修改口令

警告時間:從系統開始警告到口令正式失效的天數

不活動時間:口令過期多少天後,該賬號被禁用

失效時間:指示口令失效的絕對天數(從1970年1月1日開始計算)

標志:未使用



/etc/group Group account information. 組賬戶信息



文件格式為:

[組名]:[密碼域]:[GID]:[組員列表]



/etc/gshadow Secure group account information. 組安全帳號信息



/etc/default/useradd Default values for account creation. 創建賬戶的默認值



/etc/skel/ Directory containing default files. 新建用戶默認模版文件夾



/etc/login.defs Shadow password suite configuration. 新建用戶默認值設置文件
Copyright © Linux教程網 All Rights Reserved