Linux

How to Change Sudo or Root Password in Ubuntu?

Introduction

In Ubuntu, your superuser or “root” account holds powerful privileges. The sudo (superuser do) password allows regular users to execute administrative tasks without directly logging into the root account. However, for both security and account management, changing the sudo or root password regularly is crucial. In this guide, we’ll walk you through step-by-step instructions on how to change your sudo password and reset the root password on Ubuntu, whether you’re managing your personal system, a server, or even a Steam Deck device.

The Importance of Changing Passwords Regularly

The Importance of Changing Passwords Regularly

Passwords serve as the first line of defense in any system’s security. For accounts with root or superuser access, keeping passwords updated is even more critical because these accounts have unrestricted access to system settings, user data, and administrative functions. Failing to update your Ubuntu root password or sudo password can leave your system vulnerable to unauthorized access, particularly if the password has been compromised through phishing or other attacks.

Regularly updating the Ubuntu sudo password and root password minimizes risks by protecting against brute-force attempts, where attackers try countless password combinations to gain access. Updated passwords also guard against vulnerabilities that may arise when password databases are leaked online, where attackers might attempt to reuse passwords across different platforms. If you’re managing a server, this is even more critical as servers are frequent targets of cyber-attacks.

Additionally, rotating passwords regularly fosters good security habits. This practice forces administrators to remain vigilant and mindful of security. When using Ubuntu on public networks or when granting temporary access to others, consider a password change afterward as a best practice. Taking the time to routinely update passwords is a simple yet effective way to protect against evolving threats and prevent unauthorized control of your system.

How to Change Root Password in Ubuntu

How to Change Root Password in Ubuntu

In Ubuntu, the root password is usually disabled by default to encourage users to perform administrative tasks via the sudo command instead. This default setup minimizes the risk of unintentional changes by requiring users to re-authenticate for privileged commands. However, if you have enabled the root account and need to change the root password in Ubuntu, you can do so with just a few simple steps.

Here’s how to perform a root password change in Ubuntu:

1. Open the Terminal: Press Ctrl + Alt + T to open a terminal window.

2. Switch to Root User: To access root privileges, enter:

sudo -i

This command switches you to root mode, enabling you to run commands with root-level access.

3. Change the Root Password: Now, use the following command:

passwd

The system will prompt you to enter a new password and confirm it. Make sure to choose a robust password to intensify security.

4. Exit Root Mode: Once the password is successfully updated, type:

exit

This command exits the root mode, returning you to your standard user privileges.

Updating the root password on Ubuntu provides immediate security improvements. It guarantees that only authorized users are able to access sensitive commands and prevents unauthorized control of system files. This is especially important on Ubuntu servers and shared systems where multiple users may have access to various levels of permissions. 

How to disable your root account on Ubuntu

How to disable your root account on Ubuntu

Disabling the root account in Ubuntu improves security by preventing any direct login as root. This makes your system less vulnerable to attacks that target root accounts directly.

To disable the root account:

1. Open Terminal and type:

sudo passwd -l root

The -l option locks the root account, effectively preventing login.

2. To re-enable the account, simply use:

sudo passwd -u root

This ensures that while you can perform administrative tasks with sudo, no one can directly access the root account.

How to Modify Sudo Password in Ubuntu

The sudo password is connected to your user account password, enabling you to gain elevated privileges temporarily. This allows you to perform administrative actions without logging in as the root user directly. Since the sudo password is integral to accessing restricted features and settings, updating it periodically helps maintain system security.

Ubuntu offers two primary methods for changing your sudo password: through the command line and via the graphical interface (GUI). Every approach is simple, so you can opt for whichever syncs your preference or skill level.

Method 1: Modify Sudo Password through Command Line

The command line offers a quick, direct way to change your Ubuntu sudo password. Here’s how to perform a sudo password change using this method:

  1. Open Terminal: Press Ctrl + Alt + T to launch a terminal window.

Run the Password Change Command: Type the following command:

passwd
  1. Press Enter after typing the command. This command updates the password for your current user account, which in turn updates the sudo password since the two are linked.
  2. Authenticate with Your Current Password: You’ll be prompted to input your existing password. This step guarantees that only authorized users are able to alter the sudo password.
  3. Set the New Password: After entering the current password, you’ll be asked to enter a new password twice for confirmation. Assure to use a resilient, unique password.

Once complete, your Ubuntu sudo password is immediately updated. This method is efficient, secure, and doesn’t require leaving the terminal. The change takes effect instantly, allowing you to continue using sudo commands with your new password right away.

Method 2: Change Sudo Password via GUI

If you desire not to employ the command line, you can also update your sudo password through Ubuntu’s graphical user interface (GUI). This option may feel more accessible for users who are more familiar with a visual interface.

  1. Access the Settings Menu: Click on the system menu in the upper-right corner of your screen and select Settings.
  2. Navigate to User Settings: In the Settings window, locate and select the Users section on the left sidebar. This area displays all users on your system.
  3. Select Your Account: Choose your user account to access the account options. Assure that you opt for the apt account, as the sudo password is specific to each user.
  4. Click “Change Password”: Once you’ve opened your account settings, look for the Change Password choice. Click it to start the password upgrade method.
  5. Follow the Prompts: Input your existing password when asked for, then type your new password twice to confirm. The system will indicate if your new password aligns with the protection necessities.

This GUI method provides a user-friendly way to change the sudo password in Ubuntu, making it ideal for those who may be unfamiliar with the terminal. The Ubuntu sudo password change is immediate, ensuring that your system’s security is promptly enhanced without requiring any technical know-how.

Also Read: How to Use sudo Command in Linux with Examples

Conclusion

Understanding how to change both the root and sudo passwords in Ubuntu is an essential skill for managing your system securely. This information is critical for both private as well as professional users, especially those managing sensitive data or Ubuntu servers. Regular password updates provide an added layer of security by reducing the risk of unauthorized access, which is particularly important for Ubuntu root user passwords and superuser passwords.

For personal systems, keeping passwords updated can protect against potential attacks that exploit weak or outdated credentials. In server environments or shared systems, frequent sudo password changes help to safeguard not only individual accounts but the entire network from brute-force attacks, credential leaks, or internal threats. This is also relevant for newer devices like the Steam Deck, which runs on Linux and benefits from regular sudo password updates to protect access to its advanced settings and configurations.

By following these password update steps, you’re actively enhancing your system’s security. This practice ensures that your access credentials remain up to date and minimizes the risk of disruption due to unauthorized changes or lockouts. Practicing these updates regularly supports secure, uninterrupted access to your Ubuntu environment, empowering you to manage your system effectively and confidently, regardless of the device or application.

Arpit Saini

He is the Chief Technology Officer at Hostbillo Hosting Solution and also follows a passion to break complex tech topics into practical and easy-to-understand articles. He loves to write about Web Hosting, Software, Virtualization, Cloud Computing, and much more.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

[sc name="footer"][/sc]