Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using a program called node-webkit, but I can't start the program without specifying the full path to the executable file. Is there any way to associate a command (such as node-webkit) with an executable file on Linux, so that the full path to the file won't need to be specified?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

A third option, perhaps least intrusive, is to add an alias in your .bashrc file. This file is a set of options for bash which it reads every time an instance of bash is started.

  • Open your .bashrc file with your file editor, for e.g gedit ~/.bashrc

  • Add the below line to the bottom of your .bashrc file
    alias node-webkit=/path/to/node-webkit

  • Do source ~/.bashrc to be able to use the alias as if it were a command.

The way this works is like #define in C/C++, when you type node-webkit, it will be replaced with the right hand side of the alias definition, which here is the full path to the executable.

share|improve this answer
    
.bashrc is not always read when bash is executed, it will only be read by a.) interactive shells, and b.) non-login shells. .bashrc should be sourced from .bash_profile to work around the latter. –  Chris Down Dec 12 '12 at 22:22

Sure ... symbolic links. The command is "ln".

me@computer:~> echo $PATH
/usr/lib/mpi/gcc/openmpi/bin:/opt/lsb-tet3-lite/bin:/opt/lsb/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin

This is your path variable. Say, you have root privileges, creating a symlink into /usr/bin makes sense:

cd /usr/bin
ln -s /path/to/your/program/node-webkit node-webkit
share|improve this answer
2  
This doesn't really answer the question. eg - symlink where? –  jordanm Dec 5 '12 at 0:55
    
Any location, which is already within your path. I assumed, you do not want to change your path variable. –  ernestopheles Dec 5 '12 at 1:06

In order for the binary to be executed with it's name alone, the directory containing the binary needs to be in one of the directories specified by your PATH environment variable. You can add the directory the binary is currently in to your PATH with the following:

export PATH="/new/path:$PATH"

You can place this in an initialization script for your shell, ~/.bashrc for example. When it is a single command, I typically symlink the binary to location already in my PATH.

ln -s /path/to/node-webkit /usr/local/bin
share|improve this answer

Your Answer

 
discard

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.