Thankfully, it’s an easy process to change your password in Linux. You can change your password (or other user’s passwords) from the terminal locally or remotely, or set expiration dates to force other users to change it themselves when they next sign in. Here’s what you’ll need to do to change a user password in any Linux distribution.
Why You Should Change Your Linux Password Regularly
While a Linux-based operating system offers greater security than a typical Windows installation, that doesn’t mean it’s infallible to hackers. One of the easiest ways for someone to breach your PC is through lax security, with easy-to-crack passwords at the top of the list. Unfortunately, you should also expect that time is against you. Many of us use the same passwords for multiple accounts. If your email password is compromised, for instance, and you use the same password to sign into your Linux PC, then you’re putting your PC (and all of your saved data) at risk. That’s why it’s important to consider changing all your passwords in Linux on a regular basis, including your account passwords on Linux. A good password consists of a number of letters (both upper and lower case), numbers, and special characters. It also requires the password to be of suitable length (at least 8 characters, if not more). If you’re struggling to come up with a password you can remember, you can use a password manager to help you generate and remember it. You won’t be able to use this to fill out the login screen, but if you’re using a password manager like KeePass, you can quickly recall the password using the mobile app. However, it’s probably best (and easiest) to create a password that you can remember. Dictionary words are off the menu for this one, but where possible, you should attempt to create a memorable password that no-one else could possibly know using the steps we’ve outlined above.
How to Change Your Password in Linux
While you should be able to change passwords using your distro’s desktop environment, those steps will vary significantly. If you’re using a headless version of Linux (without a GUI), you won’t be able to use a GUI to change your password at all. That’s why the best and fastest way to change your password in Linux is to use the terminal, regardless of the Linux distribution you’re using.
Changing Other User Account Passwords in Linux
If you have superuser or root access on your Linux PC or server (for instance, if you’re a system administrator), you can change the passwords of other local users. You may want to do this if someone has forgotten their password, for instance.
How to Change the Root Password in Linux using Sudo
To help protect your system, many Linux distributions restrict normal user accounts by hiding certain access behind the root (superuser) account. When you elevate your terminal using commands like sudo su or su to grant root access, you’ll need to type the correct root password.
Setting a Password Expiry Date in Linux
By setting a built-in expiry date for passwords on your Linux PC, you don’t need to worry about manually running the passwd command on a regular basis. When the password expires, your PC will instruct you to change your password automatically.
Securing a Linux System
Linux is well known as one of the most secure operating systems available, but without a secure password in place, you’re leaving your PC vulnerable to attack. There are other ways you can secure your system further, such as maintaining a secure local network and scanning your files for viruses that could infect other PCs. You could also think about using a secure web browser to stay safe online, especially if you consider using a VPN to mask your IP address. Making efforts to protect your online privacy and security won’t stop hacking attempts, but it will add another layer of defense against it.