1843400 Members
3282 Online
110215 Solutions
New Discussion

cd to home dir. fails

 
sai_2
Occasional Advisor

cd to home dir. fails

Hi:

On the 11.0 box when i do a cd ~username it does not take me to the home directory. It says sh: ~username : not found. But if i type cd /home/username it gets there. The other box is able to do it. Curious why??

Thanks
Sai.
10 REPLIES 10
Helen French
Honored Contributor

Re: cd to home dir. fails

Hi,

Did you check the $HOME value by running 'env' ? What is the home directory setup in /etc/passwd ? what will happen if you do just 'cd' ?

It is not required to post the same question in different categories.

HTH,
Shiju
Life is a promise, fulfill it!
Rusty Sapper
Frequent Advisor

Re: cd to home dir. fails

Sounds like the the home directory entry in the /etc/passwd is wrong or not there for that user. Better check that first.




-Rusty
Rusty Sapper
Frequent Advisor

Re: cd to home dir. fails

the only time I've seen that particular message is when the user didn't exist on that box, or there was a typo with the username.

-Rusty
sai_2
Occasional Advisor

Re: cd to home dir. fails

Hi:

cd as root puts me in / dir. But it does not work for the users' home directories when i am root.I am not able to type cd ~username as root. But as the user i am able to.

Thanks
Sai.
Helen French
Honored Contributor

Re: cd to home dir. fails

Hi,

Did you check the entry in /etc/passwd ? Is that directory exists ?

Is this happens to only root ?

HTH,
Shiju
Life is a promise, fulfill it!
sai_2
Occasional Advisor

Re: cd to home dir. fails

YES. It happens only to root.

Thanks
Sai.
Mark Greene_1
Honored Contributor

Re: cd to home dir. fails

if you are su'ing to root without the "-", i.e. doing "su" instead if "su -" then this is indeed the behaviour I would expect to see.

HTH
mark
the future will be a lot like now, only later
Helen French
Honored Contributor

Re: cd to home dir. fails

Hi,

Check the 'env' varibales and alias set for root. Check the .profile file too for any mismatches.

HTH,
Shiju
Life is a promise, fulfill it!
Frank Slootweg
Honored Contributor

Re: cd to home dir. fails

There are two more things I can think of:

- For some reason the "~" character is not recognized (for *root*), This could be a stty(1) setting. "stty -a" (as root) should reveal this.

- The shell is not a POSIX shell, but a (very old) Bourne shell. On the other hand, I would expect the Bourne shell to give "~username: bad directory", not "sh: ~username: not found.".
Steve Steel
Honored Contributor

Re: cd to home dir. fails

Hi

You should add the latest shell patches


The ksh patch which is what I guess you are using includes

4. Using "~user" to refer to user's home directory fails for users in NSS, NIS+ or LDAP.


Patch Name: PHCO_22712

Patch Description: s700_800 11.00 ksh(1) cumulative patch

Creation Date: 00/11/12

Post Date: 00/11/15


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)