拾遗:Linux 用户及权限管理基础
Lacks of Knowledge 1:
Linux has large amount of COMMANDS,but many of them have similar funtions,it's annoying! So,how to get the highest efficiency in a very limited period?
Choise only one method which cat solve your problem[s] perfectly,and throw others away!
Just as the command "history",I will never waste my time on "!xxx","!<",etc. Because "history | grep" will solve any problems as all the others can do.
It's same for me to deal with the chapter of user-management.I will only focus on the formats of four files(/etc/passwd,/etc/shadow/,/etc/group,/etc/gshadow) and three necessary commands("useradd","newusers","chpasswd").
These seven tools are enough,as below:
f@z ~ $ cat /etc/passwd
qemu:x:77:77:added by portage for libvirt:/dev/null:/sbin/nologin
ldap:x:439:439:added by portage for openldap:/usr/lib64/openldap:/sbin/nologin
name:password:UID:GID:unnecessary comments of user:home directory:shell
z f # cat /etc/shadow
root:$6$QJnD:17015:0:99999:7:::
f:$6$5ajHHo.:17015:0:99999:7:::
name:password:date of last password change:minimun password age[days]:maximum password age[days]:password warning period[days]:password inactivity period[days]:account expiration date
Note:the third and eighth object(date of last password change,account expiration date) is expressed as the number of days since Jan 1, 1970.
z f # cat /etc/group
root:x:0:root
bin:x:1:root,bin,daemon
group name:password:GID:member[s] of the group
z f # cat /etc/gshadow
root:::root
bin:::root,bin,daemon
group name:password:administrator[s] of the group:member[s] of the group
newusers :#recive arguments from file,format same as /etc/passwd
[root@ fh]# cat testfile
zhangsan:abc:::xxxx:/home/zhangsan:/bin/bash
lisi:abc:::xxxx:/home/lisi:/bin/bash
[root@ fh]# newusers testfile
[root@ fh]# tail -n /etc/passwd
zhangsan:x:::xxxx:/home/zhangsan:/bin/bash
lisi:x:::xxxx:/home/lisi:/bin/bash
chpasswd :#recive arguments from stdin
[root@ fh]# cat testfile2
zhangsan:catdog
lisi:dogcat
[root@ fh]# cat testfile2 | chpasswd
[fh@ ~]$ su - zhangsan
Password:
-bash-4.2$
useradd -G -s -m -k
[root@ fh]# useradd -m -G wheel -s /bin/bash -k /dev/null test_user
[root@ fh]# tail -n /etc/passwd
test_user:x::::/home/test_user:/bin/bash
[root@ fh]# grep 'wheel' /etc/group
wheel:x::fh,test_user
[root@ fh]# ls -a /home/test_user/
. ..
Lacks of Knowledge 2:
setfacl -M :#revice arguments from file
[root@ fh]# cat file1
u:fh:
g:fh:
d:u:fh:rx
mask::
[root@ fh]# setfacl -M file1 a_dir/
[root@ fh]# getfacl a_dir/
# file: a_dir/
# owner: root
# group: root
user::rwx
user:fh:rw- #effective:r--
group::r-x
group:fh:r--
mask::r-x
other::r-x
default:user::rwx
default:user:fh:r-x
default:group::r-x
default:mask::r-x
default:other::r-x
最新文章
- 【转】FlashBack总结之闪回查询与闪回表
- python安装完毕后,提示找不到ssl模块的解决步骤
- 把Tomcat注册为windows服务
- Eclipse相关设置与优化
- 动画黄金搭档:CADisplayLink&;CAShapeLayer
- sql server 里类似replace的字符串子串删除
- 转: unix实际用户ID和有效用户ID解析
- 用例设计工具PICT — 输入组合覆盖
- 关于alpha透明度
- 在winform中添加普通右键菜单
- [原]在Fedora 20环境下安装系统内核源代码
- C#制作一个消息拦截器(intercept)1
- PHP 切割字符串 点号 不用双斜杠
- Map的遍历方法及String和其它类型的相互转化
- [iOS]C语言知识点系列视频
- Flex移动应用程序开发的技巧和窍门(一)
- 全文搜索 Contains 与like 的区别
- 【转】fread函数详解
- Loj #2331. 「清华集训 2017」某位歌姬的故事
- Numpy的基本概念