Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SunOS confusing root directory and user home directory 1

Status
Not open for further replies.

egyassun

Programmer
Apr 24, 2018
3
BR

Hello,

I´ve just started using a Solaris machine with SunOS 5.10.
After the machine is turned on, I open a Console window and at the prompt, if I execute a pwd command, it tells me I´m at my home directory (someone configured "myuser" as default user after init).

MACH1!myuser(staff,----,noView)@../myuser [41] pwd
/home/staff/myuser

But the weird thing is that if I run a ls command, it shows me that in fact, it´s at the root directory (!!!)

MACH1!myuser(staff,----,noView)@../myuser [42] ls -l
(Shows directories:
/etc
/home
/usr ...)

And if I go to a subdirectory, something stranger happens.
It assumes a false path.
MACH1!myuser(staff,----,noView)@../myuser [43] cd etc
MACH1!myuser(staff,----,noView)@../etc [44] pwd
/home/staff/myuser/etc

If I try to call this false path, the shell naturally can´t do it.

MACH1!myuser(staff,----,noView)@../etc [45] cd /home/staff/myuser/etc
/home/staff/myuser/etc: No such file or directory

But if I call my home path, it works as expected.
MACH1!myuser(staff,----,noView)@../etc [46] cd /home/staff/myuser
/home/staff/myuser

MACH1!myuser(staff,----,noView)@../myuser [47] ls -l
(shows files in my home directory)

Well, I´m not so experienced with Unix and I have no idea what can be wrong. I looked some files such as .profile, dtautologin, but couldn´t find anything that seemed to be causing this problem.

Can anyone give me a idea of what´s wrong with the configuration of this machine ?
 
Weird. I've never seen this, but I have a few suggestions.

First thing that comes to mind is that your home directory may either not exist (which will throw you to the root dir "/"), or it may have been accidentally created as a link (hard or soft) to the root directory. That would explain why 'pwd' thinks you are in your home directory, but the 'ls' shows the root directory.

Show us your /etc/passwd entry so we can confirm it's formatted correctly. Don't worry, it does not (should not) include your password hash. '[tt]grep -i myuser /etc/passwd[/tt]'.

Second, let's see what the directory is...

Code:
cd /home
ls -l
cd staff
ls -l

Also, what shell are you in? Also, let's get a little more info. Please do the following and give us the results (please scrub it of any proprietary or confidential information).

Code:
echo ~
echo $HOME
cd ~
ls -l ~
cat ~/.profile
cat /etc/profile
cat ~/.kshrc  # Only is you're in a Korn shell
env
set
uname -a
id -a

Other ideas, maybe you are in a badly set up zone. Maybe your disk is corrupted. Maybe you are being tested by devious coworkers.


 
Hi Sam,

Excuse me for this long time without answering.

I discovered that my problem was due to a highly customized prompt with csh shell.

Code:
set prompt="`uname -n | cut -f1 -d"." `\\!`whoami`($GROUP,$NCID,$VIEW)@../$cwd:t[\!] "

That explains ... but if you still want some additional info, just tell me.
Thanks for your attention !
 
Thanks for posting your solution. That helps others that may come by later with the same problem.

Also, that's the problem with having something like '[tt]$cwd[/tt]' in your [tt]PATH[/tt]. It may not correspond to the actual current working directory. Try changing it to [tt]$PWD[/tt]. The environment variable [tt]PWD[/tt] is set by the '[tt]cd[/tt]' command, so it should be more accurate.
 
Sam,

In fact, $cwd and $PWD are returning the same result.
Both return the same false path - for example, "/home/staff/myuser/etc".

But there´s another thing I forgot to mention.

If I run "pwd", this yields: "/home/staff/myuser/etc" (false).
But if I run "/bin/pwd", this yields: "/etc" (correct).
This starts to happen since I open a console window and only stops when I leave the "/home/staff/myuser" structure.

So, I´m also dealing with different versions of pwd.
In the "/bin" directory, there´s a version that works the usual way.
But the default version is having a strange behavior - probably due to some configuration.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top