8 使用者和組

2021-09-27 05:57:44 字數 2071 閱讀 5637

1、密碼檔案:/etc/passwd

登入名、經過加密的密碼、使用者id、組id、注釋、主目錄、登入shell

#include struct passwd *getpwnam(const cahr *name);

struct passwd *getpwuid(uid_t uid);

//沒有匹配,返回null,並設定errno為非0值。

2、shadow密碼檔案:/etc/shadow

儲存經過加密處理的密碼,僅供具有特權的程式讀取。(登入名、經過加密的密碼、若干與安全性相關的字段)

3、組檔案:/etc/group

使用者所屬各組資訊(組名、經過加密處理的組密碼、組id、使用者列表)

#include struct group *getgrnam(const  char *name);

struct group *getgrgid(gid_t gid);

//沒有匹配,返回null,並設定errno為非0值。

4、密碼加密和使用者認證

#include char *getpass(const char *prompt);//遮蔽輸入

#include char *crypt(const char *key, const char *salt);

//在編譯程式是需開啟-lcrypt

crypt()接受乙個最長為8字元的密碼,slat引數指向乙個兩字元的字串([a-za-z0-9/.])。

成功,返回乙個指標,指向長度為13個字元的字串。錯誤,返回null。

linux初學之8 使用者和使用者組

linux 是個多使用者多 任務的分時操作 系統,所有乙個要使用系統資源 的使用者都必須先向系統管理員 申請乙個賬號,然後以這個賬號的身份進入系統。使用者的賬號一方面能幫助系統管理員對使用系統 的使用者進行跟蹤,並控制他們對系統資源的訪問 另一方面也能幫助使用者組織 檔案,並為使用者提供安全性保護。...

使用者和使用者組

許可權 建立user1和user1組,並且user1和user1組擁有ssh登陸許可權。假如 擁有ssh登陸許可權的組為test,不想新建user1使用者對應的組。在新建user1使用者後,指定user1的組為test即可。擴充套件 乙個使用者可以屬於多個組,不過有個主屬組而已。受定式思維影響 以為...

使用者和使用者組

使用者資訊檔案 etc passwd 影子檔案 etc shadow 組資訊檔案 etc group 組密碼檔案 etc gshadow root localhost vim etc passwd root x 0 0 root root bin bash bin x 1 1 bin bin sbi...