Dot Slash in Linux – What Does ‘./’ Mean in Linux?

command linefilenamesfileslinux

For example, I can do the following

touch a

or

touch ./a

Then when I do ls I can view both, so what exactly is the ./ for?

Best Answer

The dot-slash, ./, is a relative path to something in the current directory.

The dot is the current directory and the slash is a path delimiter.

When you give the command touch ./a you say "run the touch utility with the argument ./a", and touch will create (or update the timestamp for) the file a in the current directory.

There is no difference between touch a and touch ./a as both commands will act on the thing called a in the current directory.

In a similar way, touch ../a will act on the a in the directory above the current directory as .. refers to "one directory further up in the hierarchy".

. and .. are two special directory names that are present in every directory on Unix systems.


It's useful to be able to put ./ in front of a filename sometimes, as when you're trying to create or delete, or just work with, a file with a dash as the first character in its filename.

For example,

touch -a file

will not create a file called -a file, and neither would

touch '-a file'

But,

touch ./'-a file'

would.

Related Question