linux删除添加用户,linux的添加/删除用户命令

用户的配置文件位于:/etc/passwd中

可以用cat命令查看,vi命令可查看也可以修改,建议用cat,以防出问题

passwd中的内容,类似如下:

[root@localhost etc]# cat passwd

root:x:0:0:root:/root:/bin/bash

hurong:x:500:500:centos6:/home/hurong:/bin/bash

以上面这行为例:

hurong 代表用户名

x代表用户密码(加密过的,不能直接看到)

第一个500代表用户id

第二个500代表的是用户所在组id

centos6代表的注释

/home/hurong代表用户主目录

/bin/bash 代表该用户所使用的shell解析器

linux的添加/删除用户命令

添加用户:需要有root权限的帐户才可以操作,添加的用户存放在/home/添加的用户名目录下

语法:useradd 用户名 (也可以用useradd -g 组名 用户名,给添加的用户指定组)

设置密码,语法:passwd 用户名

输入密码

再输一次

删除用户

语法:userdel -r 用户名

不加-r表示只删除用户

加-r表示同时删除/home/用户名 的目录

linux添加用户及为用户设置密码例子:

[root@localhost home]# pwd

/home

[root@localhost home]# ls -l

total 8

drwx------. 26 hurong hurong 4096 May 27 06:23 hurong

drwx------.  4 test   test   4096 May 27 06:25 test

[root@localhost home]# adduser test1

[root@localhost home]# ls -l

total 12

drwx------. 26 hurong hurong 4096 May 27 06:23 hurong

drwx------.  4 test   test   4096 May 27 06:25 test

drwx------.  4 test1  test1  4096 May 27 06:27 test1

[root@localhost home]# passwd test1

New password:

Retype new password:

passwd: all authentication tokens updated successfully.

[root@localhost home]#

linux删除用户例子:

[root@localhost home]# pwd

/home

[root@localhost home]# ls -l

total 12

drwx------. 26 hurong hurong 4096 May 27 06:23 hurong

drwx------.  4 test   test   4096 May 27 06:25 test

drwx------.  4 test1  test1  4096 May 27 06:27 test1

[root@localhost home]# userdel test1

[root@localhost home]# ls -l

total 12

drwx------. 26 hurong hurong 4096 May 27 06:23 hurong

drwx------.  4 test   test   4096 May 27 06:25 test

drwx------.  4    502    502 4096 May 27 06:27 test1

[root@localhost home]# userdel -r test1

userdel: user 'test1' does not exist

[root@localhost home]# userdel -r test

[root@localhost home]# ls -l

total 8

drwx------. 26 hurong hurong 4096 May 27 06:23 hurong

drwx------.  4    502    502 4096 May 27 06:27 test1

[root@localhost home]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值