What does ./ mean?

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.


Solution 1:

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

Solution 2:

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/