用户的配置文件位于:/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]#
- 相关文章
- linux过滤文件中的注释及空格
- linux查看内存使用情况
- linux查看硬盘使用情况
- linux查看进程
- linux查看负载
- linux循环创建及删除目录
- vim常用命令
- linux常用文件命令
- linux用户相关命令
- linux下将从将从一台服务器拷贝到
- 热门文章
- win7中将文件拷贝到虚拟机linux下
- phpexcel设置行高及列宽,背景颜色,
- rabbitmq无法启动
- intellij idea不显示git push按钮
- php7中使用mongodb的aggregate进行
- laravel页面静态化的方法
- centos7.4 64位下swoole安装及配置
- navicate连接mycat报1184错误
- curl设置超时不起作用(CURLOPT_TIM
- devops-jenkins容器为pending状态
- 好评文章
- phpexcel设置行高及列宽,背景颜色,
- php7中使用mongodb的aggregate进行
- intellij idea打开文件所在文件夹
- windows下使用MongoDB Compass Com
- win7中将文件拷贝到虚拟机linux下
- laravel 中悲观锁 & 乐观锁的使用
- 单点登录sso原理及php实现方式及de
- navicate连接mycat报1184错误
- rabbitmq无法启动
- laravel整合dingo/api方法步骤:jwt
- 我的项目
- 【github】www.github.com/hurong241
- 【码云】gitee.com/hu_rong/projects
- 【docker hub】hub.docker.com/repositories/hurong241
- 【packagist】packagist.org/users/hurong241/packages
- 站点信息
- 建站时间:2011年
- 文章数:623篇
- 浏览数:1306209