Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
cancel
Showing results for 
Search instead for 
Did you mean: 

cd ~homedir not working

Allanm
Super Advisor

cd ~homedir not working


For sometime now, I am unable to do -

cd ~homedir
but
cd /homedir works...

Can you suggest some pointers as to how I can troubleshoot or fix this?

Thanks,
Allan.
10 REPLIES
Allanm
Super Advisor

Re: cd ~homedir not working

Also sudo bash takes a very long time to come back to the password prompt...
Steven Schweda
Honored Contributor

Re: cd ~homedir not working

> cd ~homedir

If you want "/homedir", then say "/homedir".
The "~user_name" notation is used with a user
name. That path to that user's home
directory is obtained from the "passwd" data
base ("/etc/passwd", or wherever). Unless
there's a user name of "homedir", "~homedir"
makes no sense.

What is the user name here?

Where is that user's home directory?
Allanm
Super Advisor

Re: cd ~homedir not working

Sorry I meant cd ~user-home-dir, cd /user-home-dir works.

Also sudo bash is very slow to respond...
Steven Schweda
Honored Contributor

Re: cd ~homedir not working

> Sorry I meant cd ~user-home-dir,
> cd /user-home-dir works.

So, does that mean that you're happy, or is
there still a problem/question there?

> Also sudo bash is very slow to respond...

A different thread with "sudo" in the Subject
might get more attention from people who know
more about sudo than I.
Goran Koruga
Honored Contributor

Re: cd ~homedir not working

Hi.

Did you check which is the homedir set for your user?

getent passwd

Next to last field is homedir.

Regards,
Goran
Kapil Jha
Honored Contributor

Re: cd ~homedir not working

its ~user_id
if your user id existe and it has home dir.

have you seen some other problem or some specific thing when you not able to do this.
BR,
Kapil+
I am in this small bowl, I wane see the real world......
Matti_Kurkela
Honored Contributor

Re: cd ~homedir not working

When you execute "cd ~foo", the shell checks the home directory location of user "foo" from the user database (usually /etc/passwd, but can be NIS or LDAP too if configured) and then moves to that directory.

If the user "foo" has his home directory set as /home/bar, the command "cd ~foo" moves to /home/bar.

Since you say your "cd /homedir" works, it is probably not a home directory permission problem.

Maybe the user cannot look up the home directory location for some reason?
What are the permissions of /, /etc and /etc/passwd?

Please run:

ls -ld / /etc /etc/passwd

The response should be something like this. Note the permissions:
drwxr-xr-x 25 root root 4096 2009-10-20 13:30 /
drwxr-xr-x 162 root root 16384 2009-11-03 12:57 /etc
-rw-r--r-- 1 root root 1854 2009-10-06 15:18 /etc/passwd

MK
MK
dirk dierickx
Honored Contributor

Re: cd ~homedir not working

normally 'cd ~' will take you to your own home dir. 'cd ~userhomedir' will not work because that would translate to something like /home/user/user, which probably doesn't exist.

if you want to do 'cd ~otheruserhomedir', i'm not aware this is possible. afaik ~ always points to your own home dir and thus you should address others home dirs always as a full path.
Steven Schweda
Honored Contributor

Re: cd ~homedir not working

> [...] 'cd ~userhomedir' will not work
> because [...]

For a valid explanation of what this means,
see Matti Kurkela's response.

> [...] i'm not aware [...]

Try it?

debi# cd ~
debi# pwd
/root
debi# cd ~ftp
debi# pwd
/home/ftp

debi# grep '^ftp:' /etc/passwd
ftp:x:110:65534::/home/ftp:/bin/false

Or read about it. "man " should
provide the details.
dirk dierickx
Honored Contributor

Re: cd ~homedir not working

nice, didn't know about that one yet! is there anything unix can't do? :)