LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I have a stoopid noob question!! (https://www.linuxquestions.org/questions/linux-newbie-8/i-have-a-stoopid-noob-question-310346/)

sharvey44 04-06-2005 10:37 AM

I have a stoopid noob question!!
 
What's the difference between running a program with the prefix ./

I.e.

$ ./program <arguement>

$ program <arguement>

I know its stupid one but i cant find the answer anywhere!!

Cheers

phil.d.g 04-06-2005 10:39 AM

the ./ represents your working directory. As a normal user you normally have ./ in your path so don't need to bother with it, but when your root you don't, so you need the ./ to execute a script or program in the current directory

merchtemeagle 04-06-2005 10:41 AM

Quote:

$ ./program <arguement>
This searches the current directory.

Quote:

$ program <arguement
This searches the $PATH.

rose_bud4201 04-06-2005 12:13 PM

Continuing on what merchtemeagle said, $PATH contains a colon-separated list of all the directories linux by default looks in when you type the name of an executable.

You can find out if "." (i.e. whatever directory you're currently in) is in your $PATH by doing

echo $PATH

Example:
[lthurber@hostname ~]$ echo $PATH
/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/opt/IBM/director/bin:/opt/gnome/bin:/sbin:/home/lthurber/java/bin:/usr/local/ant/bin:/home/lthurber/projects/citicom/build/dev:/usr/java/bin:/usr/local/ant/bin:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc

If you look closely you can see that I do in fact have . in my path - right there between /opt/kde3/bin and /opt/IBM/director/bin :)

If it is there (as it usually will be, for a regular user) you won't have to type the ./ to run a program in your current directory.


All times are GMT -5. The time now is 07:42 AM.