LinuxQuestions.org
Help answer threads with 0 replies.
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 06-20-2015, 05:40 AM   #1
wavelength72
LQ Newbie
 
Registered: Jun 2015
Distribution: F21
Posts: 12

Rep: Reputation: Disabled
How to make a symbolic link on the command line


Hi, the path to one of my folders is pretty long:

cd here/here/here/here/here/here

I was wondering if there's a way to make a link (in a terminal) so I only have to type in:

cd here

to get there

Thanks!
 
Old 06-20-2015, 05:44 AM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,686
Blog Entries: 23

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
yep, can be done
make a folder called "here"
mount the folder

Code:
mount --bind /here/there/somewhere/else /here
putt hat in your rc, somewhere, that...depends on your distro...
Edit - an extra entry in the fstab should do...

Last edited by ButterflyMelissa; 06-20-2015 at 05:47 AM.
 
Old 06-20-2015, 05:52 AM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181
Code:
ln -s here/here/here/here/here/here there
Read the man page on ln for more info.

Notice I used a relative path (as you did). But you might want an absolute path depending on where the link is and how it is used.

Various mount operations (as Thor_2.0 suggested) might be better alternatives in some situations. But I don't see any hint in your original post that a mount would be better than a symbolic link.

For things you need to type in a lot, using an environment variable, and alias or a script is usually better than a symbolic link or mount:
Code:
export there=/absolutepathto/here
cd $there
That first line should be in some login or bash startup script so you edit it into there once then don't need to type it again.
The word export in that first line may not be necessary, depending on how you use "there".

Last edited by johnsfine; 06-20-2015 at 06:01 AM.
 
1 members found this post helpful.
Old 06-20-2015, 05:55 AM   #4
fatmac
Senior Member
 
Registered: Sep 2011
Location: Surrey/Hants Border, UK
Distribution: BSD & Linux - As long as they are Lightweight
Posts: 1,500

Rep: Reputation: Disabled
In a terminal in your /home directory
Code:
ln -s here/here/here/here/here/here here
then you can just use
Code:
cd here
from your /home directory
then
Code:
cd
on its own will take you back to your /home directory.
 
Old 06-20-2015, 06:07 AM   #5
wavelength72
LQ Newbie
 
Registered: Jun 2015
Distribution: F21
Posts: 12

Original Poster
Rep: Reputation: Disabled
Thanks for the immediate replies.

Thinking things through, perhaps I should tell more.

I have a mounted external HDD. I've already changed all the links to ~/home/Documents (etc) to point to the same folders on the external HDD. I use nemo to get to these folders. The original folders in home are still there and get used sometimes. They're backed up daily to the duplicate folders on the HDD.

The problem I'm facing is that I constantly have to change directories to the external HDD or type in an absolute path to either open something or look at the contents of a folder.

For example, if I want to confirm the naming convention of a folder in my software directory on the external HDD I have to type:

ls /run/media/win7/storage/Software (don't ask me why it's called 'win7' please)

From any prompt location in the CLI, I would simply like to type in:

ls /here/Software to get a directory listing. Similarly, making a directory in Software before wgetting a file and then wgetting the file to that location would be easier if I had some sort of symbolic link too.

Do I have to actually make a folder to represent the location since the location already exists? The external HDD is already auto-mounted on boot.

I am new to this, and trying to move over to the CLI instead of GUI, so please be gentle with your answers and assume I'm a noob who doesn't know how to do anything.

Thanks.

Last edited by wavelength72; 06-20-2015 at 06:08 AM. Reason: spelling errors
 
Old 06-20-2015, 06:53 AM   #6
wavelength72
LQ Newbie
 
Registered: Jun 2015
Distribution: F21
Posts: 12

Original Poster
Rep: Reputation: Disabled
OK. I just used:

Quote:
Originally Posted by fatmac
Code:
ln -s here/here/here/here/here/here there
Which is great, but only works from the home directory. I need it to work from anywhere.

johnsfine,

I'm not sure how to make a batch script or where to put it (F21). Can you give instructions or point to some?

Thanks
 
Old 06-20-2015, 12:22 PM   #7
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,686
Blog Entries: 23

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Quote:
I need it to work from anywhere.
The mount does that...
create a script that mounts the folder, and in the future, you can add more stuff...add this to the crontab as @reboot
It is one option, there are more enlightened ones that may have something better than that...
Thor
 
  


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] Can I make a symbolic link that is dynamic link->$HOME/file? croog Linux - General 4 10-14-2012 08:55 PM
how to create symbolic link fr command line kaykav Linux - Newbie 2 11-24-2010 08:46 PM
[SOLVED] Trying to write a command line script that will make symbolic links dave247 Programming 5 10-21-2010 01:24 PM
The command to make a symbolic link Gins Linux - General 10 11-12-2006 02:58 PM
cannot make symbolic link dave`2005 Debian 3 10-08-2005 11:15 AM


All times are GMT -5. The time now is 04:15 AM.

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