adduser命令:在linux系统中新增用户账户
(2011-02-09 17:15:28)
标签:
杂谈 |
分类: linux命令 |
adduser命令:在linux系统中新增用户账户
语法:
adduser [--home DIR] [--shell SHELL] [--no-create-home] [--uid
ID]
[--firstuid ID] [--lastuid ID] [--gecos GECOS] [--ingroup
GROUP | --gid ID]
[--disabled-password] [--disabled-login] [--encrypt-home]
USER
adduser --system [--home DIR] [--shell SHELL]
[--no-create-home] [--uid ID]
[--gecos GECOS] [--group | --ingroup GROUP | --gid ID]
[--disabled-password]
[--disabled-login] USER
如:添加cdy用户
linux@cdyemail:~$ adduser cdy
adduser: Only root may add a user or group to the
system.
linux@cdyemail:~$ sudo adduser cdy #要用root用户权限添加
Adding user `cdy' ...
Adding new group `cdy' (1001) ...
Adding new user `cdy' (1001) with group `cdy' ...
Creating home directory `/home/cdy' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: #输入用户密码
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for cdy
Enter the new value, or press ENTER for the default
#输入用户信息
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
linux@cdyemail:~$ cat /etc/passwd | grep cdy #查看是否创建了用户
cdy:x:1001:1001:,,,:/home/cdy:/bin/bash
linux@cdyemail:~$ cat /etc/group | grep cdy #查看是否默认创建了组
cdy:x:1001:
切换到控制台:登录
cdyemail login:cdy
Password:
查看登录的用户
nux@cdyemail:~$ who
cdy
tty2
2011-02-09 16:56
#测试登录成功
linux tty1
2011-02-09 16:54
linux tty7
2011-02-09 15:47 (:0)
linux pts/0
2011-02-09 17:08 (:0.0)
linux pts/1
2011-02-09 17:09 (:0.0)
我用的是ubuntu,测试时和书上的不一样,书中介绍adduser,
useradd是一个文件,即adduser只是一个链接.
linux@cdyemail:/bin$ which adduser useradd
/usr/sbin/adduser
/usr/sbin/useradd
linux@cdyemail:/bin$ ls -l /usr/sbin/adduser
/usr/sbin/useradd
-rwxr-xr-x 1 root root 35106 2010-01-27 18:26
/usr/sbin/adduser
-rwxr-xr-x 1 root root 76876 2010-09-03 18:28
/usr/sbin/useradd
这里并没有显示是连接,所以用时现查帮助 adduser --help即可。