1

I have a compiled program in a certain folder that I would like to access from anywhere without needing the write ./path/to/file/each/time/app_name. For example, the app executable is installed in this ./path/to/file/each/time/app_name path, and I would like to be able to open it by writing app_name in the command line, and nothing more than that. How could I do that?

2 Answers2

1

Create a script (as root) called /usr/local/bin/app_name and put this inside it:

#!/bin/bash

/path/to/file/app_name $@

Then make the script executable:

sudo chmod +x /usr/local/bin/app_name
0

Create an alias for your program in the .bashrc file.

nano ~/.bashrc

At the end of the file type the line:

alias app_name=/path/to/file/each/time/app_name

Then save (CTRL+O then Enter) and exit (CTRL+X).

You will be able to use the alias in new Terminal windows you open.

Alejandro
  • 745