[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.
How to link home directory to different file-system
Hello all,
I'm looking for some advice about how to implement the following functionality in my pet project.
There are two users on my system, user1 and user2. When user1 logs in he can do what he wants etc.. when user2 logs in I want to somehow link the entire file system to another place. In more detail when user2 logs in and does something like ls ~, he should see contents of /home/user1/extra/home/user2/ instead of /home/user2/
and when user2 does ls /usr/bin he should see contents of /home/user1/extra/usr/bin/
Is there a simple way to do this kind of operation. I have looked up the ln command, but I am a little unsure about how to show a completely different file structure to a particular user.
I did play around with ln and found that you can make "soft links" to directories. The problem being how can I link the user2 home directory /home/user2 to something like /home/user1/buffer/home/user2 . can I use something like ln -s /home/user1/buffer/home/user2 /home/user2 .. I guess not. I didn't want to try it as I wasn't sure so as to not hose my system.
There are two users on my system, user1 and user2. When user1 logs in he can do what he wants etc.. when user2 logs in I want to somehow link the entire file system to another place... [SNIP] ...
and when user2 does ls /usr/bin he should see contents of /home/user1/extra/usr/bin/
If you explained to us exactly why you want to do this, we might be able to offer a simple solution.
You are right about using usermod, however it will only be useful in the case where I want to change the home directory of user2 to some other location. Useful, nonetheless.
The problem being can I somehow point user2 to a completely different file structure
@tredegar
I want to do this because I want to maintain a file structure on a USB stick (just as an example). I do not want the file structure and the files in it to be known to every programmer on my system. Thereby if I can figure out a way to let user2, who is a special programmer and can get access to the file-system on the USB disk I should be able to give it to him.
The point being I want user2 to feel as if he is working on the main computer itself. Thereby the question about "Can I link the entire filesystem for a particular user to somewhere else"
I want user2 to seamlessly log in to my computer, I will decide if user2 is a special person, based on the username..etc.. and then somehow hive off user2 to a different file system where he feels as if he is on the main computer but entries in (say) the /usr/bin on the USB stick will be different than the entries in /usr/bin on my machine but user2 ned not be bothered as he will only see file system on usb stick.
how about mounting that usb drive to /home? what i do on my server is create a parition called /fs and NFS export it and mount it as /home on client remote systems It just looks like /home is locally present where as its actually nfs mounted.
that a very decent idea, I will definitely explore it with the usermod option. However the problem in this case still remains that if user2 types in ls /usr/bin he is still going to see the setup on my computer instead of the one on the usb disk..correct me if I am wrong :-)
you want to restrict your users to just he usb pen drive that is they shouldn't be able to browse outside their home directories? is that what you are inferring? If thats the case i can only think of setting up acl on per user basis
Yes you are right, that user2 should be able to only be in the pen drive based file structure. With ACLs I can cut off access to my machines /usr/bin etc..
However if user2 does type in ls /usr/bin it still won't let him see the USB drive's file system. he has to explicitly type ls /mnt/pendrive/usr/bin/.... etc. I want to make this transparent such that user2 types in /usr/bin and I can show him /mnt/pendrive/usr/bin/.
I'm thinking of a hammer and tongs approach: what if I modify the ls command, basically wrap a script around it and add /mnt/pendrive to all locations user2 types in. So ls /usr/bin would become ls /mnt/pendrive/usr/bin . The complication being thre are just so many possibilities, such as ls ~, the cd command, ln command etc..
there should be a config file in /boot grep for acl from that and see if the acl option is enabled or not you should see a Y what you see,you should se something like
there should be a config file in /boot grep for acl from that and see if the acl option is enabled or not you should see a Y what you see,you should se something like
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.