Article

Table of Contents
Theme:
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $300 by adding new articles!

Create a Sudo User on Fedora

Last Updated: Tue, Jun 16, 2020
Best Practices Fedora System Admin

Introduction

Performing server administration as a non-root user is a best practice. For security, your first task when deploying a Fedora instance at Vultr is to create a non-root user with sudo access.

This guide applies to the following versions:

  • Fedora 32
  • Fedora 31

1. Add a New User Account

Create a new user account with the adduser command.

# adduser example_user

Set a strong password for the new user with passwd.

# passwd example_user
Changing password for user example_user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

2. Add the User to the Wheel Group

Add the new user to the wheel group with usermod.

# usermod -aG wheel example_user

3. Edit Sudoers File

Chekc the sudoers file with visudo.

# visudo

Look for the wheel group. Remove the comment if the line is disabled. It should look like this when you are ready to save the file.

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

Save and exit vi. Type ESC, then :WQ, then ENTER.

Note: The visudo utility performs syntax checking before committing your edits to the file. A malformed sudoers file can break your system. Never edit /etc/sudoers directly. For example, if you make an error, you'll see this when exiting visudo.

visudo: >>> /etc/sudoers: syntax error near line 64 <<<
What now?
Options are:
(e)dit sudoers file again
e(x)it without saving changes to sudoers file
(Q)uit and save changes to sudoers file (DANGER!)

4. Test

Switch to the new user.

# su - example_user

Verify you are the new user with whoami, then test sudo access with sudo whoami, which should return root.

$ whoami
example_user
$ sudo whoami
[sudo] password for example_user:
root

Conclusion

The new user account is ready to use. As a best practice, use this sudo user for server administration. You should avoid using root for maintenance tasks.

Want to contribute?

You could earn up to $300 by adding new articles