1
0

More than 1 year has passed since last update.

ユーザー作成からsudo権限付与まで

Last updated at Posted at 2022-06-28
  • 前提条件
    • rootで作業ができる

ユーザー作成

-gと-uでそれぞれグループ(gid),ユーザーid(uid)を指定し、最後にユーザー名
今回の場合はtaroinfraでやります。また、gid,uidは抜いても構いません

useradd -g 1000 -u 1002 taroinfra

パスワード設定

passwd taroinfra

sudo権限付与

下記のコマンドで、sudoersファイルを編集します。

vi etc/sudoers

下記記載のように107行目の文章をコメントアウト(頭に#をつける)することでwheelグループに属するユーザー全員がsudoコマンドを使えるようになります。

etc/sudoers
 106 ## Allows people in group wheel to run all commands
 107 # %wheel        ALL=(ALL)       ALL

etc/sudoersを抜け下記のコマンドでユーザーをwheelグループに追加

usermod -aG wheel taroinfra

id taroinfraでwheelグループに追加されているかの確認ができます。

[root@hoge]# id taroinfra
uid=1002(taroinfra) gid=1000(ks1000) groups=1000(ks1000),10(wheel)

おまけのユーザー削除

userdel -r taroinfra

成功してもなにも出ないため注意
ユーザーのホームディレクトリを削除したくない場合は-rを抜く
-rを抜いた場合はユーザーの削除はされるもののホームディレクトリなどは残ります。

1
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
1
0