0

Say for instance I want to link the following two directories with a command like this:

 ln -s /home/usertwo testdir

When I click ls, in the directory where this link is created, i will see something like

testdir -> /home/usertwo

Is there a way I can hide /home/usertwo so that userone cannot see the name of usertwo?

1
  • 1
    Well, you could put the symlink in a directory that only userone can access. Alternately, if the symlink needs to be in a public directory, you could chain them, e.g. testdir -> /home/userone/some-innocuous-filename -> /home/usertwo. Assuming only userone can read /home/userone, only userone will be able to see where the “middle” symlink points. Jan 9, 2014 at 2:00

2 Answers 2

0

Hiding the listing would be impossible by what you could do is hide the directory from being read: chmod -r /certain/directories. Some may prefer to toggle the e[x]ecutable flag but that would also stop files from being read or executed.

0

One possible way to do it is not with a symlink but with a bind mount. The symlink has to know where to go because that is everything it is and it shows.

The possible solution:

/home/somedir <-- we want this one to show under otherdir/share /home/otherdir mount -o bind,ro /home/somedir /home/otherdir/share

here is a sample

$ ls -l
drwxrwxr-x 4 user user 35 jan 9 12:37 home
$ ls -l home/
drwxrwxr-x 3 user user 18 jan 9 12:38 otherdir
drwxrwxr-x 2 user user 21 jan 9 12:38 somedir
$ ls -l home/somedir/
-rw-rw-r-- 1 user user 0 jan 9 12:38 test.txt
$ ls -l home/otherdir/
drwxrwxr-x 2 user user 6 jan 9 12:38 share
$ ls -l home/otherdir/share/
$ sudo mount -o bind home/somedir/ home/otherdir/share/
$ ls -l home/otherdir/share/
-rw-rw-r-- 1 user user 0 jan 9 12:38 test.txt

2
  • Wouldn't other users be able to see the target of the bind with mount? Jan 9, 2014 at 15:27
  • yep they would but mount can be relegated to root use only. Of course there are other methods to see the mounts but this is usually enough for the average user
    – zeridon
    Jan 15, 2014 at 13:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .