LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 07:39 PM   #1
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
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, 10:40 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
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:
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 12:10 AM. Reason: Info added
 
Old 01-05-2013, 10:25 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:46 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
Open Source Consulting | Domain Registration