Hi,
In this tutorial, we’re gonna learn to give root privileges or sudo access to a cPanel user. Sudo stands for super user do! that can execute any command, browse any directory, and modify anything as a super user of the Linux server. The sudo command executes a command as a root user with all the rights and privileges that a root user has.
![how to give sudo power to a cPanel user](https://blog.redserverhost.com/wp-content/uploads/2022/04/how-to-give-sudo-power-to-a-cPanel-user-1024x610.png)
Generally, non-root users only have write access. They can create and delete files in a very small number of places such as their home directory, root directory, and the temporary directory (/tmp).
A user cannot edit or delete any files apart from the above directories. Some directories don’t even allow viewing the contents inside it, such as the home directory of other users.
However, with root access, you can do anything, anywhere, anytime on the server. Here are some major tasks that a root user can easily perform.
A root can read and write everywhere.
A root can see and modify every single file in the user’s home directory.
A root can easily add or remove users.
A root can erase the entire hard drive of the server.
A root can replace commonly-used programs with clones that do malicious things.
A root is always allowed for everything.
The system will allow a root user to do absolutely anything.
Other than this, assigning root privileges/sudo access to a cPanel user will be easier if you followed the below steps.
Method 1: Give Root Privileges using usermod Command
The usermod command in Linux is used to change the user account. With the help of the usermod command, we can easily change the groups and permissions to a specific user in Linux. There are 7 types of groups in the Linux file system that I’ve mentioned below.
- root
- bin
- daemon
- sys
- adm
- disk
- wheel
Must See: Allow CSF Privileges to a Reseller
Follow the below command to add a user to the root.
usermod -G root user
![usermod command example](https://blog.redserverhost.com/wp-content/uploads/2022/04/usermod-command-use.png)
The above command will add a user to the root. Let’s jump to the second method.
Method 2: Editing the /etc/passwd file
You can also assign root privileges to a cPanel user by editing the /etc/passwrd file. Simply open the passwd file using any text editor, and change the group user id to 0 which represents the root permission.
Follow the below command to edit the /etc/passwrd file, and make this method work.
- First of all, log in to your SSH with root power.
- Follow the below command to edit the passwd file.
vi /etc/passwd
Or
nano /etc/passwd
- Move into the INSERT mode by typing the i from your keyboard.
- Change the existing group and permission GID & UID to 0:0 to assign the user with root privileges.
- After modifying the permissions, press the ESC button and then type :wq! Save & Exit (If using the vi command).
- However, it’s recommended to use the nano command as it will be more convenient for you to enter & exit from the text editing tab.
![nano command example](https://blog.redserverhost.com/wp-content/uploads/2022/04/nano-command-example-1024x197.png)
This is how you can easily give root privileges to a cPanel user. Now, let’s jump to the sudo user.
Give sudo Power to a cPanel User
Similar to method 2, we can edit the sudoers file present inside the /etc/ directory, and you can add a sudo user by typing the following command inside the sudoers file.
Simply type the nano /etc/sudoers command to open up the sudoers file with a text editor and then add the below command at the end of the file to add a user to a sudo user.
user ALL=(ALL) ALL
Similar to method 2, we can edit the sudoers file present inside the /etc/ directory, and you can add a sudo user by typing the following command inside the sudoers file.
![Give sudo access](https://blog.redserverhost.com/wp-content/uploads/2022/04/Give-sudo-access.png)
In this command, the word ALL represents that you’re giving all (full control) to the user, and the user can execute any command by just authenticating.
Again, use :quit or :wq! command to save the file & Exit.
I hope this helps you. This is how you can easily give root privileges/sudo power to any user. Moreover, you can follow us on Facebook & Twitter to stay updated with the latest posts related to Linux Commands, Web Hosting, and other technologies.
Give us a chance to serve you. Try our WHM Reseller Hosting with root access, and you’re gonna love our services as we’re offering worldwide with full transparency and cost-efficiency. You can purchase web hostings at the cheapest cost over the Internet.