Home Beginner's Guide How to create a root user and password in Linux

How to create a root user and password in Linux

Creating a root user and setting a password in Linux is crucial for system administration. This guide provides clear instructions on how to establish root user credentials, from enabling the root account to setting a secure password, enhancing the safety and management of your Linux system.

by John Horan
creating a root user and password in linux

Hello, FOSS Linux enthusiasts and newcomers alike! Today, we’re exploring the intricacies of creating and managing root users in various popular Linux distributions like Ubuntu, Debian, Fedora, CentOS, RHEL, openSUSE, and Arch Linux. From setting up passwords to identifying if you’re logged in as root, this guide is tailored to demystify these crucial aspects. We’ll also sprinkle in some personal insights and practical tips to ensure your journey is as smooth as possible.

Understanding the root user in Linux

Before we jump into the “how-to,” let’s talk about the “what” and “why.” The root user in Linux is like the administrator account in Windows. It has full control over the system, which is both powerful and risky. That’s why I always tell my friends: with great power comes great responsibility!

How to know if a user is root

Knowing whether you’re logged in as the root user or a standard user is crucial for both security and system management. Let me share a couple of simple methods that I personally use to check this. They are quick and effective, perfect for both newbies and seasoned Linux users.

1. Checking the user ID (UID)

Every user in a Linux system, including root, has a unique identifier called the User ID (UID). The root user always has a UID of 0. Here’s how to check it:

  1. Open your terminal – the trusty Ctrl + Alt + T shortcut works wonders.
  2. Enter the following command:Input:
    id -u


    • If you’re root, it will display 0.
    • For any other user, it will display a different number.

2. Using the whoami command

This command is as straightforward as it sounds – it tells you ‘who am I’ in terms of the user account.

  1. Access the terminal.
  2. Type in the command:Input:


    • If you’re the root user, it will simply say root.
    • For any other account, it will show the respective username.

3. Checking the prompt symbol

This is a less technical but still effective method. In many Linux distributions, the command prompt itself can give you a hint:

  • Root user prompt: Often, it’s indicated by a # symbol.
  • Standard user prompt: Typically shows a $ symbol.

However, remember that prompt symbols can be customized, so this method isn’t as foolproof as the previous two.

Creating the root user in various Linux distributions

Each Linux distribution has its quirks, so I’ll guide you through some of the most popular ones. Remember, the process might differ slightly depending on the version.

Ubuntu and Debian

  1. Open the terminal: You can do this by pressing Ctrl + Alt + T.
  2. Set the root password: Ubuntu doesn’t enable the root account by default, but you can set a password for it.Input:
    sudo passwd root


    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully
  3. Log in as root: Now, you can use su - to switch to the root user.

Fedora, CentOS, and RHEL

  1. Access the terminal.
  2. Change to root: These distributions usually have the root user enabled by default.Input:
    su -


  3. Set or change the root password (if needed).Input:


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

Arch Linux and Manjaro

  1. Open the terminal: Arch users love their terminals, so you’re probably familiar with this step. If not, it’s usually accessible via a quick keyboard shortcut like Ctrl + Alt + T.
  2. Log in as root: In Arch, the root account is enabled by default, but you might not have set a password during installation.Input:

    Output: You’ll be prompted to enter the root password if it’s already set. If not, you’ll gain root access immediately.

  3. Set or change the root password: If you haven’t set the root password or want to change it, you can do so easily.Input:


    New password:
    Retype new password:
    passwd: password updated successfully
  4. Verify root access: You can verify that you’re logged in as root using the methods I mentioned earlier, like whoami or checking the prompt symbol.


  1. Open your terminal.
  2. Set the root password: Similar to Ubuntu, you’ll need to set a password for the root user.Input:
    sudo passwd


    New password:
    Retype new password:
    passwd: password updated successfully

Personal preferences and security tips

While I love tinkering with root access, I always remind myself to be cautious. Here are some personal tips:

  • Use strong passwords: This can’t be overstated. A strong password is your first defense against unauthorized access.
  • Limit root usage: I try to use the root account only when absolutely necessary. For regular tasks, I stick to my standard user account.
  • Regularly update passwords: It’s a good habit to change your root password periodically.

Frequently asked questions about root users in Linux

I’ve gathered a handful of questions that I often see in forums and from friends who are just starting with Linux.

1. What is the difference between su and sudo?

  • su (Switch User): This command allows you to switch to another user account, including root. By default, without any username, it switches to root. You need the root password to use it.
  • sudo (Super User DO): It allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file. It requires the user’s password, not the root password.

2. Is it safe to use the root account for daily tasks?

  • Generally, no. Using the root account for daily tasks can be risky because any command executed has full system privileges. This can lead to accidental system damages or security risks. It’s best to use a regular user account and only switch to root when necessary.

3. How can I prevent unauthorized access to the root account?

  • Use a strong, complex password for root.
  • Regularly change the root password.
  • Limit the use of the root account. Prefer sudo for administrative tasks.
  • Implement additional security measures like two-factor authentication if possible.

4. Can I disable the root account?

  • Yes, you can disable the root account, primarily for security reasons. In Ubuntu, for example, the root account is disabled by default. You can disable it in other distributions by setting an invalid password or using usermod command. However, ensure you have another way of gaining administrative privileges, like via sudo.

5. What should I do if I forget the root password?

  • If you forget the root password, you can reset it. This usually involves booting into a single-user mode or a recovery mode and then using the passwd command to set a new password. The exact steps can vary based on the distribution.

6. Why do some distributions not set a root password by default?

  • Some distributions like Ubuntu focus on enhancing security by encouraging the use of sudo instead of switching to root. This approach minimizes the risks associated with accidental misuse of root privileges.


Congratulations! You now know how to create a root user and set a password in various Linux distributions. Each distribution has its nuances, but the underlying principles of security and caution remain constant. Whether you’re a seasoned pro or a newcomer, mastering these skills will greatly enhance your Linux experience. Keep exploring, stay curious, and most importantly, stay secure in your Linux adventures!

You may also like

Leave a Comment



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us


©2016-2023 FOSS LINUX



“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.