Managing and updating passwords is a fundamental task for server administrators. Whether you need to update an existing user account password, reset a colleague’s administrative credentials, or recover access to the root superuser account after losing a password, Linux provides robust command-line tools to manage system authentication.

In this comprehensive guide, we will walk you through changing and resetting user and root passwords across all major Linux distributions (Ubuntu, Debian, AlmaLinux, Rocky Linux, RHEL, and CentOS), including standard terminal methods and emergency recovery procedures if you are completely locked out of your Aveshost Linux VPS.


Prerequisites


Method 1: Change Your Own Password (Current User)

If you are currently logged into your account and wish to update your own password, use the passwd command:

passwd

Prompts Explained:

  1. Current password: Enter your existing password.
  2. New password: Enter your new strong password.
  3. Retype new password: Confirm the new password.

Note: Linux will not display asterisks or characters on the screen as you type. Simply type your password accurately and press ENTER.


Method 2: Change Any User's Password as Root or Sudo

If you are logged in as root or have sudo administrative privileges, you can change any user account’s password (or the root password itself) without needing to know the user’s old password:

1. Change Another User's Password:

# Replace 'sammy' with the desired username
sudo passwd sammy

2. Change the Root User Password:

sudo passwd root
# OR if already logged in as root:
passwd

Method 3: Emergency Root Password Reset When Locked Out

If you forgot the root password and do not have an active sudo user or SSH key access, you can reset the root password using the Aveshost VNC Web Console and the GRUB bootloader.

Step 1: Open the VNC Web Console

  1. Log in to the Aveshost Client Area (my.aveshost.com).
  2. Navigate to Services > select your VPS > click VNC / Web Console.
  3. In your VPS control panel, click Reboot (or send Ctrl + Alt + Del).

Step 2: Access GRUB and Reset Password

For Ubuntu & Debian:
  1. As the server starts booting, press and hold the Shift key (or repeatedly press Esc) to open the GRUB boot menu.
  2. Highlight the default Ubuntu kernel line and press e to edit the boot parameters.
  3. Find the line beginning with linux or linux16 (ending with ro quiet splash or ro).
  4. Change ro to rw init=/bin/bash (or append rw init=/bin/bash to the end of the line).
  5. Press Ctrl + X or F10 to boot into a root bash prompt.
  6. Reset the root password:
    passwd root
  7. Reboot the system normally:
    exec /sbin/init
For AlmaLinux, Rocky Linux, RHEL & CentOS:
  1. At the GRUB boot screen, press e on the top kernel.
  2. Find the line starting with linux (or linux16), move to the end of the line, and append rd.break.
  3. Press Ctrl + X to boot into emergency mode.
  4. Remount the sysroot file system in read-write mode:
    mount -o remount,rw /sysroot
    chroot /sysroot
    passwd root
  5. Enter and confirm your new root password.
  6. CRITICAL (SELinux Relabeling): Create the autorelabel trigger file so SELinux accepts the new password context upon reboot:
    touch /.autorelabel
    exit
    exit
  7. The server will automatically relabel SELinux contexts and reboot into your system.

Method 4: Force a User to Change Password on Next Login

If you are onboarding new team members or resetting a compromised account, you can force the user to choose a new password immediately upon their next SSH login:

sudo passwd -e username
# OR using the chage utility:
sudo chage -d 0 username

Security Best Practices for Linux VPS Passwords

  • Use Strong Passwords: Passwords should contain at least 16 characters, including uppercase letters, lowercase letters, numbers, and symbols.
  • Disable Root Password SSH Login: Restrict direct root login and switch to cryptographic SSH Keys (see our guide on How to Set Up SSH Keys on Linux VPS).
  • Install Fail2ban: Protect SSH and user accounts from automated brute-force attacks by banning repeated failed login attempts.

Frequently Asked Questions & Troubleshooting

Q: Why do I get "Authentication token manipulation error" when running passwd?
A: This error typically occurs when the filesystem is mounted in read-only mode, the disk is 100% full, or file permissions on /etc/shadow or /etc/passwd are incorrect. Check disk space with df -h and remount with mount -o remount,rw /.

Q: Why does AlmaLinux / Rocky Linux hang after resetting root password in GRUB?
A: If you forgot to run touch /.autorelabel before rebooting, SELinux blocks authentication. Boot back into rd.break, execute touch /sysroot/.autorelabel, and reboot.


Need Further Assistance?

If you are unable to access your Linux VPS or need assistance resetting root credentials, our technical support team is available 24/7. Feel free to submit a support ticket through your client area for prompt assistance.

Kas see vastus oli kasulik? 0 Kasutajad peavad seda kasulikuks (0 Hääled)