Having program in /home/user/Downloads/program/main

I can launch it by following command cd /home/user/Downloads/program && ./main or from GUI.

What I want is to launch it from terminal by typing main I tried to do ln -s /home/user/Downloads/program/main /usr/local/bin or to /bin but it had no effect.

Before linking I issued chmod +x command.

This is compiled program, error message I get is main: command not found

What I'm doing wrong?

  • Is there any error message when you try to run the program? And is it a script, or a compiled program? – Nathan.Eilisha Shiraini Jul 21 '16 at 15:00
  • @NathanShiraini, compiled program, message main: command not found – micgeronimo Jul 21 '16 at 15:02
  • Theorically you just have to chmod +x it and put it or a link to it in a folder in your PATH. To see these folders, run the command echo $PATH. – Nathan.Eilisha Shiraini Jul 21 '16 at 15:05
  • already did this. I thought I'm doing something wrong – micgeronimo Jul 21 '16 at 15:09
  • Can you please provide the output of ls -al /home/user/Downloads/program/main, to verify permissions? – jehad Jul 21 '16 at 15:10

It looks like you need to add that directory to your path. The exact command to do this depends on which shell is in use. For bash, you'll need something like:

export PATH=$PATH:/home/user/Downloads/program/


  • The PATH=$PATH keeps the existing path as part of the new path your are creating.
  • The :/home/user/Downloads/program/ adds that directory to the path (at the end, so it is the last thing searched).
  • The export puts the path in the shell so that it stays there. You might not need that part for a single session. However, if you want to keep this in future login sessions, you'll want to add this to your .bashrc (or other file that gets executed when you login).

When you add a new program to the path, you need to type


For it to be known to the shell.


As a fast fix you can make an alias. Add to you ~/.bashrc file this:

alias main='/home/user/Downloads/program/./main' 

then run exec bash in your terminal and it should work. If you're not using bash something similar would work for other shells. For example writing to the file ~/.zshrc for the zsh shell.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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