[LINUX] Procedure until you can create a general user and execute the sudo command on CentOs (memorial note)

Prelude

Even if the knowledge is insignificant for an engineer who can do it, I would like to acquire the habit of transmitting it first.

Premise

· MacOS Mojave 10.14 -Linux OS built in the virtual machine [Virtual Box] ・ CentOs7

sudo command Commands that allow you to use commands with root privileges

1 User creation

First, log in as the root user and create a user with the useradd command.

Name: testUser01 スクリーンショット 2020-03-01 15.45.04.png

It is essential to set a password so that the created user can log in. Set the password for testUser01 with the command "passwd" that sets the password.

Now you are ready to log in as a regular user (= testUser01).

2 Add a general user to the wheel group and enable the option with the visudo command.

Now, let's try logging in as a general user and use the sudo command to view log files that cannot be viewed with user privileges. cat var/log/messages スクリーンショット 2020-03-01 16.02.50.png

When I was asked for the password and typed it in as I was told, I was told that the user is not in the sudoers file.

This is because, as it was said, the sudoers file does not contain general user settings in the sudoers file.

To resolve this, do the following:

-Make general users belong to the wheel group. In CentOS7, "wheel group" is allowed to execute all commands.

Log in as the root user once, Let's add a general user to the wheel group with the "usermod" command that changes the user definition. スクリーンショット 2020-03-01 16.29.10.png

You can check if a user has been added to the wheel group with the vigr command. スクリーンショット 2020-03-01 16.30.37.png

-Set the sudoers file Use the [visudo] command to add the settings for general users. Next, let's enable the definition of the wheel group with the visudo command.

% wheel ALL = (ALL) Uncomment the ALL and enable the option. スクリーンショット 2020-03-01 16.40.27.png

Save with esc →: wq and try the sudo command again.

Command description because it is not visible on the screen cat /vat/log/messages スクリーンショット 2020-03-01 16.44.23.png

The sudo command is now available and you can see the contents of the log file!

Recommended Posts

Procedure until you can create a general user and execute the sudo command on CentOs (memorial note)
Until you create a machine learning environment with Python on Windows 7 and run it
[Note] How to give sudo authority to user on CentOS
Execute the command on the web server and display the result
Until you create Python Virtualenv on Windows and launch Jupyter
Try and learn iptables, until you can browse the web
[MariaDB] Install MariaDB on Linux and create a DB and an operating user.
Create a python environment on centos
Until you install Apache and Tomcat on Linux (CentOS) and deploy Java apps
You can do it in 5 minutes !? Create a face detection API with FastAPI and OpenCV and publish it on Heroku