PWD could mean three things in Linux, so first confirm what you’re trying to achieve here.
pwd - current working directory
If you just type pwd in your command line prompt, it will confirm your present current directory - the place in the filesystem hierarchy you’re currently at:
now if we run pwd again, it will show that our current directory (pwd) is /tmp:
PWD - shell variable
Similar to the pwd command, PWD is a standard shell variable reporting your current home directory.
It’s not meant to be changed directly - supplying new value will not magically move you into new filesystem location. Rather, your current shell will track your commands and keep this variable updated to reflect where you are in the filesystem.
If you’re looking to change a password for a given user in Linux, that’s easy!
For your own user, you just type passwd, supply your current password and then provide new password, like this:
[email protected]:~ $ passwd greys
Changing password for greys.
Current password:
New password:
Retype new password:
passwd: password updated successfully
You will need to have sudo privilege or be root user in order to change someone else’s password.
If you just attempt changing another user’s password, you’ll get an error:
[email protected]:~ $ passwd someone
passwd: You may not view or modify password information for someone.
I learn with Educative:
I'm also a fan of SetApp for macOS:
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!