-   Linux - Newbie (
-   -   Running executables in Red Had (

lyar1031 07-14-2005 11:04 PM

Running executables in Red Had
I am kind of new to Linux. I am running Red Hat 8.0.

To run a executable you type ./<file> Is there a way where you can run the executable by just typing the file name.

For example:
./a.out ----> a.out


nadroj 07-14-2005 11:32 PM

yes there is a way to do this.
the './' in './<filename>' means to look in the current directory (.) and execute the file. when you run commands like 'ls' or 'man' the reason you dont have to specify their full path is because the computer knows where it is. there is a environment variable when your logged in called $PATH. the computer (shell) knows about this variable, and inside the variable is a list of paths to folders where the computer will look when you run commands. when you run a command like 'ls', the path to that is stored in this variable, and the shell checks the list of variables looking for the file/command (ls) and then knows how to execute it/where it is.
you can view your current path variable by typing 'echo $PATH', i believe, at the console. the list is colon delimited.. meaning its a long list and each entry is seperated by colons.
search yahoo or google for how to modify your path variable, if need be.

i read in a linux book i had last year for school that if you put your current path (.) in the $PATH variable it is a security risk.
if its just one filename/path you want to add then, read up about how to add it, and try it! but dont put '.' in the path variable.

Matir 07-14-2005 11:35 PM

If you just want to type the filename, then you need to have that directory in your PATH. To see your current path and add a new directory: (edited for brevity)

$ echo $PATH
$ PATH=$PATH:/opt/utilities
$ echo $PATH

I could now run programs located in /opt/utilities just by name.

All times are GMT -5. The time now is 11:53 AM.