linux文件权限之默认权限与隐藏权限

文件权限之默认权限与隐藏权限

非纯文本文件:od
/bin /usr/bin 普通用户执行的命令
/sbin /usr/sbin 超级用户执行的命令
# cat /usr/bin //会显示乱码
# od -t type 文件
type:
a 默认字符输出
c 使用ASCII输出
d 十进制
o 八进制
x 十六进制
# od -t c /usr/bin/passwd
//使用ASCII输出文件
0066140 \0 \0 \0 \0 \0 \0 \0 \0 001 \0 \0 \0 \0 \0 \0 \0
左边第一列以进制来表示的bytes数
# od -t oCc /etc/issue
000000 134 123 012 113 145 162 156 145
\ S \n K e r n e

修改文件的时间或创建新文件:touch
mtime:modification time
修改文件内容时,更新这个时间
ctime:status time
文件的权限或者属性更改时,修改这个时间
atime: access time
文件内容被取用时,比如cat ,更新这个时间
# ls -l /etc/passwd
-rw-r–r--. 1 root root 2499 9月 10 10:39 /etc/passwd

# ls  -l  --time=atime  /etc/passwd
-rw-r--r--. 1 root root 2499 9月  17 08:16 /etc/passwd

# ls  -l  --time=ctime  /etc/passwd
-rw-r--r--. 1 root root 2499 9月  10 10:39 /etc/passwd

# cd  /tmp
# touch  testtouch
# ls -l  testtouch 
-rw-r--r--. 1 root root 0 9月  17 08:50 testtouch
 //touch文件时,三个时间都会修改为当前的时间
选项:
	-a  修改访问时间
	-c  仅修改文件时间,文件不存在不创建文件
	-d  后面接修改的日期  --date="日期和时间"
	-m  修改mtime
	-t  [YYMMDDhhmm]

# cp  -a  ~/.bashrc   bashrc
	// -a 复制完全属性
	
# cp  -a  ~/.bashrc   bashrc
# ll  bashrc ;ls -l  --time=atime bashrc ;ls  -l  --time=ctime  bashrc 
-rw-r--r--. 1 root root 176 12月 29 2013 bashrc
-rw-r--r--. 1 root root 176 9月  16 08:59 bashrc
-rw-r--r--. 1 root root 176 9月  17 08:57 bashrc

# touch  -d  "2 day  ago" bashrc
	//修改文件时间两天前
	
# ll  bashrc ;ls -l  --time=atime bashrc ;ls  -l  --time=ctime  bashrc 
-rw-r--r--. 1 root root 176 9月  15 09:03 bashrc
-rw-r--r--. 1 root root 176 9月  15 09:03 bashrc
-rw-r--r--. 1 root root 176 9月  17 09:03 bashrc

touch最常使用的情况:
* 创建一个空文件
* 将某个文件的日期改为目前日期(mtime和atime)

文件的默认权限:umask
# umask
0022 – > 后面三个是一般权限
# umask -S
u=rwx,g=rx,o=rx --> 目录的默认权限
1.文件默认不给执行(x)权限,最大666 rw-rw-rw-
2.目录默认给X权限,最大777 rwxrwxrwx
3.uamsk分数值指的是,该默认值需要减掉的权限

# umask  002
# touch  b.txt
# ls -l 
-rw-r--r--. 1 root root 0 9月  17 09:11 a.txt
-rw-rw-r--. 1 root root 0 9月  17 09:32 b.txt

假设umask为003  ,文件和目录的权限是什么?
umask 003,去掉的权限:--------wx
文件:(-rw-rw-rw-)-(--------wx)= -rw-rw-r--
目录:(drwx-rwx-rwx)-(--------wx)= drwxrwxr--
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值