The sudo command makes it easier to manage your Fedora system. Certain commands in Fedora expect to be run only by a privileged user or administrator. The sudo command lets you run a command as if you’re the administrator, known as root.

Unlike some other methods, it also offers some key features:

  • Keeps a log when someone uses sudo to run a command
  • Supports automatic command line completion
  • Allows sharing of privileges without sharing the root password

Set up during installation

If you are installing Fedora, you can configure this function in advance. In the installer, when you set up a normal user account, check the option for Make this user administrator:

User administrator (sudo) option enabled in installer

Behind the scenes, this option sets up the user so they can use sudo when they login. This is a time saver for installations like laptops. They typically have a single user who owns the system.

Set up after installation

If you’ve already installed your system, don’t worry. You can still configure this option. First, open a terminal if needed. Use this command to verify your user account name:

$ id
uid=1000(john) gid=1000(john) groups=1000(john) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

In this example, your account name is john. Next, use this command to assume privileges of root, the system administrator. Enter the password for root at the prompt.

su -

Next run this command to add your username to the special wheel group. This group is already set up to provide sudo access:

usermod -a -G wheel john

You can check the results using the id command:

# id
uid=1000(john) gid=1000(john) groups=1000(john),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

Using sudo

You must logout, and then login, to inherit the group membership change. Once you do, you can issue a command like this:

sudo <command>

You are asked for your account password, not the password for root. The command then runs, as if you were the system administrator. If you want to start an interactive root shell, use this command:

sudo -i