. (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.
To edit or create the file test.txt in the current directory:
This is the same as running;
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:
…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: