Linux帳號管理

來源:互聯網
上載者:User

一、使用者識別碼:UID與GID

每個登入使用者至少都會取得兩個ID,一個是使用者ID(UserID,UID),一個是使用者組ID(GroupID,GID)。

每個檔案都會有所有者ID與使用者組ID,當顯示檔案屬性時,系統會依據/etc/passwd與/etc/group的內容,找到UID和GID對應的帳號與組名顯示出來。UID與帳號是一一對應的。

 

二、使用者帳號

跟使用者帳號有關的兩個檔案包括/etc/passwd和/etc/shadow,具體如下:

1./etc/passwd檔案結構:此檔案每一行代表一個帳號

查看/etc/passwd檔案的屬性,檔案的許可權為root使用者可以讀寫,其它使用者為唯讀:

[root@hs-uf21 ~]# ll /etc/passwd

-rw-r--r-- 1 root root 2767 Apr 21 21:00 /etc/passwd

查看/etc/passwd檔案內容,共有7個欄位,每個欄位使用分號“:”隔開,分別是:

[root@hs-uf21 ~]# head /etc/passwd

root : x : 0 : 0 : root : /root : /bin/bash

[ 1 ] [2] [3] [4] [ 5 ] [ 6 ] [ 7 ]

......

[1]:帳號名稱

[2]:密碼

[3]:UID

[4]:GID

[5]:使用者資訊說明

[6]:主資料夾

[7]:Shell

 

2./etc/shadow檔案結構:

查看/etc/shadow檔案的屬性,檔案的許可權為root使用唯讀:

[root@hs-uf21 ~]# ll /etc/shadow

-r-------- 1 root root 1684 Apr 10 21:28 /etc/shadow

查看/etc/shadow檔案的內容,共有9個欄位,每個欄位使用分號“:”隔開,分別是:

[root@hs-uf21 ~]# head /etc/shadow

root:$1$yI2Xb6os$9C5hnN3POy6sdl0TY8FZv.:15805:0:99999:7:::

......

[1]:帳號名稱

[2]:密碼

[3]:最新動向密碼的日期

[4]:密碼不可以被更改的天數

[5]:密碼需要重新更改的天數

[6]:密碼需要更改期限前的警告天數

[7]:密碼到期後的帳號寬限時間(密碼失效日)

[8]:帳號失效日期

[9]:系統保留

  • 1
  • 2
  • 3
  • 4
  • 5
  • 下一頁

聯繫我們

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