b5media.com

Advertise with us

Enjoying this blog? Check out the rest of the Technology Channel Subscribe to this Feed

New Linux User

EXPLANATION: What Does ‘./’ Mean in GNU/Linux?

by Jon on September 28th, 2005

In Windows or DOS the current directory is included in the path search. In GNU/Linux, it is not implicity included.

For example, if you are in the directory C:\TEMP on a Windows machine, and the path is C:\WINDOWS;C:\WINDOWS\SYSTEM and you attempted to run an application in the C:\TEMP directory - it would succeed. This is because Windows added the current directory (C:\TEMP) to its search path.

Conversely, if you are in the directory \home\fred\temp on a GNU/Linux machine, and the path is \usr\bin:\usr\sbin and you attempted to run an application in the \home\fred\temp directory - it would fail. This is because GNU/Linux does not add the current directory (\home\fred\temp) to its search path.

The dot-slash means ‘current directory’. Therefore, preceeding a file name with the dot-slash (./) tells GNU/Linux that the application indicated resides in the current directory. Therefore, in the above example (using foo.sh as an example application) typing ./foo.sh in the /home/fred/temp directory would succeed.

As would qualifying the full path, /home/fred/temp/foo.sh

You can also use the ./ to indicate the current directory during other operations such as file copying and moving.

POSTED IN: Explanation

2 opinions for EXPLANATION: What Does ‘./’ Mean in GNU/Linux?

  • Mike D'agostino
    May 26, 2008 at 7:56 am

    Good definition to above. I have another question… What does “. ./script_name.sh” mean before running a script file? I know it means to runf script file in present directory, but what is the first “.” mean before the ” ./script_name.sh” ?

  • Fevrin
    May 30, 2008 at 8:45 am

    Mike, “../” is used to signify the parent directory of the current directory. So if you run “../script_name.sh”, the computer will look for that file in the directory in which the current directory resides. With “../” and “./” you can get really fancy and perform commands in the terminal on files several directories away, although this wouldn’t be very intuitive.

Have an opinion? Leave a comment:




Check Spelling
Activate Spell Check while Typing