SunOS confusing root directory and user home directory
Solaris / OpenSolarisThis forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
As has been suggested, it looks like you are in a chroot jail, and your home directory is also the effective filesystem root.
I'm not so sure of that any longer. He is running csh and his "pwd" is aliased to a variable called $cwd. He reported, when he ran the fully qualified path of command, pwd, (/bin/pwd) it returned "/". That suggests whatever the $cwd variable is set to is causing the odd response. That is why I asked him to run "printenv cwd" - for csh that should tell what the variable is set to.
Nothing.
But if I do "echo $cwd", this shows me the current path.
So, this variable is somewhere, but not in the environment. Right ? Where can it be ?
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
csh is crappy and broken by design, and having a broken prompt command doesn't help, not sure if there is any interest in investigating the issue further.
Just switch to ksh, bash or whatever shell you are familiar with.
Nothing.
But if I do "echo $cwd", this shows me the current path.
So, this variable is somewhere, but not in the environment. Right ? Where can it be ?
So you're NOT in csh like you said earlier? In an earlier post it was suggested you run:
/usr/xpg4/bin/sh
That would have changed you from csh to sh (bourne shell). Are you still in that same session? I had suggested you log in to a session like you did originally.
When you say "current path" do you mean the one shown by /bin/pwd or the one previously shown by pwd without the /bin in front of it?
So you're NOT in csh like you said earlier? In an earlier post it was suggested you run:
/usr/xpg4/bin/sh
That would have changed you from csh to sh (bourne shell). Are you still in that same session? I had suggested you log in to a session like you did originally.
When you say "current path" do you mean the one shown by /bin/pwd or the one previously shown by pwd without the /bin in front of it?
Yes, I am running csh.
I only used sh to test if the prompt would change, then I closed that session.
Repeating tests:
I reboot the machine and open a terminal.
The prompt says itīs at "myuser" directory.
The "pwd" command (without /bin in front) also shows "/home/staff/myuser".
The "echo $cwd" command also shows "/home/staff/myuser".
I do a "ls" command to see which files are in the current directory.
So I see Iīm in the root directory, not in "myuser".
When I say "current path" I mean the actual current path (shown by /bin/pwd): "/".
csh is crappy and broken by design, and having a broken prompt command doesn't help, not sure if there is any interest in investigating the issue further.
Just switch to ksh, bash or whatever shell you are familiar with.
Ok, that seems a good advice, but I cannot switch (permanently) the shell being used.
My company has been working that way for years and they wouldnīt want to have it changed.
But at this point, it seems the main question still to be investigated is about the cwd variable, thatīs not listed in the environment, and I have no idea where it comes from.
The value is coming from $cwd. Something in your environment is setting cwd to be the <weird path> you're seeing.
For csh look for "setenv cwd <value>" statements.
global setup for all csh users is defined in /etc/login.
local setup for csh users is defined in /$HOME/.csrhc and/or /$HOME/.login
For sh/ksh look for "cwd=<value>" statements.
global setup for all sh/ksh users is defined in /etc/profile.
local setup for sh/ksh users is defined in $HOME/.profile
NB: bash has additional files - this shell is most commonly used on Linux.
Any of the environment/setup files can "source" additional files and you'd have to examine those. Also they could invoke scripts that source additional files.
If you unalias pwd it should find the system pwd (/bin/pwd) instead of using $cwd.
The value is coming from $cwd. Something in your environment is setting cwd to be the <weird path> you're seeing.
No, see the section "Special shell variables" in the csh manpage. The shell internally sets and updates cwd. It is not, technically, part of the environment.
No, see the section "Special shell variables" in the csh manpage. The shell internally sets and updates cwd. It is not, technically, part of the environment.
I see that you are right. I also see that trying to change it from command line doesn't work (in csh on Linux - I don't have a Solaris system to test). After some searching I found a nice discussion about why cwd and /bin/pwd could report different things at http://www.grymoire.com/Unix/Csh.html.
That says in part:
Quote:
Specifying the current directory
There are two ways to find out what your current working directory is. The first is with the program "pwd" - print working directory. The second is with the variable "cwd," which can be examained by
echo $cwd
or by creating a new alias
alias cwd 'echo $cwd'
Examining the internal variable "cwd" is faster than executing the stand-alone program "pwd," but there is one subtle difference. If you access a symbolic link in your directory path, then "pwd" will show the actual directory path, while "cwd" will show the path you used to get to the directory.
The above however, suggests maybe it is a symbolic link he is going to on login. OP examining the home directory path seen for the user in /etc/passwd from root (/) down to check for symbolic links might be useful.
I also found some discussion of changing csh cwd via programming including some TCL stuff. It may be OP has is executing a binary in one of his environment files that is changing this.
Last edited by MensaWater; 04-30-2018 at 08:49 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.