# simple question about executing a command



## killwin (Mar 24, 2010)

Hello !

Sorry for this stupid question, but i can't remember.

I compiled a command gcc sample.c -o sample
I copy it into /usr/local/bin/sample

How to execute sample without path ./usr/local/bin/sample ?
I want to execute it in all paths in a shell with simply "sample".

(A solution with automake/autoconf/Makefine.am is ok)

Thanks


----------



## jotawski (Mar 24, 2010)

may be wrong but allow me to show off my dumb

put /usr/local/bin in your PATH environment variable  but the first time after moving to that you need to rehash if you are using csh.

apologized me for disturbing

best regards,
jotawski


----------



## SirDice (Mar 24, 2010)

jotawski said:
			
		

> put /usr/local/bin in your PATH environment variable  but the first time after moving to that you need to rehash if you are using csh.


/usr/local/bin/ is part of PATH by default.


----------



## DutchDaemon (Mar 24, 2010)

Is 'sample' executable? It should show up in csh when you type [cmd=]sa[ctl+d][/cmd] or in bash when you type [cmd=]sa[tab][tab][/cmd].


----------



## gcooper@ (Mar 26, 2010)

Also make sure that the command is properly hashed.

For bourne shell (/bin/sh and bash):

```
hash -r
```
 or 
	
	



```
unhash
```

For csh (and I think ksh):

```
rehash
```


----------



## killwin (Apr 3, 2010)

*solved*

It was a stupid problem sorry.

I removed with accident a line in my .cshrc : set path = ...

Thanks everybody.


----------

