Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I symlinked my /host/Users/Kevin folder to /home/Kevin. I also edit the /etc/passwd file to /home/Kevin. I logged out and logged back in, however when I open up a terminal it's a bash prompt like so:

kevin@ubuntu:/host/Users/Kevin$

But when I cd or echo $HOME it changes to:

kevin@ubuntu:~$

or when I echo $HOME it prints /home/Kevin. How can I make it open up in this format by default?

share|improve this question

migrated from stackoverflow.com Apr 26 '12 at 18:19

This question came from our site for professional and enthusiast programmers.

    
IIRC this is a limitation of bash, zsh is more clever when the home directory is a symlink. Consider switching to zsh. –  Gilles Apr 26 '12 at 23:05

2 Answers 2

up vote 1 down vote accepted

You could put:

cd $HOME

in your .bash_profile, maybe, or your .bashrc (the latter executes for every shell, the former only for your login shell). The problem, of course, is that anything that walks the filesystem to find your current directory location is going to find /host/Users/Kevin folder to /home/Kevin instead of /home/Kevin.

Instead of symlinking, you could:

mkdir /home/Kevin
mount -o bind /host/Users/Kevin /home/Kevin

This will make /home/Kevin a "real" filesystem path (as opposed to one you get to by way of a symlink). You can add this mount to your /etc/fstab if you like.

share|improve this answer
1  
Don't put it in .bashrc, it would be disruptive when you start a shell in another directory. –  Gilles Apr 26 '12 at 23:04
    
Maybe. I mentioned that as a possibility because sometimes things are configured (e.g., under X or in OS X terminal) such that putting it into .profile or equivalent won't do the right thing, and I'm too lazy to test it out... –  larsks Apr 26 '12 at 23:25

Do I understand you correct that you always want it printed like:

kevin@ubuntu:/host/Users/Kevin$

that's simple: edit the file .bashrc in your home-directory. usually you'll find a line like this (or maybe more then one):

PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

replace the \w with $PWD and save.

share|improve this answer
    
I want it always printed out like: kevin@ubuntu:~$ –  user979663 Apr 26 '12 at 17:26
    
- sorry, wasn't really clear from your question which format you really want. in this case, larsks answer is better. –  mata Apr 26 '12 at 17:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.