Operating System - Linux
1752794 Members
6407 Online
108789 Solutions
New Discussion юеВ

Re: why it is required to place a ".", & a "/" b4 executeables, to run ?

 
SOLVED
Go to solution
Maaz
Valued Contributor

why it is required to place a ".", & a "/" b4 executeables, to run ?

Hi Dear Experts

why in linux executeable files are run as
# ./executeable_file_name

why it is required to place a period ".", and a slash "/" before executeable files, to run ?

Regards
Maaz
4 REPLIES 4
Chris Xu
Trusted Contributor
Solution

Re: why it is required to place a ".", & a "/" b4 executeables, to run ?

The "." indicates the current directory and "./filename" tells the system to run the file "filename" at the current directory, not to execute any other files with the same "filename" at a different location. So "./" is not required to run executable files. It is rather for the system to know which executable file to run. You can also run the executable by specifying the full path like /path-to-file/executable_file_name.

Chris
John Poff
Honored Contributor

Re: why it is required to place a ".", & a "/" b4 executeables, to run ?

Hi,

You have to specify "./" in front of your executeable because you don't have "." in your $PATH environmental variable, which is a good thing. Otherwise, some sneaky person could create a Trojan executeable named 'ps' or 'ls' and put it in a directory, waiting for you to run it.

JP
HGN
Honored Contributor

Re: why it is required to place a ".", & a "/" b4 executeables, to run ?

Hi

I think by this you would have understood the reason to sepcify a ./ is that the current directory or path where you are is not the PATH environment. As mentioned by others here it is also kind of a security thing so that you know where the executable is and can execute it.

Rgds

HGN

Maaz
Valued Contributor

Re: why it is required to place a ".", & a "/" b4 executeables, to run ?

dear Chris Xu, John Poff, and HGN I m highly thankful to u all, for replying and providing such a good/easy explanation.

John Poff the security issue u describe is no doubt is a very nice benefit, and feature. I m highly thankful to u for describing the security issue.

again Thanks a Million
Regards,
Maaz