Create User on CentOS

Tested on:

digitalocean: how-to-create-a-sudo-user-on-centos-quickstart

VIEW TUTORIAL LINK above ^

$ adduser username

Add User to Sudoers File.

TODO: explain what the sudoers file is.

Reference: how-to-add-user-to-sudoers-in-centos

1) Open /etc/sudoers file. visudo uses vim to open the /etc/sudoers

$ visudo

Find the following section and add the user just below root liks so. Replace <username> with the actual user name

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
<username>   ALL=(ALL)       ALL

Switch users

$ su - <username>

Remove users:

Reference:

  1. Remove the user.

It’s just one simple command to delete a user. In this case, we’re removing a user called mynewuser:

$ userdel <username>

If you want to remove all the files for the user, then use -r:

$ userdel -r mynewuser
  1. Remove user’s root Privileges

Visudo uses vim to update the users file.

$ visudo

Find the following snippet:

## Allow root to run any commands anywhere
root ALL=(ALL) ALL
<username> ALL=(ALL) ALL

Delete the following line:

<username> ALL=(ALL) ALL

Now, press ESC and type :wq and hit ENTER to save and exit the configuration file.

Journal