Home » Linux » Shell » What Does Dot Slash Mean In Linux

What Does “./” (Dot Slash) Mean in Linux?

In Linux, *./ (dot slash) represents the relative path to the current working directory. This article lays out exactly what it means and how to use it.

. (dot) and .. (double-dot)

. (single dot) and .. (double dot) are special directory names in Linux (And other *nix operating systems).

. represents the current directory.

.. represents the parent directory (of the current directory).

./ (dot slash)

So, the . in ./ represents the *current& directory – and the slash is the path delimiter so that what follows will refer to the contents of the current directory.

Example

To edit or create the file test.txt in the current directory:

nano ./test.txt

This is the same as running;

nano test.txt

As commands by default are executed in the current working directory.

So why do you see ./ frequently used when executing scripts and programs?

Executing Scripts Using ./

./ is used when executing programs and scripts to ensure that the program or script being run is in the current directory rather than a similarly named command that may exist on the system path (i.e., an installed application on the system).

Files with a – in the filename

There’s another common use for ./ – working with files with a  as the first character in the filename.

Consider a file called -L.txt in the current working directory. If you were to run:

nano -L.txt

…you would not edit the file but receive something similar to the following message:

nano: invalid option

…because the filename is wrongly interpreted as a command-line argument due to the dash.

This issue can be negated by running:

nano ./-L.txt

 

SHARE:
Photo of author
Author
I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Comment