5、用户管理命令

1、useradd
添加用户
语法:useradd [选项] 用户名
Options:
-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
-Z, –selinux-user SEUSER use a specific SEUSER for the SELinux user mapping

2、passwd
修改密码命令
语法:passwd [选项] [用户名]
-k, –keep-tokens 保持身份验证令牌不过期
-d, –delete 删除已命名帐号的密码(只有根用户才能进行此操作)
-l, –lock lock the password for the named account (root only)
-u, –unlock unlock the password for the named account (root only)
-e, –expire expire the password for the named account (root only)
-f, –force 强制执行操作
-x, –maximum=DAYS 密码的最长有效时限(只有根用户才能进行此操作)
-n, –minimum=DAYS 密码的最短有效时限(只有根用户才能进行此操作)
-w, –warning=DAYS 在密码过期前多少天开始提醒用户(只有根用户才能进行此操作)
-i, –inactive=DAYS 当密码过期后经过多少天该帐号会被禁用(只有根用户才能进行此操作)
-S, –status 报告已命名帐号的密码状态(只有根用户才能进行此操作)
–stdin 从标准输入读取令牌(只有根用户才能进行此操作)

3、userdel(user delete)
删除用户
-r 删除账号时同时删除宿主目录(remove)

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页