chmod和find命令的使用

來源:互聯網
上載者:User

touch myfile 建立一個檔案
chmod u+w myfile  給屬主使用者增加執行許可權
chmod u+x myfile
chmod u-r myfile
chmod g+x myfile  給同組使用者增加執行許可權
chmod o+x myfile  給其他使用者增加執行許可權
chmod u+s myfile  給檔案myfile設定suid
id 查看自己屬於哪個組
ln -s /usr/sgy /usr/lessonshell/sgy   在/usr/lessonshell/sgy目錄下建立/usr/sgy的一個連結,前提是/usr/lessonshell/sgy必須存在

find . -name "*.c" print 查目前的目錄及子目錄所有*.c檔案
find sgy -name "*.c" print查sgy目錄及子目錄所有*.c檔案
find / -name "*.c" print查根目錄及子目錄所有*.c檔案
find /usr/sgy -user root -print 查/usr/sgy目錄及子目錄所有檔案屬主為root的檔案
find . -group root -print 查目前的目錄及子目錄所有使用者組為root的檔案
find /usr/sgy -nouser -print查/usr/sgy目錄及子目錄所有沒屬主的檔案
find /usr/sgy -nogroup -print查/usr/sgy目錄及子目錄所有沒屬組的檔案
find . -mtime -5 -print  查目前的目錄及子目錄所有更改時間在5日內的檔案
find . -mtime +5 -print  查目前的目錄及子目錄所有更改時間在5日前的檔案
find . -newer pipeline.c ! -newer echoserver.c print
查目前的目錄及子目錄所有更改時間比pipeline.c新但比echoserver.c的檔案
find . -type d -print查目前的目錄及子目錄所有目錄
find . size +1000c -print查目前的目錄及子目錄所有大於1k的檔案
find . size +1000c -exec ls -l {} /;  查目前的目錄及子目錄所有大於1k的檔案,並用ls列出來,注意別丟逗號
find . name "*.c" -exec ls -l {} /;查目前的目錄及子目錄所有.C檔案,並用ls列出來,注意別丟逗號
find . name "*.c" | xargs ls -l 查目前的目錄及子目錄所有.C檔案,並用ls列出來(注意xargs的使用,建議使用)
find . name "*.log" -mtimes +5 -exec rm {} /;查目前的目錄及子目錄所有5天前的log檔案,並刪除(無提示,慎用)
find . name "*.log" -mtimes +5 -ok rm {} /;查目前的目錄及子目錄所有5天前的log檔案,並刪除(有提示)
find . name "*.c" | xargs grep "fork"查目前的目錄及子目錄所有包含fork的*.c檔案
find . name "*.c" | xargs ls -l 查目前的目錄及子目錄所有.C檔案,並用ls列出來

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.