Linux useradd --添加用户账号

用途说明

添加用户,与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]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值