Create User on CentOS
Tested on:
- CentOS7 64 bit
- CentOS7 32 bit
- CentOS6 32 bit
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:
- 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
- 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
- 2020.06.10 Created file
- Created
Add User to Sudoers File
section
- Created