Skip to content

NetworkHunt

  • EVE-NG
  • How to
    • Linux
      • Debian
      • Kali Linux
      • Ubuntu
    • Eve-ng
  • Interview Questions
  • Kali Linux
  • Debian
  • Kali Linux
  • Debian

How to Change the Root Password in Debian?

Changing the root password on your Debian system is a fundamental administrative task for the security and management of your server. This post will help you change the root password on Debian using various methods.

Table of Contents
  1. What is a Root User in Debian?
  2. How to Change Root Password on Debian?
    • Method 1: Changing the Root Password Using passwd
    • Method 2: Changing the Root Password Using su
    • Method 3: Resetting the Root Password in Single-User Mode
  3. Security Considerations

What is a Root User in Debian?

In Debian, the root user is the superuser account with unrestricted access to all system commands and files. By default, during the installation of Debian, if the root password is not set, then the root account is locked, and the initial user is granted administrative privileges through the sudo command. This setup enhances security by minimizing direct root access.


How to Change the Root Password on Debian:

Method 1: Changing the Root Password Using passwd

If you have access to a user account with sudo privileges, you can change the root password using the passwd command.

1. Open the Terminal or Connect via SSH:

After Logging in to the System, use the Keyboard Shortcut below to Open a Terminal Window:

Ctrl+Alt+T

To connect via SSH, use the command below:

$> ssh [username]@[System IP]

$> ssh network@10.10.1.54

Replace [username] and [System IP] with username of the User with Sudo Privileges, and IP Address of the System, respectively

2. Execute the passwd Command:

If you’re logged in as a user with sudo privileges, use:

$> sudo passwd root 

If you’re logged in as the root user, then use:

$> passwd
3. Set the New Password:

After running the passwd command you will be prompted to enter and confirm the new password for the root user. Ensure to choose a strong password that combines Uppercase and Lowercase Letters, Numbers, and Special Characters.

change password using sudo

Method 2: Changing the Root Password Using su -

If you know the current root password, you can switch to the root user and change the password.

1. Open the Terminal or Connect via SSH:

After Logging in to the System, use the Keyboard Shortcut below to Open a Terminal Window:

Ctrl+Alt+T

To connect via SSH, use the command below:
$> ssh [username]@[System IP]

$> ssh network@10.10.1.54

Replace [username] and [System IP] with username of the User with Sudo Privileges, and IP Address of the System, respectivelyt via SSH: Log in to your Debian system.

2. Switch to the Root User:

Use the command below to Switch to Root user:

$> su -

You will be prompted to enter the current root password.

3. Change the Password:

Once switched to the root user, use the command below to change password:

$> passwd 

Then, enter and confirm the new root password as prompted.

change root password using su

Method 3: Resetting the Root Password in Single-User Mode

If you’ve forgotten the root password, you can reset it by booting into single-user mode.

1. Reboot the System:

Restart your Debian system, using:

$> sudo reboot
2. Access the GRUB Menu:

During boot, press and hold down the Shift key (If, a BIOS systems) or press ‘Esc’ (If, a UEFI systems) to access the GRUB menu.

3. Edit the GRUB Entry:
  1. Use arrow keys to highlight the Debian entry and press ‘E’ to edit.
  2. Find the line starting with Linux and append ‘init=/bin/bash‘ at the end of it.
4. Boot into Single-User Mode:

Press ‘Ctrl+X’ or ‘F10’ to boot the system. Now, the system will boot into Single-User Mode

5. Remount the Filesystem with Write Permissions:

Once the system boots, Use the command below to remount the root filesystem with read and write permissions:

$> mount -o remount,rw /
4. Reset the Root Password:

Now use the command below to reset the Root Password:

$> passwd

Enter and confirm the new root password as prompted.

5. Remount the filesystem with Read-only Permissions:

Use the command below to remount the filesystem with Read-only Permissions:

$> mount -o remount,ro / 

$> exec /sbin/init
6. Reboot the System:

Restart your Debian system, using:

$> sudo reboot

Security Considerations

  • Disable Root Login via SSH: To enhance security, it’s advisable to disable root login over SSH. To learn how to disable root login via SSH, visit here[LINK].
  • Regularly Update Passwords: Periodically updating your passwords reduces the risk of unauthorized access.
  • Use Strong Passwords: Ensure all administrative passwords are strong and not easily guessable.

Categories Debian, How to, Linux, Networkhunt
What are System Locales and How to manage them in Linux?
How to Change Date, time and Timezone in Ubuntu linux.

Linux Related Posts

  • How to install PIP on Debian?
  • How to generate SSH key with SSH Keygen in Linux
  • How to Change User Password on Debian?
  • How to run TCP Traceroute in Centos Linux
  • How to Save the Output of a Command in a File, in Linux?
  • How to Install Nano Text Editor in Linux
  • How to Select All in Nano Text Editor
  • How To Create and View Hidden Files in Linux
  • How to Create a Password Protected ZIP File in Linux
  • How to Open a Linux Terminal
  • How to check how many CPUs in a Linux System
  • How to Customize Linux Terminal: Themes and Plugins
  • What are System Locales and How to manage them in Linux?
  • How to setup Monitor Mode for Wi-fi Interface in Linux
  • How to Disable Swap on Linux
  • How to Add Repositories in Linux
  • How to Show Line Numbers in Nano Text Editor in Linux
  • How to Add or Delete Users in Debian?
  • How to Change the Default Shell in Linux
  • How to Find in Nano text Editor in Linux

Table of Contents
  • What is a Root User in Debian?
  • How to Change the Root Password on Debian:
    • Method 1: Changing the Root Password Using passwd
    • Method 2: Changing the Root Password Using su -
    • Method 3: Resetting the Root Password in Single-User Mode
  • Security Considerations

© 2021 Networkhunt.com
Go to mobile version