Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an executable, called "octane", that I want to be able to launch globally. The executable requires access to a local binary, "octane.dat", in order to run.

I placed the directory containing the executable and the binary in /opt/ as root and created a symbolic link of the executable in /usr/local/bin/. Now, if I type "octane" anywhere, it launches but throws up an error saying it won't run without the binary, "octane.dat". Octane will only launch if my current working directory is the same as the executable and binary, in /usr/local/bin.

Any suggestions on how to fix this? Do I have to make that directory global using .bashrc?


share|improve this question
up vote 5 down vote accepted

Instead of the symbolic link you can create a wrapper script in /usr/local/bin:

#! /bin/sh
cd /opt/octane
exec ./octane "$@"

Make the script executable with chmod +x /usr/local/bin/octane.

The "$@" are the command line arguments, so you can still run octane an_argument.

The script changes the CWD (current working directory) only inside the script, because the script is run in a whole new shell instance which ends at the end of the script. Changing the current working directory for the executable might actually be a problem if you want to give a relative pathname to the executable. E.g. if you are in your home directory and run octane a_file_in_the_home_directory, it doesn't work, because the octane executable is called with a CWD of /opt/octane, and a_file_in_the_home_directory is not in /opt/octane. If that is a concern, you can either remember to give absolute pathnames only (octane ~/a_file_in_the_home_directory) or use a more complicated version of the script.

share|improve this answer
That worked perfectly. Thanks! I'm glad it doesn't change the CWD. I thought it that what the "$@" is for? – kedmond Dec 19 '12 at 18:43
Glad it worked; I updated my answer with the answer to your comment. – elmicha Dec 20 '12 at 23:24
You rock, thanks! – kedmond Dec 21 '12 at 18:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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