How to Grant a New User to Root Privileges on CentOS 6 / CentOS 7

Share this Article :

One recommended way to manage virtual private server (VPS) or a dedicated linux server is not using the root account as the main access for SSH login. This is because usually the hackers will try to brute force your root password and potentially get access to your server. Instead of using the default root account, you can create a new account and assign root privileges to it and issue the sudo command line to root from it. Please make sure that the normal user account given root privileges accounts work properly before you disable the default root login access. The following command has been tested works on CentOS 6, CentOS 7, RHEL 6 and RHEL 7 VPS.

Also Read :   How to Properly Reboot Linux CentOS/RHEL Server

1. Create new account named skytech and set the password :

[[email protected] ~]# useradd skytech
[[email protected] ~]# passwd skytech
Changing password for user skytech.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

2. Grant a New User to Root Privileges

[[email protected] ~]# visudo

Add the following code at the bottom of the file and save the file with the command :wq :

## Allow skytech user to run any commands anywhere
skytech    ALL=(ALL)       ALL

This will grant a root privileges to the normal user skytech.

Also Read :   How to Fix "cannot restore segment prot after reloc: Permission denied" error While Restarting zmcontrol on Zimbra


Leave a Reply