[SOLVED] How to link home directory to different file-system
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
OP - if all you want to do is give that user a different set of binaries, have you considered setting PATH=/media/usb/bin:$PATH? You could enforce that by adding a UID check and putting it in /etc/profile or similar, and you could use permissions or acls to prevent other users from seeing/running the directories where those new binaries were stored.
It looks like you want to chroot the users, or at least user2. You might want search on Google for chroot howto's. Having user2's system inside user1's home directory isn't a good idea. Especially as you want the the chroot environment there as well. You have to enable read and execute rights for the parent directories, which allows user2 access to user1's files. User1 on the other hand can unlink user2's directories, since user1 has write access to /home/user1/ and deleting files and directories is an operation on the parent directory. Also pendrives don't make the best device for an operating system.
Maybe you could explain why you need to do this. That might help us suggest a better solution.
are you doing it from root account or normal user? and do what karamarisan said there should be a comma there.
@kdelover
I'm using sudo..and still getting the same msg! arrrgh!! (eating my fist)
@karamarisan
Quote:
OP - if all you want to do is give that user a different set of binaries, have you considered setting PATH=/media/usb/bin:$PATH? You could enforce that by adding a UID check and putting it in /etc/profile or similar, and you could use permissions or acls to prevent other users from seeing/running the directories where those new binaries were stored.
Thats a good idea. However, excuse my naiveness, but what you are saying is to add the place where binaries are on the USB disk to the user's path, right?
basically will using PATH=/media/usb/bin:$PATH? force an ls binary to run from /media/usb/bin/ rather than /bin/? for that user.
If the files you want alternates of are just binaries, then PATH modification is probably your best bet. Note that this is purely a convenience thing. With PATH=/media/usb/bin:..., if there is an ls in /media/usb/bin, that ls will be run instead of the system one, but user2 will still be able to run the system ls with /bin/ls if he wants to. Also note that is important that no more than root and possibly user2 be able to write to /media/usb/bin or any other directory you add this way, as you could otherwise be opening a serious local security hole.
chroot is overkill if all you want are alternate binaries. It would also affect a number of other things, as the root filesystem outside /media/usb would no longer be visible until the chroot was exited.
OP: Take this as a lesson in presenting your problem rather than what you think is a solution. If all you need is alternate binaries for this user, you would have gotten the PATH business a lot sooner and that'd likely be it. You framed it like you need an entire filesystem, and a number of people have given chroot as a way to make that happen (as that's what it does).
root@wsx04:~# clear
root@wsx04:~# mount -o remount,acl /
root@wsx04:~# mount
/dev/sda7 on / type ext4 (rw,errors=remount-ro,acl)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
Everyone,
Thanks so much for the helpful pointers and code snippets. I have implemented the PATH solution and am looking at chroot now. I have got it working. I found some excellent tutorials via google about chroot.
One question though, as the root user of my system, if I grant a programmer access into a chroot jail, how can I move him back to the normal /home/user2 filesystem on m computer. I have found articles on "how to get out of chroot jail" and "how to break out of jail" etc.. but they don't seem to be quite elegant. They all use the fact that the root user can't be jailed and so the chrooted guy performs actions to elevate himself to root level and hence gets out or maybe follows a hard link..etc..
Can someone please suggest a clean way to allow a chrooted user back into the main filesystem.
Situation: User2 logs into my computer and is hived off to a chrooted environment, he does some stuff, and then I as the root user decide it is time to move user2 onto the main file system.
One possible way, I thought of, based on this thread is to possibly go and put links in the chrooted environment for user2 pointing to the /home/user2 on the main filesystem. But chroot won't allow user2 to follow those soft links (as it should). Also it seems hard links can't be made to directories.
Can anyone give me some advice about bringing a user back from a chrooted environment to the main filesystem.
Thanks again in advance.
EDIT============
I mean moving user2 into the main file system in a transparent manner if possible. For example: user2 logs in and is thrown into chrooted env, he does some stuff, and then automatically (magically, after 20 seconds or completing some tasks etc..) is now able to browse the main file system, thereby not being restricted by chroot, without having to do any "jailbreaking" explicitly.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.