What is the difference between directory structure and file system?
Unix/Linux directories and file system looks as follows:

The following two directories obviously we know directories.

  /home/abc/xyzdir1 --is a directory
  /home/abc/xyzdir2 -- is a directory

the following three samples are saying file system.

/proc -- is a file system
/ -- is a file system
/bin -- is a file system

How can I identify which one is a file system and a directory from the above code snippets?

  • A filesystem contains one or more directories. Every directory is part of a filesystem (including /proc, /, and /bin from your examples), so I'm not clear how you want to identify the "difference". – roaima May 18 '15 at 13:18
  • @roaima please find code snippet for sample – Premraj May 18 '15 at 15:29
  • Your question is still ambiguous. /proc, / and /bin are directories. They are not "filesystems". Do you perhaps mean you want to identify which directories are also the mount point (root) of their filesystem? – roaima May 18 '15 at 18:02

People don't use file system too carefully. In your examples, I would say that /, /bin and /proc are file systems because an entire partition (like /dev/sdb1) is mounted on those directories. My Arch linux system doesn't have /bin as a file system so this example isn't perfect but...

% ls -lid /proc /home /boot /
2 drwxr-xr-x  17 root root 4096 Feb 24 12:12 //
2 drwxr-xr-x   4 root root 4096 May 16 14:29 /boot/
2 drwxr-xr-x   5 root root 4096 Mar 14 18:11 /home/
1 dr-xr-xr-x 116 root root    0 May 16 17:18 /proc/

Inode number 2 is traditionally the "root" inode of an entire on-disk file system (which is the other usage of the phrase). /, /boot and /home all have inode number 2, while /proc, which is presented entirely by the kernel and does not have an on-disk presence, has inode 1. Those inode numbers indicates that a whole, on-disk file system, or a virtual file system is mounted using that name.

The sentence '/home/abc/xyzdir1 is a directory" basically means that no on-disk file system is mounted using that name. If you do the same ls -lid command on a directory you get something like this:

 % ls -lid /home/bediger/src
3670039 drwxr-xr-x 29 bediger bediger 4096 May 17 19:57 /home/bediger/src/

Inode number 3670039 is just whatever inode got allocated from in the on-disk file system mounted (on my machine) at /home.

You could also find file systems by invoking the mount command. It lists all mounted file systems and where they are mounted.

  • The "magic inode" number is specific to the ext2 series of filesystems. It does not apply to most ( all? ) others, such as xfs or btrfs. – psusi May 18 '15 at 21:03
  • I would say that /, /bin and /proc are file systems because an entire partition ... is mounted on those directories. This is not true for /proc, as the answer later implies. – Max Nanasy May 18 '15 at 22:12
  • 1
    @MaxNanasy - given that two meanings of "file system" are in common use (1. The names and arrangement of directories in a tree structure, and 2. The on-disk format and layout of file and directory structured data, along with the code to maintain and use it), it's pretty hard to come up with a term that's both comprehensible, not defined in a circular fashion, and technically correct. I chose to go with comprehensible and used "partition" instead of other terms. I invite you to suggest term(s) that are more correct, I'm at a loss. – Bruce Ediger May 18 '15 at 22:21

At the risk of grossly oversimplifying,

  • A filesystem is like your car's engine and other internal systems,
  • A directory structure is like a map of the places where you drive.

Since I’ve been asked for an encore,

  • Filesystems are like the mechanics (implementation details) of audio/video signal distribution/propagation: analog RF broadcast, digital RF broadcast, cable, Internet, video tape, video disk, etc.
  • Directory structure is like the content of television programming, and the categorization thereof, e.g., into comedy, drama, news, documentaries, games shows, sports, etc.

If you want code, see the first half of this answer to How to determine whether a Linux filesystem belongs to a running system — the part that does validation checks on root_dir.  It’s just doing what Bruce said; verifying that it is a directory and checking whether its inode number is 1 or 2.

  • 1
    Good ELI5, but could you add a code snippet answering How can I identify which one is a file system and a directory? – user1717828 May 18 '15 at 13:16

The way I see it, a filesystem, in the UNIX sense, is a way of implementing a directory tree (directory structure), or more precisely, a way of implementing the UNIX filesystem API. The root file system is backed by one particular implementation, and whenever you enter a mountpoint directory, you enter a subtree that's backed by something different.

The interface is always the same, but in one case, you have a particular disk partition at the back end, in another case, there will be a program that never even writes to a storage device. The proc filesystem will be backed by software that exposes kernel internals; an tmpfs will be backed up by software that writes to RAM, and other file systems might write to the network or elsewhere.

In the non-UNIXy sense of the word, a file system is a way of organizing data storage. ext4, btrfs, fat, and ntfs are file systems in this sense, but also in the UNIXy sense—they implement the filesystem API. proc wouldn't classify as a filesystem within this, more limited, paradigm as it doesn't organize data storage.


  • directory structure/tree = front end
  • file system = back end

While directory acception is unambiguous when talking about file systems, file system might mean different things depending on what you are talking about.

In your examples, all the listed paths are directories but only some of them are also mount points of file systems.

You can use the df command to known on what file system a given file or directory is, and the mount command on most Unix and Linux implementations to figure out what file systems are present on your machine, their type and their mount points. eg:

$ df /proc
Filesystem     1K-blocks  Used Available Use% Mounted on
proc                   0     0         0    - /proc
$ mount | grep -w /proc
/proc is a file system of type proc

The statement /bin is a file system is dubious, /bin is almost always mounted on /.

$ df -k /bin
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sda5      206292664 180687360  15103212  93% /
$ mount | grep -w /
/dev/sda5 on / type ext4 (rw,errors=remount-ro)

First a correction to your assumption about a filesystem and a directory. A filesystem contains one or more directories. Using your examples, /proc, / and /bin are directories. They are not "filesystems" in and of themselves, but they might be the root of their respective filesystems.

If you want to identify which directories are also the mount point (root) of their filesystem you can use something like this:

F="$PWD"    # The directory to be tested
if test -d "$F"
    echo "$F is a directory"
    test "X$(stat --format '%m' "$F")" = "X$PWD" && echo "$F is a mountpoint"

File System is a methodology for logically organizing and storing large quantities of data such that the system is easy to manage. a file system consists of files, relationships to other files, as well as the attributes(file type, file name, file size, file owner, file timestamp) of each file.

Directories: for example, the Unix file system is essentially composed of files and directories. Directories are special files that may contain other files. the top-most directory is / (slash), with the directories directly beneath being system directories. enter image description here

/ Root of Linux Filesystem

/bin Binary Executable files are kept here

/boot Booting related files are kept here

/dev Device files are kept here

/etc System-wide configuration files are kept here

/home Location for the home directories of regular users

/lib64 Libraries for binary executables are kept here

/mnt Temporary mount point for DVD-Rom, USB flash drive.

/opt Optional Programs are installed here like Program Files in windows

/proc Kernel pseudo filesystem

/root Home directory of super user root

/sbin System Binary Executable files are kept here

/tmp Temporary files are kept here

/usr User Filesystem

/var Variable files are kept here

/srv is a serve folder, contains site-specific data which is served by this system.

src and for more

The following two directories are user defined directories:

 /home/abc/xyzdir1 --is a directory
 /home/abc/xyzdir2 -- is a directory
  • That diagram is woefully out of date. FHS 3.0 was released in June 2015. It should also be noted that FHS applies only to Linux distributions. – fpmurphy Feb 22 '17 at 4:08

If you just need a command that tells you if path is a directory or not use mountpoint(1).

For me it prints

$ mountpoint /
/ is a mountpoint
$ mountpoint /bin
/bin is not a mountpoint
$ mountpoint some-file
some-file is not a mountpoint

The good thing is that the exit status indicates the same again so you can use it in your scripts like this:

if mountpoint "$foo" >/dev/null; then
  : do mountpoint stuff
elif [ -d "$foo" ]; then
  : do directory stuff
elif [ -e "$foo" ]; then
  : do file stuff 
  echo "$foo does not exist!" >/2

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.