[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedMay 30, 2023

How to Enable and Disable Root User Account in Ubuntu

How To Enable And Disable Root User Account In Ubuntu

This tutorial explains how to enable and disable the root user account in Ubuntu Linux.

As a new Ubuntu user, you may wonder how to log in to your Ubuntu system as a root user or what is the default root password. In Ubuntu Linux, the root user account is disabled by default for security reasons.

 

Sudo Users

Ubuntu users are encouraged to perform system administrative tasks by granting administrative privileges to a regular user using a tool named sudo. Sudo allows authorized users to run programs as another user, usually the root user.

By default on Ubuntu systems, members of the group sudo are granted with sudo access. The initial user created by the Ubuntu installer is already a member of the sudo group. Chances are that the user you are logged in as is already granted with administrative privileges.

If you want to grant sudo access to another user, simply add the user to the sudo group:

usermod -aG sudo username

To temporarily elevate root user privileges, run the command prefixed with sudo:

sudo some-command

The first time you use sudo in a session, you will be prompted to enter the user password.

If you want to run a command with sudo privileges without entering the password, you’ll need to edit the sudoers file. To do so type visudo:

sudo visudo

This will open the /etc/sudoers file with your favorite command line text editor . Add the following line by replacing username with your username:

/etc/sudoers
username ALL=(ALL) NOPASSWD: ALL

Enable Root User Account in Ubuntu

If for some reason, you need to enable the root account, you just need to set a password for the root user . In Ubuntu and other Linux distributions, you can set or change the password of a user account with the passwd command.

As a regular user in Ubuntu, you can only change your own password. The user you are logged in as must have sudo privileges to be able to set the root password.

To enable root account in Ubuntu, run the following command:

sudo passwd root

You will be prompted to enter and confirm the new root password:

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

The password is not shown on the screen when you type it.

That’s it! You have successfully enabled the root account. You can now log in to your Ubuntu machine as user root using the new password.

 

Disable Root User Account in Ubuntu

If you previously enabled the root user in Ubuntu and now you want to disable it, set the root password to expire.

To disable the root account password, use the following command:

sudo passwd -l root

 

Conclusion

To enable the root user account in Ubuntu, all you need to do is to set the root password.

When setting the password, make sure you’re using a strong and unique password. Having a strong password is the most important aspect of the security of your account. Often a strong password has at least 16 characters, at least one uppercase letter, one lowercase letter, one number, and one special character.

Keep reading
How to Check if a String Contains a Substring in Bash
April 12, 2023

How to Check if a String Contains a Substring in Bash

How To Check If A String Contains A Substring In Bash In this article, we will show you several ways to check if a string contains a substring. One of the most common operations when working with strings in Bash is to determine whether or not a string contains another string. Using Wildcards The…

Read article
How to Check for Open Ports
April 12, 2023

How to Check for Open Ports

How To Check For Open Ports This article describes several approaches to find out what ports are opened to the outside on your Linux system. Whether you are troubleshooting network connectivity issues or configuring a firewall, one of the first things to check is what ports are actually opened on…

Read article
How to Check the Kernel Version in Linux
April 12, 2023

How to Check the Kernel Version in Linux

How To Check The Kernel Version In Linux In this tutorial, we’ll show you several different ways to find out what version of Linux kernel is running on your system. The kernel is the core component of an operating system. It manages the system’s resources, and it is a bridge between your…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00