- How to change a Linux password
- The passwd command in Ubuntu
- Change your own Linux password
- Change a Linux password for one user
- Force Linux password change at next log in
- Related articles
- All important Linux commands
- How to get your Linux IP address in different ways
- The best Linux Server distributions in an overview
- The best Linux distributions (operating systems)
- How to Change or Set User Password in Linux
- Changing a User Password in Linux
- Managing Linux Users with the passwd Command
- Remove User Password in Linux
- Lock User Password in Linux
- Unlock User Password in Linux
- Force User to Change Password in Linux
- How to Change a User’s Password in Linux
- Method 1: Change the Password via GUI
- Method 2: Change the Password via Linux Command Line
- Change Your Own Password
- Change the Password for Another User
- Change the Sudo Password
- Conclusion
- About the author
- Karim Buzdar
How to change a Linux password
To best manage your own user account or the accounts of other users, it is helpful to know the most important utilities of Linux. This includes passwd, which you can use to change your Linux password, among other things. You can learn the individual steps here.
The passwd command in Ubuntu
The passwd program package, which allows you to easily change your own password or the passwords of an entire group, as well as set other commands, is included in most Linux installations. Our guide refers to the Ubuntu installations — Ubuntu is one of the most versatile, free distributions of Linux with long-term support and biannual updates.
If you are not sure which Linux distribution or version you are using, see our article on how to display your Linux version.
Change your own Linux password
If you want to change your own Linux password, this is a relatively straightforward process.
- Open the Linux terminal. This is where you normally enter commands.
- Now type the command “passwd”. This is how you tell the system that you want to change your Linux password.
- Depending on the version, you may be prompted to enter your old password. In response, simply enter your new password and confirm it again.
- If you now try to log into the system, the new password will be valid.
$ passwd Enter a new UNIX password: Re-enter the new UNIX password: passwd: Password successfully changed $
Changing passwords regularly was once one of the top recommendations for keeping safe online. However, this long-standing advice has been withdrawn, as changing passwords frequently can weaken security. Therefore, it is advisable to only change a password if the password is considered “compromised” or too weak.
Change a Linux password for one user
If you want to change the password of another user, then you need the root privileges. This means that you are the only user of the computer who has unlimited rights to all system files and resources. Keep your password ready for this reason.
- To change a user password, access the terminal and type “sudo passwd ”.
- Follow the steps in the previous example: enter new password and confirm by typing it again.
- If the password is set, the respective user must use the new password at the next login.
$ sudo passwd username Enter a new UNIX password: Re-enter the new UNIX password: passwd: Password successfully changed $
Force Linux password change at next log in
Sometimes a system administrator needs a user to change their password immediately. This can be for various reasons. There may be a user change for an account, or a password may have fallen into the wrong hands. In this case, enter the following syntax as an administrator: “-e passwd ”. Here, “-e” stands for “expire” and causes the respective password to expire immediately, so that the affected user must set up a new password the next time they log in.
We have collected the most important Linux commands for you in our article.
Related articles
All important Linux commands
Under Linux, all actions that you can carry out with the mouse and window system via the graphical user interface can also be performed using program calls in the terminal – provided you know the appropriate command and how to use it according to the correct syntax. To make working in the terminal easier, we provide you with an overview of basic Linux commands with detailed descriptions and…
How to get your Linux IP address in different ways
If you want to check your IP address in Linux, you have a couple of options. In addition to the graphical route via the settings, you can also use commands to get the information you’re looking for. Here, we’ll introduce you to some of these commands, like “ifconfig”, the equivalent of the “ipconfig” Windows command in Linux.
The best Linux Server distributions in an overview
There are several Linux distributions available for a variety of needs thanks to the open source feature and the dedicated communities. In our overview, we’ll highlight the best providers, explain their advantages and disadvantages, and outline which operating systems are best suited for servers, desktops, or other uses.
The best Linux distributions (operating systems)
It can be difficult to keep track of all the Linux distributions available. Whether you are looking to switch your business to Linux or are simply curious about Linux and in the market for a new operating system, our article shows you the top distributions and discusses their different purposes. Read on to find out more.
How to Change or Set User Password in Linux
As a regular user, you have a password that safeguards your account, and this account contains all your personal settings and files and therefore requires important protection.
Hence, it is a good practice to change your password consistently to decrease the possibility that someone else gets to recognize your password and can use your credentials to authenticate.
When changing a user password, make sure it meets the following minimal requirements:
- A password must be strong: at least six or eight characters or more is better.
- Make sure to use complex passwords by mixing letters, numbers, and other characters to make the password as hard to guess as possible.
- Use upper and lowercase letters to make the password harder to crack by an attacker.
- Make sure to avoid using any dictionary word as a password, because attackers use a brute-force password cracker to scan the whole contents of a dictionary, and if your password is in the dictionary, they can easily crack it.
Changing a User Password in Linux
Changing a user password is not that hard, just use the passwd command to change the password of your own account (it could be a root user or regular user).
Now, you need to enter your old password, as this is to prevent others from changing your password. Next, you need to enter the new password twice and make sure that your password meets the complexity rules as explained above; else, it will not be changed.
If you are logged in as a root user, you can change the password of other system users by typing the passwd command followed by the name of the user whose password you want to change.
It won’t prompt you for the old password, since you are logged in as a root user, you should be able to change the user’s passwords without knowing the old password.
Managing Linux Users with the passwd Command
There are other useful options that you can use while changing a user’s password and they are:
Remove User Password in Linux
Use the -d argument to remove the password for the specified user account.
Lock User Password in Linux
Use the -l argument to lock the password for a user account if it is not used for a given period of time.
Unlock User Password in Linux
Use the -u argument to unlock the user password that has been locked with -l option.
Force User to Change Password in Linux
Use the -e argument to force the user to change the password during the next login attempt.
The passwd command is pretty useful to manage system users on your Linux system. It manipulates the user entries in the /etc/passwd file, and the system administrator must have this as a toolkit.
How to Change a User’s Password in Linux
We use the passwd command in Linux to change a user password with ease. This command replaces an old authentication token/password for a user with a new one and it is stored in Linux system’s /etc/shadow file.
Today, we will explore the two methods to change the password in a Linux system. One method follows the change of password via Graphical User Interface (GUI) and the other method involves using the Linux commands that are executed on Linux command line OR Terminal to change the password.
Method 1: Change the Password via GUI
Let’s begin by first exploring how to change a user’s password in Linux via GUI. On the top right of the screen, locate the icons of the battery and other settings. Click on it. A window will open as shown in the following:
Next, click on the Settings and go to the Users option that is available on the left panel.
As you can see, the password option is available at the center of the screen. Click this option to change the user’s password. Now, enter the current password and then a new password. Choose a password that is strong to keep your system secure against brute force attack.
This is how we change a password via GUI. So simple!
Method 2: Change the Password via Linux Command Line
Some users are more comfortable with the command line rather than the GUI. This section is for those people!
Let’s see how a password is changed via Linux command line or Terminal.
Change Your Own Password
First, we will see how a user can change his own password. For that, the passwd command is used followed by the username as shown in the following:
Here, the user is azifa and we are changing azifa’s password.
First, the user is prompted to provide the current password. Once it is accepted, the user gives the new password.
Change the Password for Another User
What if another user’s password must be changed, how is that going to happen? Well, it’s also as simple as changing your own password. The only difference is that the system administrator can only change another user’s password.
In this case, we use the previous command but with sudo:
Sudo allows an access as a super user after accepting the password for sudo. After that, you will be prompted to change the password for the mentioned user.
Example:
Change the Sudo Password
To change the sudo password, you need as a super user. To do that, execute this command and then provide a sudo password:
Once you get the root access after providing the sudo password, execute the passwd command followed by the username to change the password:
You can also directly use the passwd command with sudo. First, you will be prompted to enter the sudo password. Once accepted, you can change the root password as we did before.
This is how we use the Linux command line to change the password.
Conclusion
Today, we explored the different ways where we can change the password in a Linux system. Some users are more comfortable with the Linux command line. However, some like to interact with GUI more than the Linux terminal. We provided a detailed guide to change the password for both types of Linux users. The guide is supported by different examples that will help you learn.
We hope you liked the tutorial.
About the author
Karim Buzdar
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.