Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-04-2013, 07:39 PM   #1
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 547

Rep: Reputation: 115Reputation: 115
symlinking with source directory structure

I have downloaded a utility which I have put in /opt. Now, rather than put /opt/myutil/bin/ in my PATH, I prefer to symlink from /usr/local/bin/myutility.
The only problem I get is that the utility looks for files relative to where it has been launched from, so in this case it is /usr/local/bin rather than /opt/myutil/bin.

Is there any way I can get the symlink to look as though it has been launched from the source rather than the target?
Old 01-04-2013, 10:40 PM   #2
Senior Member
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,797
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
You can store the utility in /usr/local/bin/ (source directory) and then create a symlink of it in /opt/myutil/bin (i.e. target directory) OR in your home directory, like this:
cd /opt/myutil/bin
ln -s /usr/local/bin/myutility myutility
OR To add a symlink in home dir:
cd /home/username
ln -s /usr/local/bin/myutility myutility
Then, in /opt/myutil/bin or /home/username, using ls -l you will see something like:-
...... myutility -> /usr/local/bin/myutility
And you can then invoke myutility while residing in /opt/myutil/bin or in /home/username dir. and you won't need to add any dir. to your PATH variable.

Last edited by shivaa; 01-05-2013 at 12:10 AM. Reason: Info added
Old 01-05-2013, 10:25 AM   #3
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 2,579

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Your utility might have an environment variable to control this (eg: ORACLE_HOME, JAVA_HOME, MOZILLA_HOME). Consult the manual. If it is so, create a script like this:

$ cat /usr/local/bin/myutil
export MYUTIL_HOME='/opt/myutil'
exec "$MYUTIL_HOME/bin/myutility"


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] Modify the directory entry structure of a directory to show manipulated data shreyas08 Linux - Newbie 1 12-13-2011 05:34 AM
Convert directory structure from long file names in Linux to DOS 8.3 structure? manorina Linux - Software 5 09-12-2009 09:18 AM
Home Jail Folder Structure like Gobolinux Directory Structure luispt Linux - General 3 07-26-2008 06:46 PM
"WARNING: Circular directory structure" error when deleting directory pistonbrew Linux - Software 5 02-03-2005 06:05 AM
directory structure sluggo Linux - Newbie 1 01-20-2002 08:15 PM

All times are GMT -5. The time now is 09:41 AM.

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