In web or desktop programming/command-prompt use, we often come through such situations where we have to use relative/absolute paths. Is there are any differences between the notation “./” and “/” ?

./

Yes, there are! When you use “./” we mean an relative path. Suppose, you are in the location http://www.somedomain.com/some_directory/index.html

Now, if you want to insert an Image file which is located at this directory “some_directory”, you can write following code in your index.html page:

<img src = "./myimage.jpg">

If you want to use an image from a directory “another_dir” on level up, you should use “../”

<img src = "../another_dir/another_image.jpg">

Both some_dir and another_dir are located under the home of your domain (www.somedomain.com).

/

Now, let’s talk about using “/”

“/” means beginning from the Root level of your file system. Suppose, in Linux, you want to Change your current working directory to the directory “etc”. Since “etc” is placed just in the Root directory of your file system (see the image below), you should type something like this in your command-prompt:

cd /etc

If you tried with the command “cd ./etc”, it wouldn’t work! Why? Because “./” means beginning from the Current Working directory. Normally, when you use a command-prompt it selects the user’s Home folder as current working directory. So if you want to go to a directory based on root level, you should use “/” instead of “./”

Image: Unix/Linux File System. See, the folder “etc” stays just below the “root” or “/”