1

Hi,

I've created a small program in C++ I would like to run like a command from the terminal. With that I mean that I can open the program from and in the terminal (as it is a console application) regardless of which directory I'm in, without having to specify the path to the program. I know how to arrange it so that I would only have to type /program_name, but I'm interested in how the above would work. Thanks in advance!

muru
  • 197,895
  • 55
  • 485
  • 740
simeon
  • 13

1 Answers1

0

You can either copy your executable to some folder in your $PATH (if you compiled your app statically) to see what is in your $PATH type:

echo $PATH

/usr/local/bin is probably the best choice. So copy it there by:

sudo cp yourexe /usr/local/bin

Or you can add additional directory to your PATH. You can do this by putting:

PATH=$PATH:/path/to/some/folder

in your ~/.profile file. Read more about it here. You will probably need to logout after doing this.