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