How to change all your passwords on linux with one single command ?

If you use Linux and have your passwords written among multiple files, you might want or need to update your password from time to time for obvious security reasons. Companies generally want their employees to update their password quite frequently – or might want to do so if you think your current password might has been compromised.

The downside is that you might have to go each single file and need to update manually your passwords – otherwise some cron jobs won’t run as moving forward.

Manual update? You’re kidding, right?

Yes.

To update your password, this is super easy.

Start by opening a Terminal.

Then enter the following command line:

find . -type f -exec sed -i ‘s/myOldPassword/myNewPassword/g’ {} +

What this command will do is the following. It will go recursively through each and any folder, analyze each file and substitute in the same file – not creating any copy – your old password or old string chain to the new one.

Super easy, nope?

This is what’s really cool with Linux. If you know how to use correctly the command line, you can save an incredible amount of time doing borring and repetitive stuff. This is why we <3 softwares.

Do you have some tricks you use to manage safely your passwords?

Leave a Reply

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