Software Installation – How to Install Executables

executablegnome3software installation

I sometimes run into software that is not offered in .deb or .rpm but only as an executable.
For example Visual Studio Code, WebStorm or Kerbal Space Programm.

For this question, I will take Visual Studio Code as the point of reference.

The software is offered as a zipped package.
When unzipping, I'm left with a folder called VSCode-linux-x64 that contains a executable named Code.
I can double click Code or point to it with my terminal like /home/user/Downloads/VSCode-linux-x64/Code to execute it.
However, I would like to know if there is a proper way to install this applications.

What I want to achieve is:

  • one place where I can put all the applications/softwares that are
    offered in this manner (executables)
  • terminal support (that means for
    example: I can write vscode from any folder in my terminal and it
    will automatically execute Visual Studio Code.

Additional info:

  • Desktop Environment: Gnome3
  • OS: Debian

EDIT:
I decided to give @kba the answer because his approach works better with my backup solution and besides that. Having script executing the binaries gives you the possibility to add arguments.
But to be fair, @John WH Smith approach is just as good as @kba's.

Best Answer

To call a program by its name, shells search the directories in the $PATH environment variable. In Debian, the default $PATH for your user should include /home/YOUR-USER-NAME/bin (i.e. ~/bin).

First make sure the directory ~/bin exists or create it if it does not:

mkdir -p ~/bin

You can symlink binaries to that directory to make it available to the shell:

mkdir -p ~/bin
ln -s /home/user/Downloads/VSCode-linux-x64/Code ~/bin/vscode

That will allow you to run vscode on the command line or from a command launcher.

Note: You can also copy binaries to the $PATH directories but that can cause problems if they depend on relative paths.

In general, though, it's always preferable to properly install software using the means provided by the OS (apt-get, deb packages) or the build tools of a software project. This will ensure that dependent paths (like start scripts, man pages, configurations etc.) are set up correctly.

Update: Also reflecting Thomas Dickey's comments and Faheem Mitha's answer what I usually do for software that comes as a tarball with a top-level binary and expects to be run from there:

Put it in a sane location (in order of standards-compliance /opt, /usr/local or a folder in your home directory, e.g. ~/build) and create an executable script wrapper in a $PATH location (e.g. /usr/local/bin or ~/bin) that changes to that location and executes the binary:

#/bin/sh
cd "$HOME/build/directory"
exec ./top-level-binary "$@"

Since this emulates changing to that directory and executing the binary manually, it makes it easier to debug problems like non-existing relative paths.

Related Question