Ubuntu 21.04
Sponsored Link

初期設定 : ユーザーを新規追加する2021/04/28

 
インストール直後は、システムユーザーを除くと、インストール中に設定したユーザーのみがシステム上に存在し、同時に管理者ユーザーとなっています。
ユーザーを新規追加する場合は以下のように設定します。
[1] 例として、[hirsute] ユーザーを追加します。
ubuntu@localhost:~$
sudo adduser hirsute

[sudo] password for ubuntu:  # 自身のパスワード
Adding user `hirsute' ...
Adding new group `hirsute' (1001) ...
Adding new user `hirsute' (1001) with group `hirsute' ...
Creating home directory `/home/hirsute' ...
Copying files from `/etc/skel' ...
New password:           # ユーザーのパスワードを設定
Retype new password:    # 確認再入力
passwd: password updated successfully
Changing the user information for hirsute
Enter the new value, or press ENTER for the default
        Full Name []:   # フルネーム等の情報を設定 (不要であればブランクでも OK)
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y
ubuntu@localhost:~$
[2] 追加したユーザーにも管理者権限を与える場合は以下のように設定します。
ubuntu@localhost:~$
sudo
usermod -aG sudo hirsute

ubuntu@localhost:~$
su - hirsute

Password:
# 管理者権限が必要なコマンドを実行

hirsute@localhost:~$
sudo ls -l /root

[sudo] password for hirsute:    
# 自身のパスワード

total 4
drwxr-xr-x 3 root root 4096 Apr 27 02:02 snap
[3] システムからユーザーを削除する場合は以下のように設定します。
# [hirsute] ユーザー削除 (ユーザーの削除のみ)

ubuntu@localhost:~$ sudo
deluser hirsute
# [hirsute] ユーザー削除 (ホームディレクトリも削除)

ubuntu@localhost:~$ sudo
deluser hirsute --remove-home
関連コンテンツ