Changing PWD in Linux?
PWD could mean three things in Linux, so first confirm what you’re trying to achieve here.
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:
So this above shows that I’m in my home directory, /home/greys at the moment.
You can change what pwd returns by moving into another directory using cd command:
now if we run pwd again, it will show that our current directory (pwd) is /tmp:
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
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:
But with sudo privilege it works just fine: