bash prompt change after user default directory change

0

There is something I am not understanding. I have used the method found here about changing user default directory using vipw /etc/passwd

However once I go into this file and change a user default dir setting their bash prompt changes to, from my machine from ex. "[root@directory ~]#" to "bash-4.1$"

Now if I try to change the global bash prompt $PS1 the user with change dir having bash-4.1$ cannot see the custom prompt.

What is this behavior?

Guy St-Louis

Posted 2015-10-17T21:59:55.117

Reputation: 39

I believe you are mistaken about what the directory named in /etc/passwd actually is. It's the user's home directory; it's not a "default directory", except by convention and extension because it's a directory that is supposedly writable by the user, and relatively private. (Remember Linux is a multi-user system by design.) If the named home directory doesn't exist, or if it does exist but the permissions don't grant the user read/write/execute permissions, all sorts of things will break. I have a strong feeling you are seeing one of those things breaking. – a CVn – 2015-10-17T22:05:30.100

@MichaelKjörling Thanks for the reply. Actually you're right, when I changed the directory, whatever I changed it to I realized that there were permission problems. So this means only because there was a permission problem, or whatever else it could be, this is why I'm seeing this weird bash-4.1? obviously I won't be lazy and test this but since I'm typing away here... – Guy St-Louis – 2015-10-17T22:15:27.860

@GuySt-Louis It is indeed a permission problem. The prompt changes because bash can not find a readable .bash_profile or the like (which is normally located in your home directory as dictated by /etc/passwd from which it can read your prompt settings, so it reverts to defaults. – Jarmund – 2015-10-17T23:18:05.217

Answers

1

You changed your home directory, but you probably left the files in the old directory.

When bash is invoked it reads and executes some files, some of them in your home directory (for example ~/.profile).

Since you changed your home directory it doesn't find them. So any configurations you find in those files (like your prompt) won't get applied to your bash.

Thomas Weinbrenner

Posted 2015-10-17T21:59:55.117

Reputation: 735

ill take a look at this too – Guy St-Louis – 2015-10-17T22:16:55.043

do you know all the files that need to be transferred over to resolve this issue? – Guy St-Louis – 2015-10-18T21:38:46.643

Sorry, I am not a bash user and I use another OS. Your bash manpage should have a list of files it uses (probably near the end of the manpage). Also like inside those files - maybe those files call other files. – Thomas Weinbrenner – 2015-10-18T21:44:12.560