FREEBSD用户帐户管理
FREEBSD用户帐户管理
第一个就是添加用户命令了:
adduser
常用命令选项如下:
adduser -h
usage: adduser [options]
options may include:
-C save to the configuration file only 保存配置文件
-D do not attempt to create the home directory 不创建用户目录
-E disable this account after creation 创建用户后关闭用户登陆
-G additional groups to add accounts to 把用户加到某个组
-L login class of the user
-N do not read configuration file 不读取控制文件
-S a nonexistent shell is not an error
-d home directory 指定用户目录
-f file from which input will be received
-g default login group
-h display this usage message
-k path to skeleton home directory
-m user welcome message file
-q absolute minimal user feedback
-s shell 指定SHELL
-u uid to start at 指定用户ID
-w password type: no, none, yes or random
常用命令选项:
adduser -v试着看下会是什么效果
例子:
adduser test
Username: test
Full name: test
Uid (Leave empty for default):
Login group [test]:
Login group is test. Invite test into other groups? []: no
Group no does not exist!
Login group is test. Invite test into other groups? []:
Login class [default]:
Shell (sh csh tcsh bash nologin) [sh]:
Home directory [/home/test]:
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]: no
Use a random password? (yes/no) [no]: no
Enter password:
Enter password again:
Lock out the account after creation? [no]: no
Username : test
Password : *****
Full Name : test
Uid : 1001
Class :
Groups : test
Home : /home/test
Shell : /bin/sh
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (test) to the user database.
Add another user? (yes/no): no
Goodbye!
第二个用户就是rmuser
rmuser从系统中完全删除一个用户。rmuser执行下面的步骤:
1. 删除用户的crontab记录。
2. 删除属于用户的at工作。
3. 杀掉属于用户的所有线程。
4. 删除本地口令文件中的用户。
5. 删除用户的主目录。
6. 删除来自/var/mail的属于用户的邮件。
7. 删除所有诸如/tmp的临时文件存储区中的文件。
8. 最后,删除在/etc/group中所有属于组的用户名。
比如rmuser test,就会依次执行以上步骤\
注意:如果一个组变成空,而组名和用户名一样,组将被删除。rmuser不能用来删除超级用户的帐户
第3个命令改变用户密码passwd
passwd test
或者用chpass但是感觉比较麻烦
第4个命令就是创建用户组
pw groupadd 组名
可以通过pw groupshow 查看刚创建的组信息
如何添用户到组
pw groupadd test -M 用户 把某用户添加到TEST组
