How to Execute a program from anywhere in terminal

How could I execute a program which I downloaded from website and able to execute from $HOME directory or anywhere in terminal?

Thanks, Peace

1

2 Answers

Lets say the command you have to run to execute the program is ./path/to/file and programs name is xyz

So create a .bash_aliases file in your home directory. Add the line to the file create a alias for the command.

alias xyz="./path/to/file"

Save the file and restart terminal.

Next time you can run the program by typing just xyz

0

If you currently have to run your program by giving the full path (say, /home/john/someprogram-1.0/someprogram), you can make it so the program runs by just typing someprogram. For this, you need the program to be somewhere in your PATH, which is a list of directories the shell searches for executables that aren't given as full paths.

There are three ways of accomplishing this:

  1. Install the program. Depending on where it came from, it probably has installation instructions which will place it in a directory already in the path, like /usr/bin. Be aware that installing it this way needs using sudo, or having root privileges.
  2. Add the directory where the program is right now to your path. You can try this manually by first doing export PATH=$PATH:/home/john/someprogram-1.0, then trying to run someprogram only, it should work. TO make this change permanent, add the export command as shown above to your .profile file (this file already exists in your home directory).
  3. Put the program in your private bin directory. Create bin in your home diretory, then copy the someprogram file into this directory. This may not work if the program needs access to other data files.
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like