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
- An active Linux VPS running Ubuntu, Debian, AlmaLinux, Rocky Linux, RHEL, or CentOS.
- SSH access or access to the VNC / Web Console in your Aveshost Client Area dashboard (see How to Log in and Access Linux VPS via SSH).
- Root or
sudoadministrative privileges (see How to Create a Sudo User on Linux VPS).
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:
Current password:Enter your existing password.New password:Enter your new strong password.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
- Log in to the Aveshost Client Area (my.aveshost.com).
- Navigate to Services > select your VPS > click VNC / Web Console.
- In your VPS control panel, click Reboot (or send
Ctrl + Alt + Del).
Step 2: Access GRUB and Reset Password
For Ubuntu & Debian:
- As the server starts booting, press and hold the
Shiftkey (or repeatedly pressEsc) to open the GRUB boot menu. - Highlight the default Ubuntu kernel line and press
eto edit the boot parameters. - Find the line beginning with
linuxorlinux16(ending withro quiet splashorro). - Change
rotorw init=/bin/bash(or appendrw init=/bin/bashto the end of the line). - Press
Ctrl + XorF10to boot into a root bash prompt. - Reset the root password:
passwd root - Reboot the system normally:
exec /sbin/init
For AlmaLinux, Rocky Linux, RHEL & CentOS:
- At the GRUB boot screen, press
eon the top kernel. - Find the line starting with
linux(orlinux16), move to the end of the line, and appendrd.break. - Press
Ctrl + Xto boot into emergency mode. - Remount the sysroot file system in read-write mode:
mount -o remount,rw /sysroot chroot /sysroot passwd root - Enter and confirm your new root password.
- CRITICAL (SELinux Relabeling): Create the autorelabel trigger file so SELinux accepts the new password context upon reboot:
touch /.autorelabel exit exit - 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.