加载中…
个人资料
汉斯的遗忘
汉斯的遗忘
  • 博客等级:
  • 博客积分:0
  • 博客访问:3,458
  • 关注人气:160
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

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
   Add a normal user

adduser --system [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID]
[--gecos GECOS] [--group | --ingroup GROUP | --gid ID] [--disabled-password]
[--disabled-login] USER
   Add a system 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即可。

0

阅读 收藏 喜欢 打印举报/Report
前一篇:佛待病比丘
后一篇:难陀被迫出家
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有