Linux useradd --添加用户账号
2016-04-07 16:21
375 查看
用途说明
添加用户,与useradd是同一命令。需要root权限才能执行(有root權限)。
常用参数
-d home_dir设定使用者的主目录为 home_dir
-p passwd 指定用户的登录密码。RHEL4支持此参数,RHEL5已经去掉这个参数了。
-g group 指定用户所在的群组。
使用示例
示例一
[root@localhostroot]#adduser xxx
[root@localhostroot]#ls -l /home/xxx
total 0
[root@localhostroot]#ls -ld /home/xxx
drwx------ 2 xxx xxx 4096 9月 29 16:05/home/xxx
[root@localhostroot]#grep xxx /etc/passwd /etc/shadow /etc/group
/etc/passwd:xxx:x:500:500::/home/xxx:/bin/bash
/etc/shadow:xxx:!!:14881:0:99999:7:::
/etc/group:xxx:x:500:
[root@localhostroot]#
[root@localhostroot]#ssh xxx@localhost
xxx@localhost'spassword:
Permission denied,please try again.
xxx@localhost'spassword:
Permission denied,please try again.
xxx@localhost'spassword:
Permission denied(publickey,password,keyboard-interactive).
[root@localhostroot]#
[root@localhostroot]#
[root@localhostroot]#passwd xxx
Changing passwordfor user xxx.
New password:
BAD PASSWORD: it istoo simplistic/systematic
Retype new password:
passwd: allauthentication tokens updated successfully.
[root@localhostroot]#
[root@localhostroot]#
[root@localhostroot]#ssh xxx@localhost
xxx@localhost'spassword:
[xxx@localhost xxx]$
示例二
[root@localhostroot]#adduser -d /opt/oracle oracle
[root@localhostroot]#ls -ld /opt/oracle
drwx------ 2 oracle oracle 1024 9月 29 16:10/opt/oracle
[root@localhostroot]#grep oracle /etc/passwd /etc/shadow /etc/group
/etc/passwd:oracle:x:501:501::/opt/oracle:/bin/bash
/etc/shadow:oracle:!!:14881:0:99999:7:::
/etc/group:oracle:x:501:
[root@localhostroot]#
添加用户,与useradd是同一命令。需要root权限才能执行(有root權限)。
常用参数
-d home_dir设定使用者的主目录为 home_dir
-p passwd 指定用户的登录密码。RHEL4支持此参数,RHEL5已经去掉这个参数了。
-g group 指定用户所在的群组。
使用示例
示例一
[root@localhostroot]#adduser xxx
[root@localhostroot]#ls -l /home/xxx
total 0
[root@localhostroot]#ls -ld /home/xxx
drwx------ 2 xxx xxx 4096 9月 29 16:05/home/xxx
[root@localhostroot]#grep xxx /etc/passwd /etc/shadow /etc/group
/etc/passwd:xxx:x:500:500::/home/xxx:/bin/bash
/etc/shadow:xxx:!!:14881:0:99999:7:::
/etc/group:xxx:x:500:
[root@localhostroot]#
[root@localhostroot]#ssh xxx@localhost
xxx@localhost'spassword:
Permission denied,please try again.
xxx@localhost'spassword:
Permission denied,please try again.
xxx@localhost'spassword:
Permission denied(publickey,password,keyboard-interactive).
[root@localhostroot]#
[root@localhostroot]#
[root@localhostroot]#passwd xxx
Changing passwordfor user xxx.
New password:
BAD PASSWORD: it istoo simplistic/systematic
Retype new password:
passwd: allauthentication tokens updated successfully.
[root@localhostroot]#
[root@localhostroot]#
[root@localhostroot]#ssh xxx@localhost
xxx@localhost'spassword:
[xxx@localhost xxx]$
示例二
[root@localhostroot]#adduser -d /opt/oracle oracle
[root@localhostroot]#ls -ld /opt/oracle
drwx------ 2 oracle oracle 1024 9月 29 16:10/opt/oracle
[root@localhostroot]#grep oracle /etc/passwd /etc/shadow /etc/group
/etc/passwd:oracle:x:501:501::/opt/oracle:/bin/bash
/etc/shadow:oracle:!!:14881:0:99999:7:::
/etc/group:oracle:x:501:
[root@localhostroot]#
相关文章推荐
- linux字符驱动之poll机制按键驱动
- linux ppp上网的文章
- Linux零基础入学之1-2可用快照创建和服务器的组装
- linux 主要配置文件
- CentOS Rsync服务端与Windows cwRsync客户端实现数据同步
- Centos7下yum安装mysql
- 第四阶段 :安全与监控 Linux监控和安全运维
- Linux ac --在线时间统计
- Linux显示全部执行中的进程
- Linux服务器管理员Journald初级指南
- linux下配置JDK JAVA环境
- Linux下线程的调度策略与优先级
- Linux 下I/O多路复用总结
- 查看linux系统版本命令
- Linux学习之CentOS--虚拟机下的CentOS如何上网
- 如何在Linux上安装服务器管理软件Cockpit
- linux dmesg命令
- Linux 冒号(:) --空指令
- Linux的进程/线程间通信方式总结 04
- linux ssh基本