基礎命令學習目錄首頁html
passwd命令用於設置用戶的認證信息,包括用戶密碼、密碼過時時間等。系統管理者則能用它管理系統用戶的密碼。只有管理者能夠指定用戶名稱,通常用戶只能變動本身的密碼。linux
語法
passwd(選項)(參數)
選項
-
-
-
-
-
-s:列出密碼的相關信息,僅有系統管理者才能使用;
-
參數
用戶名:須要設置密碼的用戶名。bash
知識擴展
與用戶、組帳戶信息相關的文件post
存放用戶信息:學習
-
-
存放組信息:加密
-
-
用戶信息文件分析(每項用:
隔開)url
-
例如:jack:X:503:504:::/home/jack/:/bin/bash
-
-
-
503 //用戶id(0表明
root、普通新建用戶從500開始)
-
-
-
-
組信息文件分析.net
-
例如:jack:$!$:???:13801:0:99999:7:*:*:
-
-
-
-
-
-
-
-
實例
若是是普通用戶執行passwd只能修改本身的密碼。若是新建用戶後,要爲新用戶建立密碼,則用passwd用戶名,注意要以root用戶的權限來建立。code
-
[root@localhost ~]# passwd linuxde //更改或建立linuxde用戶的密碼;
-
Changing password for user linuxde.
-
New UNIX password: //請輸入新密碼;
-
Retype new UNIX password: //再輸入一次;
-
passwd: all authentication tokens updated successfully. //成功;
普通用戶若是想更改本身的密碼,直接運行passwd便可,好比當前操做的用戶是linuxde。xml
-
[linuxde@localhost ~]$ passwd
-
Changing password for user linuxde. //更改linuxde用戶的密碼;
-
(current) UNIX password: //請輸入當前密碼;
-
New UNIX password: //請輸入新密碼;
-
Retype new UNIX password: //確認新密碼;
-
passwd: all authentication tokens updated successfully. //更改爲功;
好比咱們讓某個用戶不能修改密碼,能夠用-l
選項來鎖定:
-
[root@localhost ~]# passwd -l linuxde //鎖定用戶linuxde不能更改密碼;
-
Locking password for user linuxde.
-
-
-
[linuxde@localhost ~]# su linuxde //經過su切換到linuxde用戶;
-
[linuxde@localhost ~]$ passwd //linuxde來更改密碼;
-
Changing password for user linuxde.
-
Changing password for linuxde
-
(current) UNIX password: //輸入linuxde的當前密碼;
-
passwd: Authentication token manipulation error //失敗,不能更改密碼;
再來一例:
-
[root@localhost ~]# passwd -d linuxde //清除linuxde用戶密碼;
-
Removing password for user linuxde.
-
-
-
[root@localhost ~]# passwd -S linuxde //查詢linuxde用戶密碼狀態;
-
Empty password. //空密碼,也就是沒有密碼;
注意:當咱們清除一個用戶的密碼時,登陸時就無需密碼,這一點要加以注意。
轉自:http://man.linuxde.net/passwd