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.

What does ./ mean?

For example: Does the following command mean moving files from Gapache2 folder to sites-available:

root@ip-10-112-55-203:/etc/mds-1.2-beta4/sana/config/etc/Gapache2# mv ./ /etc/apache2/sites-available

If not how should this be modified?

I tried getting something from Google Search. But ./ gets ignored by search engines.

share|improve this question

2 Answers 2

up vote 8 down vote accepted

In Unix/linux . means the current directory in your case /etc/mds-1.2-beta4/sana/config/etc/Gapache2. There are also many shortcuts like:

  • ..: parent directory (/etc/mds-1.2-beta4/sana/config/etc/)
  • ~: home folder

So to move all folders and files from /etc/mds-1.2-beta4/sana/config/etc/Gapache2 to /etc/apache2/sites-available, the command will be like this

mv ./* /etc/apache2/sites-available/

UPDATE: This link is a good resource for basic UNIX commands

share|improve this answer
    
To move hidden files too, actually you need a more sophisticated glob expression (or different shell settings). See stackoverflow.com/questions/1586477/… –  Andrea Corbellini Feb 3 '13 at 10:50
    
(pretending to be a new user in this comment) "./ means the current directory" What is the difference between . and ./ then? I thought that just . means the current directory. –  gertvdijk Feb 3 '13 at 11:11
    
@gertvdijk : Updated the answer. :) –  aneeshep Feb 3 '13 at 12:19

About .

In UNIX/Linux, . means the current directory. You'll also see it listed in ls commands:

ls -al
total 40348
drwx------  20 root root     4096 Feb  2 23:05 .               <-- there!
drwxr-xr-x  24 root root     4096 Jan 31 20:07 ..
-rw-r--r--   1 root root      322 Dec 16 17:35 20-revert

Slashes, ./ and the symbolic links

When appending the / to it, this has the same meaning as appending a / to any other directory name. It will just make sure you're not operating on a file. Generally, this will not be a difference in cp and mv commands, but you will see a difference when you're using symbolic links. Suppose this structure:

.                                                                   
├── a                                                               
├── dir1
│   ├── b
│   └── c
├── dir2
│   └── d
└── symlink -> dir2

Then a regular listing will show the link itself

ls -l symlink
lrwxrwxrwx 1 gert gert 4 Feb  3 12:15 symlink -> dir2

but appending the / will make it list descend into it and showing the contents.

ls -l symlink/
total 0
-rw-rw-r-- 1 gert gert 0 Feb  3 12:15 d

This means that when using operations, it's a good thing to append the / if you refer to the contents of it or you want to copy/move into it by dereferencing the link, rather than replacing the link itself.

See also: Trailing slashes on symbolic links to directories

Back to the example

In the example in your question you really want to only move the contents of the directory into the other. So, as aneeshep pointed out, you should use mv ./* destdir/. This is the same as mv * destdir/ as your shell (Bash) expands the * from the current directory by default.

So, I would run it like this (in the source directory):

mv * /etc/apache2/sites-available/
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.