In what directory will the command cd .. not do anything at all?


#1

Transfered from Linux Config Disqus comments:

Question:

In what directory will the command ‘cd …’ (note the two dots in this command) not do anything at all?

Answer:

In root directory “/”.

Since the … directory points to a parent directory and / ( root directory ) is on the top of the file system hierarchy standard and therefore it does not have a parent directory, the “cd …” command will not do anything at all. We may also say that / directory is a parent directory of itself. Try:


$ cd /
$ pwd
/
$ cd ..
$ pwd
/


Long Answer:

Every directory in the linux file system contains two special directories and they are:
[ul]
[li]"." a current working directory [/li][li]"…" a parent directory [/li][/ul]

To see these special directories enter command:

ls -a

Current working directory “.” points to itself.

Examples:

The command below will copy a file from /tmp directory to a current working directory:

cp /tmp/file .

Ore check disk space mounted below my current working directory:

df -h .

Parent directory “…” points to a directory one above my current working directory.

Examples:

Use a symbolic path to navigate to different directory in the same parent directory:

$ pwd
/tmp
$ cd ../etc/
$ pwd
/etc

Navigate two directories above my current directory:


$ pwd
/etc/terminfo
$ cd ../..
$ pwd
/

#2

#3

#4