Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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. :(

share|improve this question
3  
In these cases, the best is to look for "dot slash", which gave this very useful result: linfo.org/dot_slash.html –  heltonbiker Sep 7 '11 at 2:11
    
Nice idea. Indeed. :) Thanks. –  MEM Sep 7 '11 at 15:02

4 Answers 4

up vote 26 down vote accepted

./ 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.

share|improve this answer
15  
Someone should include in their answer why $PATH does not contain .. It is because automatically using the current directory is a security hole. Imagine someone else makes a program, names it ls and you cd into his directory, then type ls –  Zan Lynx Sep 6 '11 at 20:23
    
@Zan I've always wondered this, thanks for your answer to the question that nobody asked, but someone should have. –  crasic Sep 7 '11 at 6:31

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 ...

share|improve this answer
    
excellent addition root45 +1 :) –  Rinzwind Sep 6 '11 at 17:04

It means to start from the current directory path.

Let's assume you have a path like this:

/usr/ /usr/bin/ /usr/local/bin

and inside /usr/bin/ there is an executable called yiic.

If you issue yiic it would start the one in /usr/bin/.

By issueing ./yiic you tell the system to look inside the current directory for this executable.

share|improve this answer
    
Ok... but I don't still get. Let's say I have yiic inside /home/mysuser/ and that I navigate there by using cd /home/myuser . Once inside, I believed that doing just yiic, it should work because I've called while on that directory. But he says command not file. If I do the same, and I use the ./ then, it runs properly... Can you please clarify a little bit more? –  MEM Sep 6 '11 at 17:08
    
@frabjous as answered this comment as well. –  MEM Sep 6 '11 at 17:09
    
Nope! it will always look in the PATH directive unless you tell it to use the current directory (by using ./). Look at user45's answer: . is a special file inside a folder that you can see when doing a ls -la in the directory ;) –  Rinzwind Sep 6 '11 at 17:11

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:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.