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 have 2 Ubuntu Linux boxes with similar directory structures, LX02 and LX04. When I ssh from a terminal on LX02 to LX04 and go to my main scripting directory, /root/sbin, I see a different set of subdirectories than when I go the same directory from a terminal session on LX04. Why?

DETAILS
Both machines have a /0 directory that contains mountpoint directories for each remote host as in...

/0/LX02
/0/LX04

/etc/fstab contains entries to mount the remote host's root (/) directory to these. There is a 'mount bind' entry to mount the local (/) directory which avoids special coding for the local host in scripts.

/root/sbin is a symlink to /usr/local/sbin on each machine.

The local /root/sbin directory on LX02 looks like...

 root@LX02:/  cd /root/sbin

 root@LX02:~/sbin  ls -l | grep '^d'

drwxr-x--- 2 root root  4096 2011-07-16 00:49 Archives-sbin-20110825
drwxr-x--- 2 root root  4096 2010-07-28 08:13 lst
drwxr-xr-x 2 root root  4096 2012-04-11 09:28 Misc
drwxr-xr-x 2 root root  4096 2012-04-11 09:28 Slates
drwxr-xr-x 2 root root  4096 2012-04-11 09:28 Tomboy
drwxr-xr-x 2 root root  4096 2012-04-11 09:28 Ubuntu_8.04
drwxr-x--- 2 root root  4096 2010-07-28 08:13 www
drwxr-xr-x 2 root root  4096 2012-09-27 12:48 zim

Going to /0/LX04/root/sbin from an LX02 terminal session results in...

 root@LX02:/0/LX04/root/sbin  cd /0/LX04/root/sbin

 root@LX02:/0/LX04/root/sbin  ls -l | grep '^d'

drwxr-x--- 2 root root  4096 2011-07-16 00:49 Archives-sbin-20110825
drwxr-x--- 2 root root  4096 2010-07-28 08:13 lst
drwxr-xr-x 2 root root  4096 2012-04-11 09:28 Misc
drwxr-xr-x 2 root root  4096 2012-04-11 09:28 Slates
drwxr-xr-x 2 root root  4096 2012-04-11 09:28 Tomboy
drwxr-xr-x 2 root root  4096 2012-04-11 09:28 Ubuntu_8.04
drwxr-x--- 2 root root  4096 2010-07-28 08:13 www
drwxr-xr-x 2 root root  4096 2012-09-27 12:48 zim

However, the /root/sbin directory on LX04 actually looks like...

 root@LX04:/  cd /root/sbin

 root@LX04:~/sbin  ls -l | grep '^d'

drwx------ 4 root root 12288 2011-12-23 03:23 Archives
drwx------ 2 root root  4096 2011-07-16 00:49 Archives-sbin-20110825
drwxr-xr-x 3 root root  4096 2012-11-14 00:22 Examples
drwxr-x--- 2 root root  4096 2011-04-29 13:50 fnc
drwxr-x--- 2 root root  4096 2011-05-19 15:00 lst
drwxr-xr-x 3 root root  4096 2012-10-28 10:01 Synergy
drwxr-x--- 2 root root  4096 2011-03-10 20:54 tmp
drwxr-x--- 2 root root  4096 2011-03-10 20:54 www

What's happening here?

share|improve this question
    
Are you absolutely sure you need root privileges to log on at the machines? Can you reproduce this issue with an unprivileged user? What does grep root /etc/passwd return on both machines? –  jippie Nov 18 '12 at 18:14
    
No, I'm not... but thanks for asking as it could be a factor for most people. I leave to those who still have to work in multiuser environments to address those kinds of questions. I have a "salvage yard" of several Linux computers (I like to think of it as a "lab") and 99% of what I do on them requires root privileges so logging in as an unprivileged user would be very unproductive. So far as I can tell, no bots have slaved my machines yet. I predominantly rely on monitoring the history of what normally runs, and the resource usage, and watch for anomalies. –  DocSalvage Nov 19 '12 at 11:25
add comment

1 Answer

up vote 1 down vote accepted

If I understand your setup correctly, /root/sbin on LX04 is a symbolic link to /usr/local/sbin. Therefore /0/LX04/root/sbin on LX02, which is part of an SSHFS filesystem, is a symbolic link to /usr/local/sbin. When you're on LX02, the directory /0/LX04/root/sbin is located at /usr/local/sbin, and that's the contents you're seeing. Since you're on LX02, you are of course seeing LX02's /usr/local/sbin (which is also accessible via /root/sbin).

Symbolic links are purely textual, they don't carry any information about the filesystem that you think they should be targetting.

If you want /0/LX04/root/sbin to point to the /usr/local/sbin from LX04, make it a symbolic to /0/LX04/usr/local/sbin. If you want /0/LX04/root/sbin to show /usr/local/sbin from the same machine that it's on (which here is the same thing), make it a relative link: /root/sbin ->../usr/local/sbin (run ln -snf ../usr/local/sbin /0/LX04/root/sbin. It's usually a good idea to make symbolic links relative, that more often than not gives the desired result when doing complex mounting.

share|improve this answer
    
I'd vote this up but I haven't got enough rep yet! Yes, I finally figured that out but left the question up so I can find the answer next time I need it (I forget a lot). –  DocSalvage Nov 19 '12 at 11:00
    
Now that I have enough rep, I've +1'd. Thanks! –  DocSalvage Jan 17 at 10:06
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.