16th May 2024

How to Change Password in Linux?

Passwords are the first line of defence in any system’s protection. Passwordless SSH is a reliable alternative, but at the end of the day, a strong password is a great option. Having a strong password will also make your system extremely secure. In this guide, you will learn how to change a password in Linux.

We will also see how to change passwords for other users on your VPS. If you want to be a system administrator, it would be useful to learn this.

Passwords and Linux

Linux is seen as one of the most powerful operating systems in the world due to the way transactions are made. However, all operating systems require the use of passwords at some point. Linux handles passwords quite similar to other systems. However, it is important to know two important directories in password management.

The first one is the / etc / passwd directory where you can find all users on the system. In addition, it shows which group of the system users belong to. It is possible to see a large number of users, but only a few will be able to log in as they are system users.

If you want to see the contents of the / etc / passwd directory, you can do so with the following command:

sudo cat /etc/passwd
cat /etc/passwd
cat /etc/passwd

 

The second Linux directory that is related to passwords is / etc / shadow. In the shadow file, you can see the users’ encrypted passwords and whether they have the SSH key.

sudo cat /etc/shadow
sudo cat /etc/shadow
sudo cat /etc/shadow

 

Finally, if you have strong passwords, nobody will be able to guess your passwords or resort to brute force. However, if you think your passwords are compromised, you can change them. It is recommended to do this often!

LEARN MORE  How to Make Troubleshooting on Linux Servers?

How to Change Password in Linux?

You only need to know one command to change your Unix password! This is the same even if you are a normal user. First, access your VPS over SSH. Then, to change your password in Linux, you need to open the terminal and enter the following command:

sudo passwd
sudo passwd
sudo passwd

 

After running the command, you will be asked to enter the new password twice. In this case, you will have changed the root password because you did not specify a user.

How to Change a Password in Linux for Another User?

It is also possible to change the password of another user on the same system. To do this, you must be logged in as root user and add the username to the passwd command. Again, you will be asked to enter the password twice. If it’s an example command on the command line, it would be like this:

passwd username

In this example, we will change the password of the user named omer.

passwd omer
passwd omer
passwd omer

 

As we can see the password has been successfully changed!

Result

Linux password change process is important for the security of your project. The process is very simple and we recommend repeating this process frequently for maximum security.

Leave a Reply

Your email address will not be published. Required fields are marked *