LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Windows-sort-of shortcut (https://www.linuxquestions.org/questions/linux-newbie-8/windows-sort-of-shortcut-4175473684/)

esso82 08-16-2013 11:26 PM

Windows-sort-of shortcut
 
Hello, can anyone help a noob please?

I would like to share a folder (including subfolders) on my NAS ( WD MyBook World Ed. WhiteLight) with a friend over internet (FTP).

So far I created a user, installed vsftpd and set to jail it's users in their /home directory. Now say, there is a folder /shares/music which I want to appear readable only in /home/user.

Do I use the mount command or should I go different path?

Thank you for any advice.

jdkaye 08-17-2013 12:04 AM

Would a (symbolic) link do the job?
jdk

esso82 08-17-2013 12:18 AM

I don't know. Well, I don't know what a symbolic link is or what is it used for. Simply, I want a remote user to access his /home folder, where he can download data from another folder on the hard drive. So the contents of this "another" folder would be listed in his home folder as read only.

moo-cow 08-17-2013 02:26 AM

Hi,

a symbolik link, as suggested by jdk, corresponds exactly to a "shortcut" in Windows. Just create a symlink from the user's home dir to /shares/music and make sure that /shares/music and the files contained therein are not writable for the user.

PS: You can create a symlink using ln.

esso82 08-17-2013 06:13 AM

oh yes, thank you, that worked

well, not the way I want, but I mean, the symlink worked

My problem now is that ftp sends error 500, but when I log in as root and go there, it takes me where it points to. Is it because the user is jailed to it's /home folder?

----------
EDIT
----------

also if I connect via phone using ES File Manager this symlink doesn't work as shortcut but phone wants to open it as video/audio/text/etc .... wouldn't the mount command work better here?

moo-cow 08-17-2013 08:17 AM

Code:

wouldn't the mount command work better here?
Try it out! ;) But note that the command will only mount devices, e.g. disk partitions.

eSelix 08-17-2013 08:31 AM

Symlink will not work due jail. That way anybody could create symlink to other place and read data outside jail. You can do
Code:

mkdir /home/user/shared_music
mount --bind /shares/music /home/user/shared_music


esso82 08-17-2013 09:48 AM

OK, we're getting there

mount --bind works the way I want, but have 2 more questions on how to and that is:

1. How do I represent spaces in path when typing command in putty? ie "/shares/Music/Hip Hop" won't work because of the space before last word
2. when I mount like this: "mount --bind /shares/Music /home/user" - how do I unmount later? tried "umount /shares/Music" but didn't work, it says "couldn't umount, invalid argument".
Also, shouldn't "mount -l" list all mounted devices including my bind folder?

----------
EDIT
----------

also, a bit off topic, when I ssh this user into my NAS he can see all contents (can't write though) of the hard drive, how do I make this visible to root only?

moo-cow 08-17-2013 09:58 AM

Code:

1. How do I represent spaces in path when typing command in putty? ie "/shares/Music/Hip Hop" won't work because of the space before last word
Enclose the path in quotation marks, or add a backslash (\) before every space.

Code:

Also, shouldn't "mount -l" list all mounted devices including my bind folder?
Yes! That your share folder isn't listed and the "invalid argument" error message indicate that mounting didn't work. Try mount with the -v option ("verbose").

esso82 08-17-2013 10:07 AM

Quote:

Originally Posted by moo-cow (Post 5010925)
Code:

Also, shouldn't "mount -l" list all mounted devices including my bind folder?
Yes! That your share folder isn't listed and the "invalid argument" error message indicate that mounting didn't work. Try mount with the -v option ("verbose").

well, it does, I can see contents of the folder when I go into /home/user but it's not listed within the mounted devices

also, when I try
Code:

mount --bind -o ro /shares/music /home/user/test
I can go into /home/user/test and see the contents of /shares/music but it's NOT read only. I'm afraid to chmod it to 444, don't know whether that happens to the "shortcut" folder or to the actual /shares/music folder

----------
EDIT
----------

just to show, mount -l shows this:
Code:

securityfs on /sys/kernel/security type securityfs (rw)
/dev/md2 on /DataVolume type xfs (rw,usrquota) []
/dev/md4 on /ExtendVolume type xfs (rw,usrquota)

even tho I mounted two more folders now

eSelix 08-17-2013 03:08 PM

Quote:

2. when I mount like this: "mount --bind /shares/Music /home/user" - how do I unmount later? tried "umount /shares/Music" but didn't work, it says "couldn't umount, invalid argument".
Usually unmouting is done by mountpoint, not mounted "device". Try "umount /home/user" or "umount /home/user/test" (wherever you mounted).

Quote:

Also, shouldn't "mount -l" list all mounted devices including my bind folder?
It should.

Quote:

I can go into /home/user/test and see the contents of /shares/music but it's NOT read only.
It should.

Are you using busybox? The last two problems may be connected with that. It is simplified program, some tools may not work with "full potential". Also your /etc may be mounted read only, or /etc/mtab is not writable, therefore mount/umount can not store data it need for unmouting and listing. Try "cat /proc/mounts" if you have proc mounted.

Quote:

I'm afraid to chmod it to 444, don't know whether that happens to the "shortcut" folder or to the actual /shares/music folder
Always to actual folder. Permissions of this shortcut folder (called mountpoint) is not taken into account. But remember about subdirectories, they also need proper permissions, 0755 should be sufficient or 0750 (with proper group set for users and this folder).

esso82 08-17-2013 04:07 PM

eSelix ... yes I'm using busybox (2.26 I think it is) what looks like the main problem is

cat /proc/mounts returns all mountpoints including those mount by me and for some strange reason I wasn't able to unmount /home/user before I unmount /shares/user (which I must have accidentaly created)

also I have a root access so I can change anything I guess

anyway thank you, I think I found answers I was looking for, time to go sleep now, will try once again tomorrow.


All times are GMT -5. The time now is 02:30 PM.