How Do You Avoid Using the Root User When Doing Linux Administration?

Problem scenario
You've been given root credentials.  How do you create a new user and make it a sudoer so you can install and remove OS packages?

You know that it is best to use a non-root user for Linux administration. You have been given a root user.  How do you create a non-root user with full sudoer privileges?

This example assumes that the username is "mike."  Substitute "mike" with the username of your choice.

1. Run this command:

# useradd mike

Then respond to the following prompts.

2.  Run this command:

# visudo

3.  While in this text file (in the vi environment), enter this stanza:

mike    ALL=(ALL:ALL) ALL

4.  Save the changes to the file above.  Test the user by running this command:

sudo -i -u mike

5.  To full test it, run this:

sudo apt-get install apache2

Respond "n" to the prompt!  This is just to test it.

If you have issues with Docker, see this posting.

Leave a comment

Your email address will not be published. Required fields are marked *