What does the ./ mean (dot slash) in linux?
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.
The ./
notation is useful when trying to run a script or other executable in the current directory. Unlike the Windows command prompt, Unix (and Unix-like systems like Linux) shells do not check the current directory for executables before checking the PATH
environment variable, and Unix systems tend not to include ./
in the PATH
for security reasons. By having to specify
./executable
rather than just
executable
the user is saying, "yes, I do want to run this executable in the current directory"
This is called a relative path.
.
represents the current working directory. So if you are currently in /home/jesse
, .
is simply a link to /home/jesse
so when you point to ./
you are really pointing to /home/jesse/