ユーザを追加する

ユーザを追加する場合はadduserコマンドを使うと便利。rootになりオプション無しでadduserを実行すると、adduserがユーザ名やパスワードを聞いてくるので、それに答えていけばユーザを作成出来る。
こんな感じ
# adduser
Username: hogehoge
Full name: hogehoge no fugafuga
Uid (Leave empty for default):
Login group [simamaru]: wheel
Login group is wheel. Invite simamaru into other groups? []:
Login class [default]:
Shell (sh csh tcsh bash rbash zsh nologin) [sh]: zsh
Home directory [/home/simamaru]:
Use password-based authentication? [yes]: yes
Use an empty password? (yes/no) [no]: no
Use a random password? (yes/no) [no]: no
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username : simamaru
Password : *****
Full Name : sima to maru
Uid : 1002
Class :
Groups : wheel 0
Home : /home/simamaru
Shell : /usr/local/bin/zsh
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (simamaru) to the user database.
adduser: INFO: Account (simamaru) is locked.
Add another user? (yes/no):
Goodbye!
#
[Lock out the account after creation? ]と聞かれたところで[yes]とすると、一般ユーザからsimamaruへログインすることが出来なくなるようです。
UIDは、何も入力しない場合はシステムが一意な番号を振ってくれます。Shellは/etc/shellsファイルの記載されているシェルを指定する。
対話形式じゃなくて、1行のコマンドでユーザを作成する場合はpwコマンドで
# ># pw useradd simamaru -d /home/simamaru -g wheel -s /usr/local/bin/zsh
のようにすることも可能。

ユーザを削除する場合はrmuserを使う。
# rmuser simamaru
Matching password entry:

simamaru:*:1002:0::0:0:hogehoge no fugafuga:/home/simamaru:/usr/local/bin/zsh

Is this the entry you wish to remove? y
Remove user's home directory (/home/simamaru)?
Removing user (simamaru): mailspool home passwd.


TODO

  • login classってなんだ?
  • /usr/sbin/adduserスクリプトを読んでみる。


参考記事

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2007年07月14日 14:46