Originally Posted by iochinome
oh, i just got it. you have to type in
is that the same for all programs?
Yes. As long as they directory where they reside is not in your $PATH. By default, and unlike in DOS and Windows, the current directory "." is not in your $PATH, which means that you will have to tell your shell where the binary lives, you can do so using a relative path, or an absolute one.
For example, if your program lives in /home/jochinome/ you could do this to run it:
As if you are already in /home/jochinome, you can do as you did:
Which means "run the file hello which lives on the current directory".
Alternatively you could also put this file in /usr/local/bin or another location that is on your path. To see your current path you could use this:
To add a directory to your path you can add this line into ~/.bashrc and ~/.bash_profile (create them if they do not exist, it's perfectly normal):
Then restart your shell, open a new one, or just run "exec bash" to reload this config files. Then create the bin/ directory inside your home, and from that moment, every executable file in that directory can be run by just invoking its name, just like any other system tool.
Feel free to ask for clarification if you need so.
and is this called an 'executable?'
Yes. That's a binary program file which I guess is what you wanted to ask. About it being executable, well, "executable" is just an attribute of files, you can turn it on/off for any file (another things is if that will actually be useful, that depends on the file). We use the chmod command for that. But that's for another thread.
There are lots of different executable files in linux, some are binary object code like those produced by C and compilers in general, just like the .exe files. Some others are scripts of any kind (perl, shell scripts which can also be of many types, lisp, ...).
Postscript: I really don't want to sound like a purist smartass of anykind, but you really should correct the habit of using .c for c++ sources, in the future you are going to have problems if you stick to that in both IDEs and with gcc/g++. The compiler will assume that you are using c syntax if you use .c as the file extension, and that will confuse it. You can read all the extensions that the compiler accepts in the man page, look this string into the man page, and it will show you: