權限: r .w .x (讀 寫 執行 權限三個一組,所對應的數字爲讀=4 寫=2 執行=1)
文件:
r:可讀,可以使用類似cat等命令查看文件內容
w:可寫,可以編輯或刪除此文件
x:可執行,可以命令提示符下當作命令提交給內核運行
目錄:
r:可以對此目錄執行ls以列出內部的所有文件
w:可以在此目錄創建文件
x:可以使用cd切換進此目錄,也可以使用ls -l 查看內部文件的詳細信息
用戶ID :(user id)UID,/etc/passwd
[root@www ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
1:帳號名稱。用來對應UID
2:密碼。早期的Unix系統的密碼就是放在這邊的,但是這個文件的特性是所有的程序都能夠讀取,這樣以來很容易造成密碼數據被竊取,因此後來這個字段的密碼數據給它改放到/etc/shadow 中了,所以在這裏你看待一個[x]。
3:這個就是用戶ID號。UID=0 ,代表這個帳號是系統管理員。UID=1-499,表示系統帳號,其中1-99 是由distributions自行建立的系統帳號,100-499 若用戶有系統帳號需求時,可以使用的帳號。500-65535 ,一般用戶。
4:GID。這個與/etc/group 有關。
5:用戶信息說明欄。這個字段基本上並沒有什麼重要的用途,只是用來解釋這個帳號的意義而已。
6:家目錄。默認的家目錄在/home/yourIDname。
7:shell。有一個shell可以用來替代成讓帳號無法取得shell環境的登入動作,就是/sbin/nologin
組ID : (group id)GID,/etc/group
[root@www ~]# cat /etc/group
root:x:0:root
1:組名。用戶組類別:基本組-用戶的默認組,私有組-創建用戶時,如果沒有爲其指定所屬的組,系統會自動爲其創建一個與用戶同名的組 , 附加組/額外組——默認組以外的其它組。
2:羣組密碼。通常不需要設定,這個設定通常是給[羣組管理員]使用的。同樣的,密碼已經移動到/etc/gshadow。
3:GID。就是羣組的ID
4:此羣組支持的帳號名稱。
用戶管理:useradd,userdel,id ,usermod,chsh ,chfn ,passwd,pwck ,finger,chage
/etc/passwd (用戶賬戶信息)
[root@www ~]# tail -1 /etc/passwd
steins:x:500:500::/home/steins:/bin/bash
用戶名:密碼:UID:GID:註釋:家目錄:默認shell
useradd : create a new user or update default new user information
useradd [option] LOGIN
-u : the numerical value of the user's id.(UID)
-g : the group name or number of the user's initial login group.the group name must exist.(基本組,組必須事先存在)
-G : a list of supplementary group which the user is also a member of.(附加組,
組必須事先存在)
-c : any text string.(註釋信息)
-d : --home[HOME DIR] the new user will be created using [HOME DIR] as the value for the user's login directory.(指定家目錄)
-s : --shell[SHELL] the name of the user's login shell.(指定shell)
-r : --system creat a system account
/etc/shells : 當前系統可用的安全shell
[root@www ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
userdel : delete a user account and rekated files
userdel [option] LOGIN
-r : --remove remove home directory and mail spool(默認不刪除家目錄)
id : print real and effective user and group IDs
id [option] ....[USERNAME]
-g : --group print only the effective group ID(基本組)
-G :--groups print all group IDs
-u : --user print only the effective user ID
-n : print a name intstead of a number (-u -n ;-g -n 一起使用)
usermod : modify a user account
usermod [options] LOGIN
-u : UID
-g : initial group 更新用戶新的起始登入組,組必須已存在。(基本組)
-G :group,[...] 定義用戶爲一堆groups的成員,每個組使用“,”區別開來。(組必須已存在)
-c : comment 更改用戶passwd 裏的註釋信息
-d : home dir 更改用戶的家目錄
-s : shell 制動新登入的shell,如果此欄留白,系統將選用系統預設的shell
-l : login name 更改用戶的登入名
-L : 鎖定賬戶密碼
-U : 解鎖賬戶密碼
chsh : change your login shell
chsh [-s shell] [-l] [-u] [-v] [username]
-l : --list-shells print the list of shells listed in /etc/shells and exit
chfn : change your finger information(修改註釋信息)
chfn [option] [username]
/etc/shadow(用戶密碼信息)
[root@www ~]# tail -1 /etc/shadow
fedora:$6$Nf.Zfpxu$NiDHDmjyHSBOo/WH6YQTdB/ULS5ATRRg36bNe95B7e4tFsH2VuqV4NpvUruyy7ppWSA/23usbWm7SnKfHAyWP.:16359:2:50:7:::
用戶名:密碼:最近一次修改密碼的時間:最短使用期限:最長使用期限:警告時間:非活動時間:過期時間
passwd : update user's authentication tokens
passwd [options] [username]
-l : this option is used to lock the specified account and it is available to root only.(鎖定賬戶)
-u : this is the reverse of the [-l] option ,it will unlock the account password by removing the ! prefix.(解鎖賬戶)
-d : this is a quick way to delete a password for an account.(刪除帳號密碼)
--stdin : this option is used to indicate that [passwd] should read the new password from standard input,which can be a pipe.
pwck : verify integrity of password files(檢查用戶帳號完整性)
chage : change user password expiry information
chage [options] [LOGIN]
-l : set the number of days since January 1st 1970 when the password was last changed.(最近一次修改時間)
-E : set the date or number of days since January 1 1970 on which the user's account will no longer be accessible (過期時間)
-m : set the minimum number of days between password changes to MIN DAYS(最短使用期限)
-M :set the maximum number of days during which a password is valid (最長使用期限)
-W : set the number of days of warning before a password change is required(警告時間)
-I :set the number of days of inactivity after a password has expired before the account is locked (非活動時間)
組管理:groupadd,groupmod,groupdel,gpasswd,newgrp
/etc/group (用戶組信息)
[root@www ~]# cat /etc/group
root:x:0:root
組名:密碼:GID:以此組爲其附加組的用戶列表
groupadd : create a new group
group [option] group
-g : group's ID值
-r : 創建系統組
groupmod : modify a group definition on the system
groupmod [option] group
-g : change the group ID to GID
-n : change the name to NEW_GROUP
groupdel :delete a group
groupdel group
/etc/gshadow(組密碼信息)
[root@www ~]# cat /etc/gshadow
root:::root
組名:密碼:組管理者:組成員
gpasswd : administer /etc/group and /etc/gshadow(添加組密碼)
gpasswd [option] group
newgrp : log in to a new group
newgrp [group]
退出使用 [exit]
權限管理:chown,chgrp,chmod,umask
加密方法:
對稱加密:加密和解密使用同一個密碼
公鑰加密:每一個密碼都成對兒出現,一個爲公鑰(public key),一個爲私鑰(secret key)。