• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • What is . and .. in Unix/Linux ?

    So, if you are reading this blog then you are confused with the fact that each of the directory in your linux/unix box contains a"." and ".." , what does this basically means?

    Well the answer is really simple, You just need to use a little bit of logic. Let me demonstrate you with an example.

    Scenario 1
    You need to go one step back of the current directory where you are. For eg. you are inside /home/deepak and you want to go to /home so what is the command you would run?

    # cd ..
    Now does that 2 dots used after cd makes any sense? I think you must have got my point and the usage of double dot in each directory.

    Scenario 2
    Try to find a file with name test inside the current directory and all directories inside the current directory. For eg. Find test file inside /home/deepak( which is your present working directory)

    # find . -name test -type f
    Now as you can see I have used a single dot "." to tell my system to only look in my current directory.

    So basically single dot "." means current directory which actually is a hardlink to its containing directory.
    You can verify the same using the below command
    [deepak@server work]$ ls -di . "$PWD"
    66232 .  66232 /home/deepak/work
    returns the same inode no.

    and double dot ".." means one step back i.e. the parent directory, that is the only directory where that directory is referenced from
    [deepak@server work]$ ls -di ..  /home/deepak/
    22 ..  22 /opt/fti/

    You can see the size difference between "." and".." accordingly below
    [deepak@server work]$ ls -al
    total 1592
    drwxrws--x  4 deepak deepak  2048 Nov 13 02:22 .
    drwxrws--x 23 deepak deepak  3864 Aug 22 09:57 ..

    I hope the article was useful.

    What is . and .. in Unix/Linux ? What is . and .. in Unix/Linux ? Reviewed by admin on Wednesday, December 25, 2013 Rating: 5


    Powered by Blogger.