0

If I have a program written in C, how can I run this program in a terminal with just a single word (the program's name), no matter where it is on the system?

2
  • 6
    Add the path to the program to $PATH.
    – Pilot6
    Aug 3 '16 at 14:13
  • 1
    What you really want is to have the location of your program added to $PATH variable, as Pilot6 properly said. See this askubuntu.com/q/60218/295286 Aug 3 '16 at 14:36
0

See this:

http://www.linfo.org/path_env_var.html

As Pilot6 and Serg wrote in comment, You have to expand your $PATH system variable and compile program in release mode. When you will have this done, you will call myProgram and your system should check if it exists ind $PATH directories; it will eventually run it if it exists, or show error "unknown command" if it doesn't.

0

The solution mentioned by adding more path elements worked for me. To run your C program, first of all you have to compile it. Once you compile your c program, it will generate a executable file. The path of your executable file must be present in $PATH system variable then only your system will able to find your executable program.

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