# Running a program without "./"



## Poincare (Jul 23, 2009)

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?


----------



## michaelrmgreen (Jul 23, 2009)

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.


----------



## SirDice (Jul 23, 2009)

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.


----------



## vermaden (Jul 23, 2009)

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:

```
$ which ls
/bin/ls
$
```


----------



## SirDice (Jul 23, 2009)

Poincare said:
			
		

> PS. Where can I find the system utility "ls"? should it be in bin?


It's a shell builtin. See builtin().


----------



## vermaden (Jul 23, 2009)

SirDice said:
			
		

> It's a shell builtin. See builtin().



ls(1) is not a builtin(1) command, its separate /bin/ls program, ls-F(1) is csh shell builtin(1):

```
~ % which ls-F
ls-F: shell built-in command.
~ % which ls
/bin/ls
```


----------



## SirDice (Jul 23, 2009)

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


----------

