file execution doubt
hi
Why it’s sometime necessary to prefix ‘./’ to run an executable file |
because the current directory isn't in the path.
the ./ means "in this directory". |
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. |