About nixCraft

Topics

Understanding UNIX / Linux filesystem directories

Posted by Vivek Gite [Last updated: September 25, 2007]

You use DNS (domain name system) to translate between domain names and IP addresses.

Similarly files are referred by file name, not by inode number. So what is the purpose of a directory? You can groups the files according to your usage. For example all configuration files are stored under /etc directory. So the purpose of a directory is to make a connection between file names and their associated inode number. Inside every directory you will find out two directories . (current directory) and .. (pointer to previous directory i.e. the directory immediately above the one I am in now). The .. appears in every directory except for the root directory.

Directory

A directory contained inside another directory is called a subdirectory. At the end the directories form a tree structure. Use tree command to see directory tree structure:
$ tree /etc | less
Again a directory has an inode just like a file. It is a specially formatted file containing records which associate each name with an inode number. Please note the following limitation of directories under ext2/3 file system:

However according to official documentation of ext2/3 file system points that “Using a hashed directory index (which is under development) allows 100k-1M+ files in a single directory without performance problems'. Here are my two favorite alias commands related to directory :
$ alias ..='cd ..'
alias d='ls -l | grep -E "^d"'


Well I'm sure all of you know the basic commands related to directories and files managment. Click above (or here) to see summery of all basic commands related to directories and files managment. See interesting discussion about soft links and directories. This is 6th part of "Understanding UNIX/Linux file system, continue reading rest of the Understanding Linux file system series (this is part IV):

Tell us how we're doing: Please answer a few questions about your experience to help us improve nixCraft.

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Nguyen Dinh Trung Says:

    Thanks alot.This article is very useful for my project call “Describe the files and directory model in Linux?UNIX”

  2. nixcraft Says:

    Nguyen,

    Glad to know article is helping out.

    Appreciate your feedback.

  3. Swapnil Says:

    Hi,

    Thx for the useful information abt the ext2 filesystem. What I want to find out is, whether any website is avbl for finding the detailed structure of a superblock ? i.e., all the fields that the superblocks stores, their valid contents, when are they changed, how r they affected when a file is changed etc…
    Thanks a lot in advance.

    -Swapnil

  4. steve Says:

    Heya,

    the correct command to go back to previous directory (as seen in table graphic) should be
    cd -
    not
    cd ..

    cd .. go to parent directory
    cd - return to previous directory

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , ,

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.