1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Linuxについて5(自分用メモ

Posted at

ユーザーにはユーザーID(UID)という固有ID番号が割り当てられる。
Linux上ではユーザーの識別はUIDで行われる。

UIDの確認
id [ユーザー名]

ユーザー名とUIDの対応はユーザー情報が格納されたファイル/etc/passwordに記述される。

●ユーザーの種類
・root ID「0」
システム全体を制御する権限をもつ。
・システムユーザー ID「1~99」
システムプログラムやサーバソフトウェアを実行する特別なユーザー
・一般ユーザー ID「100以上」
システムを利用するユーザー

・一時的にrootユーザーに切り替えるコマンド
su [-] [ユーザー名]

※[-】を省略してもrootユーザーになれるが、以下の点が異なる。
1、rootユーザー用コマンドの多くが使えない
2、カレントディレクトリが元のまま

・元のユーザーに戻るコマンド
exit

・rootユーザーの権限が必要なコマンドを実行(予め設定が必要)
sudo コマンド

●ユーザーは何らかのグループに所属しなければならない

所属グループの確認コマンド
groups [ユーザー名]

※idコマンドでもグループ情報を確認できる

●ユーザーの作成
useradd ユーザー名

※ユーザーを作成できるのはrootだけなので、su - コマンドでrootに切り替える

●パスワード設定
passwd [ユーザー名]

※passwdコマンドは一般ユーザーでも使えるが、その場合は自分のパスワードのみ変更できる

●ユーザーの削除 rootユーザーのみ
userdel [-r] ユーザー名

●ホームディレクトリごとユーザーを削除する
userdel -r ユーザー名

●グループ作成 rootのみ
groupadd グループ名

●ユーザーの情報を変更(グループに作成済みユーザーを参加させる) rootのみ
usermod -G グループ名 ユーザー名

●グループの削除 rootのみ
groupdel グループ名

※ユーザーが削除するグループにプライマリグループとして存在する場合はグループ削除できない。

グループの情報は/etc/groupファイルに格納される

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?