免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
linux 目錄 rwx(讀寫執(zhí)行) 知多少?

linux/unix 下的文件 rwx 想必大家很熟悉了!但對目錄的rwx是怎么理解的呢?

 

今天碰到了這個問題,一時還真回答不上來,例如:

  1. 目錄執(zhí)行權(quán)限能干嗎?
  2. 目錄只有寫權(quán)限就可以寫入文件到該目錄了嗎?

于是查看了一下資料,《Advanced Programming in the UNIX》中解釋如下:

 

Note that read permission for a directory and execute permission for a directory mean different things. Read permission lets us read the directory, obtaining a list of all the filenames in the directory. Execute permission lets us pass through the directory when it is a component of a pathname that we are trying to access. (We need to search the directory to look for a specific filename.)

 

原來讀權(quán)限僅僅是讀取目錄下的list(文件列表), 執(zhí)行權(quán)限是access(訪問)目錄下的文件。

這下明白了,見用大學宿舍一哥們唱的一首《18摸》來解釋:

  1. 讀權(quán)限:“只能讓你看,不能讓你摸”
  2. 執(zhí)行權(quán)限:“只能讓你摸,不能讓你看”
  3. 寫權(quán)限:“先讓摸,后讓寫” 換句話 “ 摸都不讓,寫也就沒門了” (歌詞沒這句,呵呵?。?/li>

 

做實驗證明:

 

     root$ mkdir test/d1 -p

     root$ touch test/f1

     root$ echo "test" > test/f2

 

驗證讀權(quán)限:

     root$ chmod 004 test  (r讀權(quán)限)

     robin$  ls test (可以看到d1, f1, f2)

     robin$  cat test/f2 (Permission denied)

     root$ chmod 005 test (rx讀執(zhí)行權(quán)限)

     robin$  cat test/f2  (看到“test”了)

驗證執(zhí)行權(quán)限:

     root$ chmod 001 test (執(zhí)行權(quán)限)

     robin$ ls test (這邊沒有東西了哦!)

     robin$ cat test/f2(可以看到“test”)

驗證寫權(quán)限:

     root$ chmod 002 (w寫權(quán)限)

     robin$ echo "test2" > test/f3  (Permission denied)

     root$ chmod 003 (wx寫執(zhí)行權(quán)限)

     robin$ echo "test2" > test/f3 (成功)

 

這下清清楚楚! 不迷惑了!

由此可以看出:如果目錄沒有執(zhí)行權(quán)限,搜索時也不會找到文件及其內(nèi)容哦!

本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Linux的RWX權(quán)限管理實現(xiàn)詳解及chmod使用
更改文件權(quán)限
Linux文件屬性、權(quán)限設置
linux系統(tǒng)的登陸賬號與權(quán)限管理
軟件測試:快速學會操作目錄和文件的Linux命令(必讀一)
Linux 文件基本屬性及修改
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服