LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 07-18-2014, 10:37 AM   #1
dorlack
Member
 
Registered: Oct 2009
Location: Cambridge MA
Distribution: Any Linux
Posts: 122

Rep: Reputation: 2
show contents of one directory in another.


drawing a total blank hope you guys can help me out.

I am trying to remember the command to link directories.

I need to show the contents of /var/home_volume in /home. I was abe to this once before and I remember it not being the normal symbolic link process.

The last time I did this was to display /home in a folder called /workspace. So if i created a new user in /home it showed up in /workspace.

IDK maybe it is a symbolic link but /home is already created. I could have sworn there is another method. Hope I am able to get my point across.
 
Old 07-18-2014, 11:16 AM   #2
austintx
Member
 
Registered: Jul 2012
Location: Austin, Texas
Distribution: Linux Mint 17 Cinnamon
Posts: 34

Rep: Reputation: 4
The ordinary symlink should work.
ln -s /var/home_volume $HOME/home_volume

You can also automount at boot in fstab using bind.
Something like this:
UUID=f7927995-b098-42be-ada0-987857f5177a /var ext4 defaults,noatime 0 0
/var/home_volume $HOME/Documents auto bind 0 0
 
Old 07-18-2014, 11:19 AM   #3
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
@ Reply

Directories cannot be hard link but you can soft link them. As you said you want to show contents of one directory to be shown in other. You can use:

Code:
ln -s <parent directory> <directory you want to show contents in>, example: ln -s <home> <home_test>
Remember that the other directory where you want to show the contents should not already exist. It will be automatically get created by ln -s.
 
Old 07-18-2014, 11:23 AM   #4
dorlack
Member
 
Registered: Oct 2009
Location: Cambridge MA
Distribution: Any Linux
Posts: 122

Original Poster
Rep: Reputation: 2
The folders are already created. I wanted to avoid rebuilding them. Symbolic link will require the folder to not exist right?
 
Old 07-18-2014, 11:33 AM   #5
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
Yes that is correct. However, you can have a sub-folder inside that which contains symlink to your parent folder. Example:

Code:
/tmp/test_dir (already exist)
/tmp/test_dir1 (already exist)

get into /tmp/test_dir1 and then run:

ln -s /tmp/test_dir testing
This will create a child directory under /tmp/test_dir1/testing which will actually point to /tmp/test_dir.
 
Old 07-18-2014, 11:35 AM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,260

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
So what you're saying is, /var/home_volume already exists and has files/dirs inside. In addition, /home already exists and has files/dirs inside. And you want to merge these two directories so that all files/dirs from BOTH locations are shown side-by-side in /home ?

The cleanest way, I would think, would be to move the contents of /home to /var/home_volume, delete /home, and then symlink or bind mount /var/home_volume to /home. If that's not an option, I suppose you could loop through all files/dirs in /var/home_volume and symlink them inside of /home
Code:
for i in /var/home_volume/*; do ln -s $i /home/; done
But this would have to be repeated every time a new file/dir is added in /var/home_volume, it wouldn't be added to /home automatically. It would be pretty messy though, and how would you handle files with the same name in both locations? You'd be better off thinking of a new way to do things, IMO.

All of the above suggestions are explaining how to make a symlink of /var/home_volume INSIDE of /home, so you would have to go to /home/home_volume to see it. It doesn't sound like that's what you want.

Last edited by suicidaleggroll; 07-18-2014 at 11:39 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] List files/directory names without directory contents? littlebigman Linux - Software 2 05-03-2011 05:42 AM
Firefox not able to show the contents rajesh.bahl Linux - Desktop 2 03-10-2009 01:34 AM
list contents of directory without listing contents baddah Linux - Newbie 2 06-12-2006 05:02 AM
KDE 3.2 won't show CD contents spookymulder825 Linux - Software 4 03-07-2005 08:52 PM
show contents of random file? iluvatar Linux - Software 6 07-13-2004 02:53 AM


All times are GMT -5. The time now is 03:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration