What is the meaning of ./ before a given path?
I've been told to run this:
./yiic message ./app/messages/config.php
But I don't understand the ./
meaning, can anyone clarify please.
Note: Believe me, we can't google that. I've tried:
./ meaning ./ ubuntu
It was the same as nothing. :(
./
or just .
is unix shorthand for the current directory.
You need to specify it when the current directory is not in your PATH. The PATH is the list of folders searched when you run a program. (You can determine it by writing echo $PATH
.) If an executable file is not in your PATH, to run it you need to specify the folder it's in. You could do this by giving the full path to the file, but if the file is in the current directory, you can use ./
as shorthand.
Similarly, ../
or just ..
is shorthand for the directory above the current one.
Every directory in the command line has two "special directories" called .
and ..
. These are shorthand for, respectively, the current directory and the directory containing the current directory.
So for example, cd ./more/directory/names
just means, "start at the current directory and continue in the path." Similarly, the command cd ..
means, "change one directory up.
If you want the name of your current directory, you can use the pwd
command. Also, if you use the -a
flag for ls
, you can see these two special directories. That is, ls -a
will output a list starting with .
and ..
.
Others have already explained what .
and ..
means (current directory and the parent directory respectively). This applies to all path names.
When you open a terminal, you usually start in your home directory: ~
(which expands to /home/username
). The below paths are all equivalent, providing your current working directory is /home/username
:
/home/username
.
../username
../../home/username
-
../../../home/username
(the parent directory of/
is still/
) -
./././././.
(the current directory in the current directory in the ...) -
./
(trailing slashes are allowed for directories) -
/home////username///
(and so are multiple slashes)
Do not confuse ./program
with . program
. ./program
runs a file in the current directory with the execute bit set. . ./program
is a bash thing and can alternatively be written as source ./program
which reads bash commands from the program
file in the current directory and executes them in the current shell.
If you wonder why you can just run gedit
instead of /usr/bin/gedit
and not program
instead of ./program
or /home/username/program
, see the related question:
- What are "$PATH" and "~/bin"? How can I have personal scripts?