首页 / LINUX / 8.1 linux基础,创建用户
8.1 linux基础,创建用户
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了8.1 linux基础,创建用户,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3052字,纯文字阅读大概需要5分钟。
内容图文
![8.1 linux基础,创建用户](/upload/InfoBanner/zyjiaocheng/1333/586b55316ccd413e8ad6146dbe2df4ec.jpg)
1. 创建testuser uid 1234,主组:bin,辅助组:root,ftp,shell:/bin/csh home:/testdir/testuse
-c, --comment COMMENT 添加用户全名或注释
-u, --uid UID 指定uid
-g, --gid GROUP 指定主组
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]] 指定附加组
-d, --home-dir HOME_DIR 指定家目录
-s, --shell SHELL 指定默认shell
主要是熟悉useradd的常用选项, -d指定目录的时候,要先确定其父目录存在
现有一testuser用户,进行修改
[root@localhost ~]# usermod -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser testuser
查询结果:
[root@localhost ~]# id testuser
2. 修改testuser uid:4321,主组:root,辅助组:nobody,loginname:test,home:/home/test 家数据迁移
-u, --uid UID 指定uid
-g, --gid GROUP 指定主组
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]] 指定辅助组
-l, --login NEW_LOGIN 指定新的登陆名
-d, --home HOME_DIR 指定家目录
-m, --move-home 移动家目录,一般要与-d使用
主要是熟悉usermod的常用选项
[root@localhost ~]# usermod -u 4321 -g root -G nobody -l test -md /home/test testuser
查询结果:
[root@localhost ~]# id testuser
无此用户
[root@localhost ~]# id test
3. 批量创建帐号:user1...user10
uid:3000-3009,shell:/bin/csh,home:/testdir/username
passwd:usernamepass
注意家目录相关配置,使用户正常登录
主要掌握newusers和chpasswd两个命令, 还要确认系统是存在/bin/csh
newusers命令批量创建用户,注意文件与/etc/passwd相同,我们可以查看newusers的man手册:
首先创建一个user.txt文件
[root@localhost ~]# vi user.txt
在文件内编辑要创建的用户:
[root@localhost ~]# vi user.txt
[root@localhost ~]# cat user.txt
user1:user1pass:3000:3000::/testdir/username1:/bin/csh
user2:user2pass:3001:3001::/testdir/username2:/bin/csh
user3:user3pass:3002:3002::/testdir/username3:/bin/csh
user4:user4pass:3003:3003::/testdir/username4:/bin/csh
user5:user5pass:3004:3004::/testdir/username5:/bin/csh
user6:user6pass:3005:3005::/testdir/username6:/bin/csh
user7:user7pass:3006:3006::/testdir/username7:/bin/csh
user8:user8pass:3007:3007::/testdir/username8:/bin/csh
user9:user9pass:3008:3008::/testdir/username9:/bin/csh
user10:user10pass:3009:3009::/testdir/username10:/bin/cs h
使用newusers命令批量创建用户:
user5:user5pass:3004:3004::/testdir/username5:/bin/csh
user6:user6pass:3005:3005::/testdir/username6:/bin/csh
user7:user7pass:3006:3006::/testdir/username7:/bin/csh
user8:user8pass:3007:3007::/testdir/username8:/bin/csh
user9:user9pass:3008:3008::/testdir/username9:/bin/csh
user10:user10pass:3009:3009::/testdir/username10:/bin/csh
[root@localhost ~]# newusers user.txt
[root@localhost ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
查看/etc/passwd下的用户信息
[root@localhost ~]# cat /etc/passwd
user1:x:3000:3000::/testdir/username1:/bin/csh
user2:x:3001:3001::/testdir/username2:/bin/csh
user3:x:3002:3002::/testdir/username3:/bin/csh
user4:x:3003:3003::/testdir/username4:/bin/csh
user5:x:3004:3004::/testdir/username5:/bin/csh
user6:x:3005:3005::/testdir/username6:/bin/csh
user7:x:3006:3006::/testdir/username7:/bin/csh
user8:x:3007:3007::/testdir/username8:/bin/csh
user9:x:3008:3008::/testdir/username9:/bin/csh
user10:x:3009:3009::/testdir/username10:/bin/csh
切换账号,用新建账户登录:
Last login: Tue Aug 2 22:58:51 2016
/usr/bin/xauth: file /testdir/username1/.Xauthority does not exist
[user1@localhost ~]$ su user2
密码:
[user2@localhost username1]$
原文:http://11897500.blog.51cto.com/11887500/1833752
内容总结
以上是互联网集市为您收集整理的8.1 linux基础,创建用户全部内容,希望文章能够帮你解决8.1 linux基础,创建用户所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。