Running a program without "./"

When I write my own programs in C, I obviously run the executable by using ./<my program name> and it works. But, I was wondering if there was a way to run programs by just typing the program name and I think this is possible since I can run firefox 3 by just typing in firefox3.

PS. Where can I find the system utility "ls"? should it be in bin?
 
Add . to the path in .profile (security risk) or move the prog to somewhere in the path (/usr/local/bin etc)

find / -name (something) is your friend.
 
michaelrmgreen said:
Add . to the path in .profile (security risk) or move the prog to somewhere in the path (/usr/local/bin etc)
It can be a security risk but only if you put . (cwd) first in your path. When you put it at the end the risk is a lot less.

For my own applications/scripts etc I usually create a ~/bin directory and add that to my path.
 
Poincare said:
PS. Where can I find the system utility "ls"? should it be in bin?
If you can run ls(1) without full path (like /bin/ls) then it is in ${PATH}, so you can use which(1) to find it:
Code:
$ which ls
/bin/ls
$
 
vermaden said:
ls(1) is not a builtin(1) command, its separate /bin/ls program, ls-F(1) is csh shell builtin(1):
Oh yeah, you're right :e
 
Back
Top