在 UNIX® 的環境之中提供了各式不同的指令管理使用者帳號, 以下為較常使用的指令摘要及更詳細的使用範例。
指令 | 摘要 |
---|---|
adduser(8) | 新增使用者。 |
rmuser(8) | 移除使用者。 |
chpass(1) | 更改使用者資料。 |
passwd(1) | 更改使用者密碼。 |
pw(8) | 修改使用者的各種資料。 |
adduser(8) 是一支新增使用者的簡單程式。
它會建立資料於系統的 passwd
與
group
檔案之中。 同時也會建立使用者的家目錄,從
/usr/share/skel
複製預設的組態檔(“dotfiles”),
並可以選擇性的郵件通知新使用者歡迎訊息。
#
adduser
Username: jru
Full name: J. Random User
Uid (Leave empty for default):
Login group [jru]:
Login group is jru. Invite jru into other groups? []: wheel
Login class [default]:
Shell (sh csh tcsh zsh nologin) [sh]: zsh
Home directory [/home/jru]:
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username : jru
Password : ****
Full Name : J. Random User
Uid : 1001
Class :
Groups : jru wheel
Home : /home/jru
Shell : /usr/local/bin/zsh
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (jru) to the user database.
Add another user? (yes/no): no
Goodbye!
#
您輸入的密碼並不會回應到螢幕,所以不會以星號顯示 。 請確定您所輸入的密碼無誤。
您可以使用 rmuser(8) 來將使用者從系統之中完全移除 rmuser(8) 會執行以下動作:
移除該使用者的 crontab(1) 資料 (如果存在)。
移除所有屬於該使用者的 at(1) 工作。
中止所有該使用者擁有的程序。
移除系統本機密碼檔中該使用者的資料。
移除該使用者的家目錄 (如果為該使用者所有)。
移除 /var/mail
中屬於該使用者的郵件。
移除暫存空間 (如: /tmp
) 中所有屬於該使用者的檔案。
最後,在 /etc/group
檔內移除該使用者帳號。
若該群組已無成員,或者是群組名稱與該使用者名稱相同時, 則群組將會被移除; 此操作會與 adduser(8) 所建立的帳號群組相對應。
rmuser(8) 無法移除系統管理者帳號帳號, 因為這即代表嚴重的破壞行為。
為了確認您的操作,預設採互動模式。
rmuser
帳號移除#
rmuser jru
Matching password entry:
jru:*:1001:1001::0:0:J. Random User:/home/jru:/usr/local/bin/zsh
Is this the entry you wish to remove? y
Remove user's home directory (/home/jru)? y
Updating password file, updating databases, done.
Updating group file: trusted (removing group jru -- personal group is empty) done.
Removing user's incoming mail file /var/mail/jru: done.
Removing files belonging to jru from /tmp: done.
Removing files belonging to jru from /var/tmp: done.
Removing files belonging to jru from /var/tmp/vi.recover: done.
#
chpass(1) 可更改使用者資料如: 密碼、Shell及個人資訊。
僅系統管理者即系統管理者帳號可利用 chpass(1) 更改其他使用者的資訊及密碼
除了指定使用者名稱,當不加參數時,chpass(1) 會將使用者資訊顯示於編輯器當中。 並於使用者離開編輯器時更新使用者資訊。
若您並非系統管理者帳號,在離開編輯器前會詢問您的密碼。
chpass
一般使用者僅可更改自己的少部份資訊。
chpass
chfn(1) 與 chsh(1) 即為 chpass(1),也同
ypchpass(1)、ypchfn(1) 與 ypchsh(1)。
NIS 支援是自動的,所以無需在指令前加上 yp
。
若這會困擾您,請不必擔心,章 27, Network Servers 將函蓋 NIS 的部份的說明。
passwd(1) 是更改密碼常用的方式,除了超級管理者可更改其他使用者的密碼外 使用者僅能更改自己的密碼。
為了避免意外或未經同意的修改,在更新密碼前需輸入原密碼。
%
passwd
Changing local password for jru.
Old password:
New password:
Retype new password:
passwd: updating the database...
passwd: done#
passwd jru
Changing local password for jru.
New password:
Retype new password:
passwd: updating the database...
passwd: donechpass(1)、 yppasswd(1) 即為 passwd(1),皆支援 NIS。
本文及其他文件,可由此下載: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。
若有 FreeBSD 方面疑問,請先閱讀
FreeBSD 相關文件,如不能解決的話,再洽詢
<questions@FreeBSD.org>。
關於本文件的問題,請洽詢
<doc@FreeBSD.org>。