0
0

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 3 years have passed since last update.

Linuxユーザーの追加・確認・削除

Posted at

現在ログインしているユーザーの確認

下記3つのうちどれか。

$ echo $USER
$ who
$ users

ユーザー一覧の確認

$ cut -d: -f1 /etc/passwd

ユーザー名が分かっている場合はgrepしてあげる。

$ cut -d: -f1 /etc/passwd | grep hoge

ユーザーを新規追加

ユーザーの登録

$ useradd testuser

ユーザーが登録されているかの確認

$ cat /etc/passwd | grep testuser

# testuser:x:1000:1000::/home/testuser:/bin/bash

ユーザーにパスワードを設定

$ sudo passwd testuser

ユーザーの削除

※ホームディレクトリ配下のユーザーディレクトリも削除する場合は-rオプションが必要。

$ sudo userdel -r testuser
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?