您的位置:首页 > 运维架构 > Linux

03_04_Linux

2016-11-09 21:50 239 查看
用户、组、权限

安全上下文(secure context)

权限
文件:

r:可读,可以使用类似cat等命令查看文件内容

w:可写

x:可执行 executable可以命令提示符下当作命令提交给内核运行

目录:

r:可以对目录执行ls等指令

w:可以在此目录创建文件

x:可以使用cd切换此目录,也可以使用ls -l查看文件详细信息

用户
用户:UID /etc/passwd

组:GID /etc/group

影子口令:

用户:/etc/shadow

组:/etc/gshadow

用户类别:

管理员:0

普通用户(系统用户、一般用户):1-65535

系统用户:1-499

一般用户:500-60000

用户组类别:

管理员组:

普通组:

系统组:

一般组:

[root@bogon /]# cat etc/passwd
root:x:0:0:root:/root:/bin/bash
<pre name="code" class="html">[root@bogon /]# man 5 passwd



account   the name of the user on the system.  It should not contain cap-ital letters.
password  the  encrypted  user  password,  an asterisk (*), or the letter 'x'.  (See pwconv(8) for an explanation of 'x'.)
UID       the numerical user ID.
GID       the numerical primary group ID for this user.
GECOS     This field is optional and only  used  for  informational  pur-
root:用户名

X:占位密码(存在etc/shadow)

[root@bogon /]# cat etc/shadow
root:$1$iINxcG9C$JGPtCwNQxlgBXhlbd/qaC1:17108:0:99999:7:::
<span style="font-family: Arial, Helvetica, sans-serif;">[root@bogon /]# man 5 passwd</span>


以双冒号隔开分别是

用户名:加密相关信息:最近一次修改密码天数:密码最短使用期限:密码最长使用期限:密码过期前提醒

加密相关信息以$隔开

$1:表示加密方式为MD5

$iINxcG9C:杂质

$JGPtCwNQxlgBXhlbd/qaC1:处理后的密文

加密方法:

对称加密:加密和解密使用同一个密码

公钥密码:每个密码都成对出现,一个为公钥(pubilc key),一个为私钥(secret key)

单项加密:散列加密:只能加密不能加密,提取数据特征码 (MD5  SHA1)

1、雪崩效应 小小改变会引起很大变化

2、输出长度不变

[root@bogon /]# md5sum etc/inittab
3f206e10339f61eaf8d378bf504db462  etc/inittab


[root@bogon /]# which useradd
/usr/sbin/useradd
[root@bogon /]# ls -l $(which useradd)
-rwxr-x---. 1 root root 101168 Aug  2  2011 /usr/sbin/useradd


增加用户:

[root@bogon /]# useradd tom
[root@bogon /]# tail -1 /etc/passwd
tom:x:501:501::/home/tom:/bin/bash
[root@bogon /]# tail -1 /etc/shadow
tom:!!:17115:0:99999:7:::
更改tom密码:

[root@bogon /]# tail -1 /etc/shadow
tom:$1$d4c068/C$HTnXcRJHW9ZNY5EBK4wiK0:17115:0:99999:7:::
查看组:

[root@bogon /]# tail -1 /etc/group
tom:x:501:
查看default值:

[root@bogon /]# cd etc/default/
[root@bogon default]# ls
nss  useradd
[root@bogon default]# file useradd
useradd: ASCII text
[root@bogon default]# cat useradd
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes


查看组信息:

[root@bogon default]# cat /etc/group
root:x:0:
bin:x:1:bin,daemon
daemon:x:2:bin,daemon


添加组:

[root@bogon default]# groupadd mygroup
<span style="font-family: Arial, Helvetica, sans-serif;">[root@bogon default]# tail -1 /etc/group</span>
<span style="font-family: Arial, Helvetica, sans-serif;">mygroup:x:502:</span>


用户管理:useradd、userdel、usermod、passwd、chsh、chfn、finger、id、chage

组管理:groupadd、groupdel、groupmod、gpasswd

权限管理:chown、chgrp、chmod、umask
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux