1

I have a particular way that I order my folders within documents to keep things nice and neat, but many programs I use want to dump things in my home folder. Some things, like git, are just easier to access from the home folder.

I'd like to set up symbolic links for these, but I'm not sure which direction to go with it. I'm thinking I should place the files in my documents scheme, and create the symbolic link folders in my home folder. I'm just not sure how the path is read by the item using it. (Like if git accesses the symbolic link, is the path the "same" as if the file were actually in that folder?)

Example:

~ original directory: ./Documents/directory1/directory2/
~ symbolic link: ./git linked to directory2
~ accessing a file in directory2: ./git/fileA
(fileA being located in directory2)

So my questions are:

  1. Is my understanding of how to set this up correct? Are the paths to files read from the linked folder the same as if they were in the original folder?

  2. If my understanding is not correct, how do I write paths to access files within the linked directory?

5
  • Are you trying to manage a git repository from your home? – Ravexina Aug 26 '17 at 15:24
  • I'm finding your question a little confusing. Could you perhaps show us the output of ls -ld ~/git and a sample of ls -l ~/Documents/directory1/directory2 that includes fileA? I think the answer to your question is YES; if you create a symlink to a directory, you can use the symlink in a path, instead of the real directory path. But I am not sure I follow exactly what you want to ask... – Zanna Aug 26 '17 at 15:25
  • @Ravexina - that and several other things that seem to want to work within my home folder. – mbrasseau Aug 26 '17 at 15:56
  • @Zanna - I have no output. I merely used git as an example since many are familiar with it. I'm asking what is the proper path description to access the files in hypothetical directory2 from hyposthetical symbolic link git – mbrasseau Aug 26 '17 at 15:59
  • yes, but you could make some fake directories for the purpose of having a clearer description. I tried to edit your post (/paths/look/clearer/as/code but I couldn't find a way to do it that seemed right. Anyway, I think the answerers understood and I agree with them – Zanna Aug 26 '17 at 16:02
1
  1. Is my understanding of how to set this up correct? Are the paths to files read from the linked folder the same as if they were in the original folder?

Yes. You can make that link using ln:

ln -s ~/Documents/directory1/directory2 ~/git

Then, for example if you run nano ~/git/fileA, it will open the exact same file as if you ran nano ~/Documents/directory1/directory2/fileA.


Similarly, I have a multi-level symlink setup in my home folder, and it works fine. For example:

~/Dropbox
Documents -> ~/Dropbox/Documents/
Scripts -> ~/Documents/Scripts/
.bashrc -> ~/Scripts/startup/bashrc
1
  • Wow! thanks. Exactly what I needed to know. I didn't know we could link to Dropbox too. – mbrasseau Aug 26 '17 at 16:06
0

Yes. You are right. When you link to a directory, it will function as you expect.

In my case, I needed to work with NLTK for processing some text. The NLTK-data needed to be in my home folder while I didn't have enough space there for a new 5GB+ folder. My solution was to download the data and save them in another place and then, make a link to it from my home. You can see what I have done:

lrwxrwxrwx  1 sama sama        9 Apr 23 13:53 D -> /media/D/
lrwxrwxrwx  1 sama sama       18 Apr 23 13:53 DDownloads -> D/Downloads
lrwxrwxrwx  1 sama sama       20 Apr 23 13:54 nltk_data -> DDownloads/nltk_data

You can see the second and the third, are links to an already link.

1
  • Thank you. Your comment helped to clarify my understanding. I like knowing that I can expand the linkage. – mbrasseau Aug 26 '17 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.