LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 01-04-2013, 08:39 PM   #1
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 547

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


Hi,
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, 11:40 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,797
Blog Entries: 4

Rep: Reputation: 285Reputation: 285Reputation: 285
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:
Code:
cd /opt/myutil/bin
ln -s /usr/local/bin/myutility myutility
OR To add a symlink in home dir:
Code:
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:-
Code:
...... 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 01:10 AM. Reason: Info added
 
Old 01-05-2013, 11:25 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,893

Rep: Reputation: 522Reputation: 522Reputation: 522Reputation: 522Reputation: 522Reputation: 522
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:

Code:
$ cat /usr/local/bin/myutil
#!/bin/sh
export MYUTIL_HOME='/opt/myutil'
exec "$MYUTIL_HOME/bin/myutility"
 
  


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


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration