How to add a new user to CentOS

Open a terminal window and log in to your server via SSH.
Create the user by entering the following command. Replace exampleuser with your desired username:

adduser exampleuser

Set the password for your new user by entering the following command. Replace exampleuser with your desired username:

passwd exampleuser

You will now need to edit your sudoers file to grant your new user the correct permissions. Enter the following command to open your sudoers file for editing:

visudo

Type ‘i’ to enter the insert mode, and add an entry for your user below the root user, granting all permissions. Replace exampleuser with your username:

## Allow root to run any commands anywhere
root ALL=(ALL) ALL
exampleuser ALL=(ALL) ALL

Press ‘Esc’ to leave insert mode and enter the following command to save the file and quit visudo:

:wq
Log out of your server as the root user by entering the following command:
logout

Log in to your server as the new user by entering the following command. Replace exampleuser with your username, and the example IP address with your server’s IP address:

ssh exampleuser@122.222.22.22

Now you can administer your server with the new user account instead of root. When you need to execute superuser commands in the future, preface them with sudo. For example, later in this guide you’ll execute sudo iptables -L while logged in with your new account. Nearly all superuser commands can be executed with sudo, and all commands executed with sudo will be logged to /var/log/auth.log.

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

FFMPEG install on CentOS

How to install FFMPEG and FFMPEG-PHP install on CentOS 5.X To install FFMPEG please follow the...

How to set hostname on Centos 6?

In order to permanently set hostname on Centos 6 VPS you neew to run # nano...

How to change hostname on CentOS permanently

If you are installing LAMP on a new server and ran into the following issue with httpd during the...

CentOS: Start custom script automatically after network startup

Find the ifup-post under /etc/sysconfig/network-scripts. This scipt is called right after any...

Change hostname in CentOS

How to Change Hostname - CentOSThis KB helps user to change hostname on CentOS. By default your...