免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: 剑心通明
打印 上一主题 下一主题

专题讨论之handbook版-第3章(讨论版) [复制链接]

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
31 [报告]
发表于 2005-10-16 10:52 |只看该作者

专题讨论之handbook版-第3章(讨论版)

请参看本版置顶的精华收集贴

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
32 [报告]
发表于 2005-10-16 10:59 |只看该作者

专题讨论之handbook版-第3章(讨论版)

desktop# touch test
desktop# ll
total 4
-rw-r--r--  1 root  wheel  0 Oct 16 10:54 test
-rwxrwxrwx  1 root  wheel  6 Oct 16 09:33 test1
-rw-r--r--  1 root  wheel  6 Oct 16 09:33 test2
lrwxrwxrwx  1 root  wheel  5 Oct 16 09:33 test3 ->; test2
lrwxr-xr-x  1 root  wheel  5 Oct 16 09:33 test4 ->; test1
desktop# chflags schg test
desktop# ll
total 4
-rw-r--r--  1 root  wheel  0 Oct 16 10:54 test
-rwxrwxrwx  1 root  wheel  6 Oct 16 09:33 test1
-rw-r--r--  1 root  wheel  6 Oct 16 09:33 test2
lrwxrwxrwx  1 root  wheel  5 Oct 16 09:33 test3 ->; test2
lrwxr-xr-x  1 root  wheel  5 Oct 16 09:33 test4 ->; test1
desktop# ls -lo
total 4
-rw-r--r--  1 root  wheel  schg 0 Oct 16 10:54 test
-rwxrwxrwx  1 root  wheel  -    6 Oct 16 09:33 test1
-rw-r--r--  1 root  wheel  -    6 Oct 16 09:33 test2
lrwxrwxrwx  1 root  wheel  -    5 Oct 16 09:33 test3 ->; test2
lrwxr-xr-x  1 root  wheel  -    5 Oct 16 09:33 test4 ->; test1
desktop# chmod 777 test
chmod: test: Operation not permitted
desktop# chmod -f 777 test
desktop# ls -lo
total 4
-rw-r--r--  1 root  wheel  schg 0 Oct 16 10:54 test
-rwxrwxrwx  1 root  wheel  -    6 Oct 16 09:33 test1
-rw-r--r--  1 root  wheel  -    6 Oct 16 09:33 test2
lrwxrwxrwx  1 root  wheel  -    5 Oct 16 09:33 test3 ->; test2
lrwxr-xr-x  1 root  wheel  -    5 Oct 16 09:33 test4 ->; test1

结论:chmod的-f选项的作用就是:权限无法被更改也不要显示错误讯息

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
33 [报告]
发表于 2005-10-16 15:42 |只看该作者

专题讨论之handbook版-第3章(讨论版)

desktop# pwd
/tmp/test
desktop# ll
total 6
drw-rw-rw-  2 root  wheel  512 Oct 16 15:06 test1
-rw-r--r--  1 root  wheel    0 Oct 16 15:36 test2
lrwxr-xr-x  1 root  wheel    5 Oct 16 15:40 test3 ->; test2
dr--r--r--  2 root  wheel  512 Oct 16 15:13 test4
dr-xr-xr-x  2 root  wheel  512 Oct 16 15:13 test5
desktop# cd ..
desktop# chmod -R 777 test
desktop# cd test
desktop# ll
total 6
drwxrwxrwx  2 root  wheel  512 Oct 16 15:06 test1
-rwxrwxrwx  1 root  wheel    0 Oct 16 15:36 test2
lrwxr-xr-x  1 root  wheel    5 Oct 16 15:40 test3 ->; test2
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test4
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test5



结论:chmod的-R的作用是:对目录下的文件及子目录进行相同的权限变更,以递归的方式逐个改变。

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
34 [报告]
发表于 2005-10-16 16:10 |只看该作者

专题讨论之handbook版-第3章(讨论版)

desktop# pwd
/tmp/test
desktop# ll
total 6
dr-xr-xr-x  2 root  wheel  512 Oct 16 15:06 test1
-r-xr-xr-x  1 root  wheel    0 Oct 16 15:36 test2
lrwxr-xr-x  1 root  wheel    5 Oct 16 15:40 test3 ->; test2
drw-r--r--  2 root  wheel  512 Oct 16 15:13 test4
drwxr-xr-x  2 root  wheel  512 Oct 16 15:13 test5
desktop# cd ..
desktop# chmod -R -P 777 test
desktop# cd test
desktop# ll
total 6
drwxrwxrwx  2 root  wheel  512 Oct 16 15:06 test1
-rwxrwxrwx  1 root  wheel    0 Oct 16 15:36 test2
lrwxr-xr-x  1 root  wheel    5 Oct 16 15:40 test3 ->; test2
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test4
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test5

结论:chmod -R -P的作用是:除了符号链接的文件,其它的跟chmod -R作用一样

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
35 [报告]
发表于 2005-10-16 16:15 |只看该作者

专题讨论之handbook版-第3章(讨论版)

desktop# pwd
/tmp/test
desktop# ll
total 6
dr--r--r--  2 root  wheel  512 Oct 16 15:06 test1
-r-xr-xr-x  1 root  wheel    0 Oct 16 15:36 test2
lrwxr-xr-x  1 root  wheel    5 Oct 16 15:40 test3 ->; test2
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test4
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test5
-rw-r--r--  1 root  wheel    0 Oct 16 16:12 test6
lrwxr-xr-x  1 root  wheel    5 Oct 16 16:12 test7 ->; test6
desktop# cd ..
desktop# chmod -R -L 777 test
desktop# cd test
desktop# ll
total 6
drwxrwxrwx  2 root  wheel  512 Oct 16 15:06 test1
-rwxrwxrwx  1 root  wheel    0 Oct 16 15:36 test2
lrwxr-xr-x  1 root  wheel    5 Oct 16 15:40 test3 ->; test2
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test4
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test5
-rwxrwxrwx  1 root  wheel    0 Oct 16 16:12 test6
lrwxr-xr-x  1 root  wheel    5 Oct 16 16:12 test7 ->; test6

结论:chmod -R -L的作用是:对所有的符号链接文件都起作用

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
36 [报告]
发表于 2005-10-16 16:17 |只看该作者

专题讨论之handbook版-第3章(讨论版)

desktop# chmod 444 test2
desktop# chmod 555 test6
desktop# ll
total 6
drwxrwxrwx  2 root  wheel  512 Oct 16 15:06 test1
-r--r--r--  1 root  wheel    0 Oct 16 15:36 test2
lrwxr-xr-x  1 root  wheel    5 Oct 16 15:40 test3 ->; test2
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test4
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test5
-r-xr-xr-x  1 root  wheel    0 Oct 16 16:12 test6
lrwxr-xr-x  1 root  wheel    5 Oct 16 16:12 test7 ->; test6
desktop# chmod -R -H 777 test7
desktop# ll
total 6
drwxrwxrwx  2 root  wheel  512 Oct 16 15:06 test1
-r--r--r--  1 root  wheel    0 Oct 16 15:36 test2
lrwxr-xr-x  1 root  wheel    5 Oct 16 15:40 test3 ->; test2
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test4
drwxrwxrwx  2 root  wheel  512 Oct 16 15:13 test5
-rwxrwxrwx  1 root  wheel    0 Oct 16 16:12 test6
lrwxr-xr-x  1 root  wheel    5 Oct 16 16:12 test7 ->; test6
结论:chmod -R -H的作用:只对当前命令行里的符号链接文件起作用。
如chmod -R -H 777 test7就只改了test6文件的属性,test2的属性未做改变。

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
37 [报告]
发表于 2005-10-16 16:25 |只看该作者

专题讨论之handbook版-第3章(讨论版)

desktop# touch test1
desktop# ln -s test1 test2
desktop# ll
total 0
-rw-r--r--  1 root  wheel  0 Oct 16 16:24 test1
lrwxr-xr-x  1 root  wheel  5 Oct 16 16:24 test2 ->; test1
desktop# chmod 777 test2
desktop# ll
total 0
-rwxrwxrwx  1 root  wheel  0 Oct 16 16:24 test1
lrwxr-xr-x  1 root  wheel  5 Oct 16 16:24 test2 ->; test1
desktop# chmod -h 666 test2
desktop# ll
total 0
-rwxrwxrwx  1 root  wheel  0 Oct 16 16:24 test1
lrw-rw-rw-  1 root  wheel  5 Oct 16 16:24 test2 ->; test1
结论:chmod -h的作用是:改变符号链接文件本身的属性,不是默认的改变符号链接所链接的文件属性

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
38 [报告]
发表于 2005-10-16 16:46 |只看该作者

专题讨论之handbook版-第3章(讨论版)

desktop# touch test1
desktop# ll
total 0
-rw-r--r--  1 root  wheel  0 Oct 16 16:34 test1
desktop# ln -s test1 test2
desktop# ll
total 0
-rw-r--r--  1 root  wheel  0 Oct 16 16:34 test1
lrwxr-xr-x  1 root  wheel  5 Oct 16 16:34 test2 ->; test1
desktop# chmod -v 666 test2
test2
desktop# ll
total 0
-rw-rw-rw-  1 root  wheel  0 Oct 16 16:34 test1
lrwxr-xr-x  1 root  wheel  5 Oct 16 16:34 test2 ->; test1
desktop# chmod -v -v 777 test2
test2: 0100666 [-rw-rw-rw- ] ->; 0100777 [-rwxrwxrwx ]
desktop# chmod -v -v -v 644 test2
test2: 0100777 [-rwxrwxrwx ] ->; 0100644 [-rw-r--r-- ]
结论:chmod -v的作用:一个-v的时候显示权限变更的文件名字,多个的时候,以八进制显示权限变更的详细情况

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
39 [报告]
发表于 2005-10-17 10:29 |只看该作者

专题讨论之handbook版-第3章(讨论版)

正在看chmod的相关文章,有几个问题不大明白,望各位指点:
1:目录的大小计算。所谓的目录入口占用空间是如何计算的?
2:那个sticky bit位如果文件设置了是什么意思?看有的帖子说是为了共享文件,不大理解
3:suid的有文件里有大写的S,是什么意思?
暂时就这么多了,其它的还没看到,今天有些事情要做,明天接着看吧,今天先把这几个搞懂再说,呵呵

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
40 [报告]
发表于 2005-10-17 10:36 |只看该作者

专题讨论之handbook版-第3章(讨论版)

原帖由 "剑心通明" 发表:
正在看chmod的相关文章,有几个问题不大明白,望各位指点:
1:目录的大小计算。所谓的目录入口占用空间是如何计算的?
2:那个sticky bit位如果文件设置了是什么意思?看有的帖子说是为了共享文件,不大理解
3:sui..........


你看的这个几个地方把网址贴上,可以么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP