How to change a password in Linux

Passwords are the first line of defense when protecting any system, including Linux. is a good alternative but, at the end of the day, a strong password is the best option to secure your . This alternative allows the security of your system to be much more reliable. In this tutorial, you will learn how to change a password in Linux on any distribution, including Ubuntu, Debian, and CentOs.

We will show you how to change your server password using Bash. We will also teach you how to change it for other users on your VPS. This is ideal if you’re trying to learn the skill set of a sysadmin.

How to change a password in Linux?

To change a password you only need to know one command. First, access your VPS through SSH. Do you have problems to do it? Look at our . Then, to change the password on Linux, you need to open the terminal and type the following command:

sudo passwd

After running the command, you will be prompted to enter the new password twice. In this case, when you don’t specify a user, you will be changing the root password. The screen should look like this:

Enter new UNIX password: Retype new UNIX password:

If you change the password successfully, the command line will show something like this:

passwd: password updated successfully

This means that your new password is set and your old password no longer exists.

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 will need to use the command passwd one more time.

See also  The surprising story of the first website

First, login as root user, type passwd and then the username whose password you want to change. The command will look like this on the command line:

passwd username

As an example, let’s say we want to change the password of the user named Edward. The command line will look like this

passwd edward

Next, we will be asked to enter the new password twice.

Enter new UNIX password: Retype new UNIX password:

And just like that, you have updated a different old user password to a new password, using the command passwd.

Passwords and Linux

It is considered one of the safest systems in the world, due to the way processes are handled. However, every operating system relies at some point on the use of passwords. Linux handles these passwords in much the same way as other systems. However, it is necessary to know two important directories in password management.

The first of these files is /etc/passwd, where we can find all the users of the system. In addition, it shows which system group they belong to. We may see many users, but only a few will be able to log in as system users.

If you want to see the content of /etc/passwdyou can do it with the following command:

cat /etc/passwd

The second Linux file that is closely related to passwords is /etc/shadow. In the shadow file, we will be able to see the encrypted passwords of the users and if they have one, as well as other related information.

See also  How to fix "Error establishing a database connection" in WordPress

cat /etc/shadow

How to create a strong password

Finally, we recommend that you establish strong passwords so that no one can guess or force them. It is suggested that you choose a password that is unique, long and prevents the use of personal information.

To create or change a unique password, use a different password for each of your important accounts, like bank accounts and email accounts. Try not to reuse your old passwords.

Remember that you should not use personal information in your password. Avoid nicknames, initials, pet names, or old addresses.

If you suspect that your password has been compromised, change it as soon as possible. It is recommended to do this frequently.

conclusion

Changing a password in Linux is important for the security of your project. The process is very simple, and we recommend doing it frequently for maximum security. Stay safe, better safe than sorry!

Deyi is a digital marketing enthusiast, with a background in web design, content creation, copywriting, and SEO. She is part of ‘s SEO & Localization team. In her free time, she likes to develop projects, read a book or watch a good movie.

Loading Facebook Comments ...
Loading Disqus Comments ...