LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   file execution doubt (https://www.linuxquestions.org/questions/linux-general-1/file-execution-doubt-96638/)

pongsu 09-25-2003 03:30 AM

file execution doubt
 
hi

Why it’s sometime necessary to prefix ‘./’ to run an executable file

whansard 09-25-2003 03:42 AM

because the current directory isn't in the path.
the ./ means "in this directory".

coolamit78 09-25-2003 01:23 PM

Well yes, I would just like to give some more details for those who find the answer a bit complicated or those just migrating from windows to Linux platform....

In Unix/Linux, there are 2 kinds of paths:

1. Absolute Path
2. Relative Path

1. Absolute Path -> This is the complete path which needs to be given in order to execute a particular file in relation to the root directory(/).
for example, to run the command 'clear' which is located in /usr/bin, we can specify the complete path to the command...i.e

$ /usr/bin/clear

2. Relative Path -> A Relative path does not be start with a '/'. It specifies the path in relation to the 'current directory'.

There are 2 shortcuts that the system creates for every directory file created namely (.) and (..) where (.) stands for the current directory and (..) means the parent directory (one-level up).

So, suppose, if our present working directory is /usr/local/bin and we want to execute the clear command, located in /usr/bin then the relative path will be as follows:

$ ../../bin/clear

Thus, ./filename infoms the shell that the file <filename> is an executable located in the current directory.

for example

[user@localhost bin]$ ./configure [. stands for /usr/bin]


All times are GMT -5. The time now is 04:53 PM.