• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Create a Sudo User on CentOS

Written by Admin, Updated On May 7, 2019
centos, sudo, sudo user
How to Create a Sudo User on CentOS

The sudo command designed for granting administrator privileges to normal users. This tutorial will show you the simple and easy way to create a new user on CentOS and make it sudo user account. You can use this user account to execute administrative commands without a need to logging as a root user in to your CentOS server.

Creating Sudo User On CentOS#

Follow the steps below to create a sudo user on your CentOS server. You can skip user creation steps if you wants to give sudo access to existing user.

At First, Log in to your CentOS server as the root user.

ssh root@server_ip_address

Next, create a new user account using adduser command. Be sure to replace demouser with the user name that you want to create.

adduser demouser

Use the passwd command to set a password for the new user.

passwd demouser

It will prompt to confirm new password. Make sure you use a strong password. Use a combination of alphabets, upper case letter, special character and number as a password.

Output:
Changing password for user demouser.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

By default on CentOS system, members of the wheel group are granted with sudo access. Now, user is ready to add to wheel group to grant sudo access.

usermod -aG wheel demouser

Verify the sudo access#

Login using new created user or you can switch to the new created user by type :

su - demouser

Use the sudo command to run the whoami command:

sudo whoami

If new user account have sudo access then output of given command will be root as below :

Now you can use sudo by just type sudo before any command and give space :

sudo ls -la /root

Conclusion#

Finally, You have learned how to create a user with sudo privileges. You can now log in to your CentOS server with this user account and use sudo to run administrative commands.

Your valuable suggestions are welcome. Feel free to leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install MariaDB on Debian 9 Server
Next Article   How to Install Apache on CentOS 7 Server

Related Posts

  • How to Install Php 8 on CentOS 8

    How to Install PHP 8 on CentOS 8

    January 27, 2021
  • How to Install Python 3.9 on CentOS 8

    How to Install Python 3.9 on CentOS 8

    December 31, 2020
  • How to Install GIMP 2.10 on CentOS 8

    How to Install GIMP 2.10 on CentOS 8

    December 30, 2020

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook