一、使用者新增、刪除
1.1 useradd
-b, --base-dir base_dir base directory for the home directory of the
new account
-c, --comment comment gecos field of the new account
-d, --home-dir home_dir home directory of the new account
-d, --defaults print or change default useradd configuration
-e, --expiredate expire_date expiration date of the new account
-f, --inactive inactive password inactivity period of the new account-g, --gid group name or id of the primary group of the new
account-g, --groups groups list of supplementary groups of the new
account
-h, --help display this help message and exit
-k, --skel skel_dir use this alternative skeleton directory
-k, --key key=value override /etc/login.defs defaults
-l, --no-log-init do not add the user to the lastlog and
faillog databases
-m, --create-home create the user's home directory
-m, --no-create-home do not create the user's home directory
-n, --no-user-group do not create a group with the same name as
the user
-o, --non-unique allow to create users with duplicate
(non-unique) uid
-p, --password password encrypted password of the new account-r, --system create a system account-s, --shell shell login shell of the new account
-u, --uid uid user id of the new account
-u, --user-group create a group with the same name as the user
useradd 普通使用者
useradd -g mysql
會建立/home/mysql,賦予密碼後可以以該身份登陸。
useradd -r 系統賬戶
useradd -r mysql
不會建立/home/mysql,可以登陸 但是會提示 沒有/home/mysql目錄,uid小於500!一般用來管理服務,許可權較小,不用來登陸系統!
1.2、userdel
-f, --force force removal of files,
even if not owned by user
-h, --help display this help message and exit
-r, --remove remove home directory and mail spool
預設不刪除 /home/username ,加上 -r 則會全部刪除。
二、passwd
-k, --keep-tokens keep non-expired authentication tokens
-d, --delete delete the password for the named account (root only)
-l, --lock lock the named account (root only)
-u, --unlock unlock the named account (root only)
-f, --force force operation
-x, --maximum=days maximum password lifetime (root only)
-n, --minimum=days minimum password lifetime (root only)
-w, --warning=days number of days warning users receives before
password expiration (root only)
-i, --inactive=days number of days after password expiration when an
account becomes disabled (root only)
-s, --status report password status on the named account (root
only)
--stdin read new tokens from stdin (root only)
2.1 清空密碼
passwd -d username
3.1 檢視 w
-h skip header
-l long listing (default)
-s short listing
-u ignore uid of processes
-f toggle from field (default on)
-v display version
3.2 踢出
使用命令pkill -kill -t 使用者tty
四、直接操作配置檔案
4.1 /etc/passwd
4.2 /etc/group
4.3 /etc/shadow
LInux 使用者管理
最近在使用nagios的時候,需要新增一些使用者和組的資訊。需要整理一下,有些記不清楚了。原文連線 http www.g loaded.eu 2005 11 06 manage users from the command line userinfo 使用者資訊 命令id 顯示使用者基本資訊 命令u...
Linux使用者管理
0 產看使用者uid gid 等資訊 id 使用者名稱 1 linux使用者型別 1 超級使用者 root uid 0 2 偽使用者 uid 1 499之間 3 普通使用者 uid 500 60000之間 2 配置檔案 1 使用者資訊檔案 etc passwd 2 密碼檔案 etc shadow 3...
Linux 使用者管理
1 linux裡檢視所有使用者 linux裡,並沒有像windows的net user,net localgroup這些方便的命令來管理使用者.xwindows介面的就不說了.1 在終端裡.其實只需要檢視 etc passwd檔案就行了.2 看第三個引數 500以上的,就是後面建的使用者了.其它則為...