Linux學習課程筆記(3)

來源:互聯網
上載者:User

標籤:linux

檔案許可權管理


passwd username 修改使用者密碼

groupadd groupname  添加一個組

查看linux中所有組的資訊,儲存在 etc/group 中


添加使用者的時候,可以指定將使用者添加到那個組

useradd -g username groupname

查看linux中所有使用者資訊

在檔案/etc/passwd中

link:x:1000:1004:Link Lee:/home/link:/bin/bash

使用者名稱:密碼:使用者ID:所在組ID:使用者描述:使用者組目錄:該使用者所使用的shell解譯器


usermod  命令修改使用者資訊

usermod -g groupname username 修改使用者的組

usermod -d dirname username 修改使用者的初始目錄


chmod

  ①命令英文原意:change the permissions mode of a file

  ②命令所在路徑:/bin/chmod

  ③執行許可權:所有使用者

  ④文法:chmod [{ugoa}{+-=}{rwx}] [檔案或目錄]

  [數字許可權] [檔案或目錄]

  -R 遞迴修改

  ⑤功能描述:改變檔案或目錄許可權

  *只有檔案或目錄“所有者”或者“root使用者”可以修改當前檔案或目錄的許可權

  *u:所有者,g:所屬組,o:其他人,a:所有人

  *數字許可權:r(讀):4,w(寫):2,x(執行):1

  例:chmod 755 /tmp/test  (檔案許可權被修改為:rwxr-xr-x)

650) this.width=650;" src="http://www.51testing.com/attachments/2017/04/14982672_201704201036261NrVL.jpg" border="0" style="margin:0px auto;padding:0px;border:0px;" alt="14982672_201704201036261NrVL.jpg" />

  *只有對檔案所在的目錄有”寫入權限“才可以刪除此檔案


操作範例

touch a.txt 

chmod u+w a.txt 給所有者提供寫入權限

chmod o-r a.txt 取消其他人的讀許可權

chomd a+x a.txt 給所有人提供執行許可權

chmod 770 a.txt 變更檔案許可權為 rwxrwx--- 


關於許可權的細節

要進入目錄,必須有目錄的執行許可權

要刪除目錄裡的檔案,必須有目錄的寫入權限






Linux學習課程筆記(3)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.