Suppose you're distributing a program to run on Linux, call it Foo, and the program executable is called foo.exe (because it's a CLR program so it runs under Mono) and it needs a couple of DLLs in the same directory and maybe a later version might need some data files that it reads on startup and whatever, so relocating it to a global bin directory is a bit of hassle and it really prefers to remain in its original directory...

But the user would prefer to invoke the program by typing foo instead of mono /path/to/foo.exe.

What's the best/most usual way to provide such a short command? Can/should an install script/makefile create a one line script called foo that invokes the full path, and put the one line script in a global bin directory? If so, what should be the target bin directory, and are there any directions about exactly how to do this? Or is there a preferred alternative?

edit: The approach of creating a one line script at install time seems to work well, here's the actual install script I ended up writing:

a@a-desktop:~/ayane$ cat install.sh 
echo mono `pwd`/ayane.exe '"$@"' >ayane
chmod +x ayane
mv ayane /usr/local/bin

I would put a link or a script in /usr/local/bin

A link if all you need to do to start foo.exe is to type the full path /my/path/foo.exe. You on the other hand would need a small shell script that calls mono /path/to/foo.exe.


Use an alias

put something like

alias foo='mono /path/to/foo.exe'

into the users shell initialisation file.


I would use the Filesystem Hierarchy Standard as a guide and install your package in /opt/package_name and place your wrapper script in /usr/local/bin or allow the user to configure these choices and generate the wrapper script at install-time based on those choices. An alternative would be to put the wrapper script in the same directory as the application and add the application directory to PATH in /etc/profile, but I consider this less desirable.


The simplest way is with a Bash alias. I'm not sure if it's normal practice to add an alias to profile files though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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