linux使用者的秘密之login.defs檔案詳解

來源:互聯網
上載者:User

標籤:使用者名稱   linux   login.defs   

    我們都知道linux下有很多使用者,有超級管理使用者,有普通使用者,還有很多的系統使用者。

    那麼問題來了,這些使用者是怎樣產生的呢?又是那些規則決定著這些使用者的屬性呢?那麼,就讓我帶你們走進linux,揭開它的神秘面紗吧!

    凡是接觸過linux的人都知道,建立一個使用者只需要很簡單的一個命令:“useradd +使用者名稱”就能成功建立一個linux普通使用者,“passwd +使用者名稱”就可以給使用者設定密碼。

[[email protected] ~]# useradd liupengfang

[[email protected] ~]# passwd liupengfang

更改使用者 liupengfang 的密碼 。

新的 密碼:

重新輸入新的 密碼:

passwd: 所有的身分識別驗證令牌已經成功更新。

    建立完成後,我們可以用id命令查看該使用者的ID:

[[email protected] ~]# id liupengfang

uid=4005(liupengfang) gid=4005(liupengfang) 組=4005(liupengfang)

    還可以在/home目錄下查看到該使用者的家目錄:

[[email protected] ~]# cd /home/

[[email protected] home]# ls

fedora  Fedora  liupengfang  mandriva

    我們會看到使用者liupengfang的uid為4005,gid也為4005.為什麼這些id不是從1開始呢?為什麼在建立該使用者後會在/home目錄下建立一個自己的家目錄呢?這些使用者會不會到期呢?這就需要我們瞭解一個檔案------login.defs。

    我們查看下這個檔案:

[[email protected] home]# vim /etc/login.defs 

PASS_MAX_DAYS   99999    #密碼最長到期時間

PASS_MIN_DAYS   0        #密碼最短到期時間

PASS_MIN_LEN    5        #密碼最小長度

PASS_WARN_AGE   7        #密碼到期提前提醒時間


#

# Min/max values for automatic uid selection in useradd

#

UID_MIN                   500    #uid最小值

UID_MAX                 60000    #uid最大值


#

# Min/max values for automatic gid selection in groupadd

#

GID_MIN                   500    #gid最小值

GID_MAX                 60000    #gid最小值


#

# If defined, this command is run when removing a user.

# It should remove any at/cron/print jobs etc. owned by

# the user to be removed (passed as the first argument).

#

#USERDEL_CMD    /usr/sbin/userdel_local


#

# If useradd should create home directories for users by default

# On RH systems, we do. This option is overridden with the -m flag o

n

# useradd command line.

#

CREATE_HOME     yes    #是否同時建立家目錄


# The permission mask is initialized to this value. If not specified

# the permission mask will be initialized to 022.

UMASK           077    #建立後使用者的許可權掩碼


# This enables userdel to remove user groups if no members exist.

#

USERGROUPS_ENAB yes    #建立使用者時是否同時建立相同使用者名稱的組


# Use SHA512 to encrypt password.

ENCRYPT_METHOD SHA512    #密碼加密方式為SHA512

    看完這個設定檔,我們就會大致瞭解,為什麼使用者建立後它的那些屬性其實都是有根有據的,login.defs這個檔案就是用來設定使用者建立時屬性的檔案。當然這些屬性也不是固定不變的,我們可以用usermod +參數來改變它的各個屬性,而這些參數只要man一下就知道了。


本文出自 “IT網路” 部落格,請務必保留此出處http://liupengfang1015.blog.51cto.com/6627801/1662534

linux使用者的秘密之login.defs檔案詳解

聯繫我們

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