How to Create Sudo User in openSUSE Linux

The sudo command allows a user to administer a Linux system with the security privileges of another user, by default, the superuser or root.

In this guide, we will walk you through the process of creating a sudo user in openSUSE i.e create a user and grant them privileges to invoke the sudo command.

For this guide, we will use openSUSE Leap 15.3, the latest release on which the sudo command comes pre-installed. However, if this is not the case for you and the sudo command isn’t installed on your openSUSE operating system, install it as follows.

Install Sudo in openSUSE Linux

First switch to the root account, using the su command, enter the root password when prompted, and then run the zypper command to install sudo as shown:

$ su - 
# zypper in sudo

This guide also assumes that you have a freshly installed openSUSE operating system on your computer.

Create Sudo User in openSUSE Linux

Start by creating a user account (called sysadmin in this example), using the useradd command, and create a secure password for the user as follows. The -m flag instructs to create the user’s home directory.

Note that the user tecmint is the default administrative user that can invoke sudo. Therefore we are using it to create another administrative user that can invoke sudo as well.

$ sudo useradd -m sysadmin
$ sudo password sysadmin
Create Sudo User in openSUSE
Create Sudo User in openSUSE

Next, add the user sysadmin to the administrative group called wheel using the usermod command as shown.

In this command, the -a flag means adding the user to the supplementary group specified by the -G flag. Then check the sysadmin’s groups using the groups’ command:

$ sudo usermod -aG wheel sysadmin
$ sudo groups sysadmin
Add User to Wheel Group
Add User to Wheel Group

Configure Sudo Access and Wheel Group in Sudoers File

Now you need to configure the wheel group to allow users who belong to it to execute any command using sudo. Open the sudoers file for editing by running the following command (by default, visudo uses vim as an editor):

$ sudo visudo

Look for the lines:

Defaults targetpw   # ask for the password of the target user i.e. root
ALL   ALL=(ALL) ALL   # WARNING! Only use this together with 'Defaults targetpw'!

and comment them out as shown in the following screenshot.

Configure Wheel Group
Configure Wheel Group

Also, look for the following line.

# %wheel ALL=(ALL) ALL

and uncomment it to allow members of the group wheel to execute any command by invoking the sudo command:

%wheel ALL=(ALL) ALL
Enable User to Use Sudo Command
Enable User to Use Sudo Command

Save the changes in the sudoers’ file and close it.

Note: After the recent changes, the default user account on a freshly installed system is disabled from sudo access. In this case, the user tecmint can no longer invoke the sudo command unless the user is added to the wheel group.

Testing Sudo User in openSUSE Linux

To test if the newly created user account can invoke the sudo command, switch the account using the su command, then run any command using sudo.

$ su - sysadmin
$ sudo zypper install git
Test Sudo User in openSUSE
Test Sudo User in openSUSE

That’s all! In this guide, we looked at how to create a sudo user in the openSUSE Linux distribution. As usual, reach us via the comment form below for any questions or comments.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.