I don't understand the difference between path and directory. Could someone explain to me with examples?


3 Answers 3


A directory is a "folder", a place where you can put files or other directories (and special files, devices, symlinks...). It is a container for filesystem objects.

A path is a string that specify how to reach a filesystem object (and this object can be a file, a directory, a special file, ...).

Example: you have (probably, depending on your system) a file where system messages are logged, called syslog.

It normally sits in a directory named log which is contained in a directory named var which is in the root directory of your filesystem.

Now, /var/log/syslog is a path to that file (an absolute path in that case), as /var/log is a path to the directory that contains the file. /var/spool/../log/syslog is also a path to the syslog file too (if /var/spool exists).

Paths can be relative, too. So if your current directory is /home/user, the path ../../var/log/syslog is a relative path to the same file, too (you know it's relative because it doesn't start with /).

And in your home directory, if you create a symlink to /var/log like this:

ln -s /var/log myvarlog

then myvarlog/syslog is another path to our file.

  • I'd like to know the reason for the downvotes. Is there something incorrect in the answer?
    – Rmano
    Jan 31, 2016 at 9:47
  • 2
    Unfortunately, there is no way to know downvoters motivations. In any case, your answer is absolutely correct.
    – jlliagre
    Jan 31, 2016 at 10:09

Directory is where you are.

Path is how to get there.


pages is a directory

/var/www/public/site/pages/ is the path to files in that directory. This is an absolute path.

/var/www/public/site/ is the path to that directory.

./pages/ may be a path to files in that directory, if you are currently working in /var/www/public/site/. This is a relative path.


On Linux, The terminology "directory" usually have two different meanings:

A. Unopened directory. Part of a "normal"(can be used to store data freely, like tmpfs or ext4, not used to expose kernel functionality, like procfs or sysfs) filesystem, usually consist of uniquely named pointers to other parts of the filesystem(other files or directories).

B. Open file description of a directory. A kernel object, which is a handler to A or some sort of interface to a kernel functionality.

The terminology "Path" is just a string which let you refer to one instance of A when constructing an instance of B.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.