Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
172
Help us understand the problem. What is going on with this article?
@Esfahan

CentOSでuserをsudo可能にする

More than 3 years have passed since last update.

環境

  • CentOS release 6.7 (Final)

手順

ユーザー追加、パスワード設定

$ useradd sampleuser
$ passwd sampleuser

visudoで/etc/sudoersを開き、下記の行のコメントアウトを外す。

$ visudo

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

sudoの実行をパスワードなしで許可する場合は、下記のほうのコメントアウトを外す。

# Same thing without a password
%wheel        ALL=(ALL)       NOPASSWD: ALL

ユーザーをwheelグループに追加

$ usermod -aG wheel sampleuser

sampleuserになって、自分の所属groupを確認

$ groups
sampleuser wheel

sampleuserでログインし、rootになってみる

$ sudo su - 
[sudo] password for sampleuser:{sampleuserのパスワード}

$ whoami
root

特定のユーザーのみsudoを許可する

username   ALL=(ALL)   NOPASSWD: ALL

suでrootになれるようにする

wheelグループのユーザーはすべてsu -でrootになれるようにする

/etc/pam.d/su
-#auth            required        pam_wheel.so use_uid
+auth            required        pam_wheel.so use_uid

以上

参考

172
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Esfahan
WEB系出身。現在はビッグデータの基盤構築、ETLなどがメイン。 / YouTubeで料理チャンネルやってます → https://www.youtube.com/channel/UCDnYBh2TtUAfQ0Z-tl0jTyw / ゲームもやってます -> https://www.youtube.com/channel/UCeqPhExV09EF5o8lZLO15Eg

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
172
Help us understand the problem. What is going on with this article?