Understanding UNIX / Linux File Systems

A conceptual understanding of the file system, especially data structure and related terms will help you become a successful system administrator. I have seen many new Linux system administrator without any clue about the file system. The conceptual knowledge can be applied to restore the file system in an emergency situation.

What is a file in Linux or Unix?

A file is a collection of data items stored on disk. Or, it is a device which can store the information, data, music (mp3 files), picture, movie, sound, PDF book and more. All data must be stored on your computer in the form of a file. Files are always associated with devices like hard disk, floppy disk, USB pen drive and more. A file is the last object in your file system tree. See Linux/UNIX – rules for naming file and directory names.

How to list directory contents

Use the ls command:
ls -l
ls -Fl
ls -l /etc/

ls command on Linux and Unix

Using ls command to list information about the files on Linux and Unix-like systems

The ls -l command gives full information and indicates the type of filesystem object stored on disk. For example:

drwxr-xr-x  3 root root     4096 Apr  4  2018 acpi
-rw-r--r--  1 root root     3028 Apr  4  2018 adduser.conf

The following information is displayed for each file from above outputs:

Field Description
drwxr-xr-x File mode
3 Number of links to file
root File owner name
root File group name
4096 number of bytes in the file
Apr 4 2018 Abbreviated month, day-of-month file was last modified, hour file last modified, and minute file last modified
acpi The pathname/filename

The acpi is a directory indicated by first character d in drwxr-xr-x and the adduser.conf is a file indicated by first character - in -rw-r--r--. Let us try to understand meaning of drwxr-xr-x in ls command output.

More on the file mode

To understand the drwxr-xr-x file mode let us divide into three groups:

  1. group 1 : d
  2. group 2 : rwx
  3. group 3 : r-x
  4. group 4 : r-x

The file mode (group 1) printed consists of the file type and the permissions. The entry type character (group 1) describes the type of file, as follows:

Character File type
- Regular file.
b Block special file.
c Character special file.
d Directory.
l Symbolic link.
s Socket.
w Whiteout.

The next three groups are for owner permissions (group 2), group permissions (group 3), and other permissions (group 4). So each field has three character positions:

  1. r : Read only file permission
  2. w : Write only file permission
  3. x : Execute only file permission
  4. – : No permission

So group 2 has rwx permission it means you have read, write and executable permission on the file.

What is a directory?

A directory is a group of files. A directory is divided into two types:

  • Root directory – Strictly speaking, there is only one root directory in your Linux and Unix-like system, which is denoted by / (forward slash). It is root of your entire file system and can not be renamed or deleted.
  • Sub directory – Directory under root (/) directory is subdirectory which can be created, renamed by the user.

Directories are used to organize your data files, programs more efficiently.

How to create a directory

Use the mkdir command:
mkdir dir1
Next list newly created directory with the help of ls command:
ls -ld dir1
To change the working directory use the cd command:
cd dir1
To print the current working directory, run the pwd command:
Let us create two sub-directories and a file, run:
mkdir foo
mkdir -v bar

Next create a file named demo.txt in Linux/Unix from a bash shell prompt, run:
echo "This is a test" > demo.txt
List everything:
ls -l

Create a new directory and file on Linux and Unix

Creating a new directory, sub-directories, and file on Linux

Linux supports numerous file system types

  • Ext2: This is like UNIX file system. It has the concepts of blocks, inodes and directories.
  • Ext3: It is ext2 filesystem enhanced with journalling capabilities. Journalling allows fast file system recovery. Supports POSIX ACL (Access Control Lists).
  • Isofs (iso9660): Used by CDROM file system.
  • Sysfs: It is a ram-based filesystem initially based on ramfs. It is use to exporting kernel objects so that end user can use it easily.
  • Procfs: The proc file system acts as an interface to internal data structures in the kernel. It can be used to obtain information about the system and to change certain kernel parameters at runtime using the sysctl command. For example, you can find out CPU information on Linux with following cat command:

$ cat /proc/cpuinfo

  • Or you can enable or disable routing/forwarding of IP packets between interfaces with following command:

# cat /proc/sys/net/ipv4/ip_forward
# echo "1" > /proc/sys/net/ipv4/ip_forward
# echo "0" > /proc/sys/net/ipv4/ip_forward

  • NFS: Network file system allows many users or systems to share the same files by using a client/server methodology. NFS allows sharing all of the above file system.
  • Linux also supports Microsoft NTFS, vfat, and many other file systems. See Linux kernel source tree Documentation/filesystem directory for list of all supported filesystem.

You can find out what type of file systems currently mounted with mount command.
$ mount
$ cat /proc/mounts

List mounted file systems on Linux and Unix

mount running on OpenBSD Unix box and display /proc/mounts on Linux

What is a UNIX/Linux File system?

A UNIX file system is a collection of files and directories stored on disk. Each file system is stored in a separate whole disk partition. The following are a few of the file system:

  • / – Special file system that incorporates the files under several directories including /dev, /sbin, /tmp and more
  • /usr – Stores application programs
  • /var – Stores log files, mails and other data
  • /tmp – Stores temporary files

See The importance of Linux partitions for more information.

But what is in a File system?

Again file system divided into two categories:

  • User data – stores actual data contained in files
  • Metadata – stores file system structural information such as superblock, inodes, directories

Next time I will write more about Metadata objects – superblock, inodes, directories with actual linux commands so that you can understand and master the concepts 🙂

Continue reading rest of the Understanding Linux file system series:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 50 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
50 comments… add one
  • Ashish Jan 18, 2006 @ 12:38

    Hello Sir,

    I would like to post my comments regarding file and directories definitation.


    It contains the metadata which includes inodes, date and stamp, rights and ownership filesize and type. It also has the link to the datablock which stores data on it.


    Directories are also files which contains filename to inode associations in its datablock so people says there are only files in Unix.


  • 🐧 nixcraft Jan 18, 2006 @ 20:14

    Nice ashish! I appreciate your post 🙂

  • Anonymous Jan 30, 2006 @ 23:37

    two typos

    Procfs: The proc
    cat /proc/mounts

  • Anonymous Jan 30, 2006 @ 23:40

    You didn’t mention Reiserfs which I think is a little short sighted. Many users prefer it to ext3, XFS, and JFS journaling filesystems. Once reiserfs v4 is merged we’ll see some cool features being made available to all other filesystems as well.

  • 🐧 nixcraft Jan 31, 2006 @ 1:00

    Anonymous, thanks. I really appreciate your help for spotting out typos and your post.

  • 🐧 nixcraft Jan 31, 2006 @ 1:07

    Yes, I just missed reiserfs v3 was quite stable v4 will take some to stable under 2.6 kernel.. I will update the post for reiserfs. Thanks for suggestion.

  • Anonymous Jan 31, 2006 @ 8:49

    Quote “It contains the metadata which includes inodes, date and stamp, rights and ownership filesize and type. It also has the link to the datablock which stores data on it.”

    I think this definition is wrong, a file by definition is a stream of data -the meta data is exactly that, its data about data.

    The inode may be part of the operating systems fileing system, but it is NOT part of the file. For example if I copy a file from my linux system onto my windows system i lose the date/time/inode/mode/group – but I still have my “file”


    • Kishore Kumar Apr 23, 2015 @ 11:35

      When you copy a file from linux to windows or within the same OS, you are creating a new file. You are not losing the date/time or anything that you have mentioned. The new file is just getting updated with its values. Copying copies only the data, not the metadata. File “data” is not everything. Its just another attribute of a file. Data + Metadata = File.

  • Ashish May 15, 2006 @ 23:17

    Hey Jon,

    This brings another querry in my mind.
    Where file is storing the information about date, stamp, permissions, ownership and filesize?

    BTW, I really do not have much information about windows file system. Is it same like Unix file system? Is it having inodes and other stuff?

    Ashish Pathak

  • Thomas Scott Jan 29, 2007 @ 3:41

    “A conceptual understanding of file system, especially data structure and related terms will help you become a successful system administrator”
    But his job is easily taken away
    by future s/w that manages all objects
    files and folders , w/o a cmd line .
    Automating objects , reduces the
    kernel size , runs much faster .

    Pocket boxes are $5 cpu , & 64MB .
    And Intel lost its grip ( 20 countries
    make ARM !). No more WinTel .

    Ppl will hack h/w and s/w into
    a pocket box that will run fast
    enuf to do everything .
    OpSys that has NO cmd line , true G.U.I.
    uses images ONLY , has no text keyboard.
    But since OpSys is non-text , one
    can create apps in hours ! Most of
    the proceedures will be in kernel ,
    all you need is to chain these proc’s
    in the proper order to create your app .

    Yes , i know Linux is your paycheck ,
    sorry …..

    • riyaz ahmed Jan 16, 2012 @ 15:57

      dear sir,
      please send me a good material about red hat linux to i become a good
      and skilled system administration in linux.above my e.mail address

  • Arnab Jun 11, 2007 @ 8:01

    Hey friends can any one answer this following questioon plz.. it’s urgent.. I need ur help.

    ” Now a days memories are large and cheap.Therefore,when a file is opened it is simpler and faster to fetch a new copy of the i-node into the i-node table, rather than searching the entire table to see if it is already there” True or False?? – Justify

  • abhi Nov 14, 2007 @ 15:11

    @Thomas Scott,

    Thomas, a question : How does your hypothetical keyboard-less OS stores your resume to begin with? or any data? Just curious.

    And what if someone wants to create something new? How do these “most procedures” cope with that then? Sheesh!

    If you don’t understand computers, or are plain simple drunk, why bother commenting at all? Why not just sleep off the effect of the wonderful liquor you have imbibed?

    • Anonymous Jan 17, 2012 @ 5:27

      I honestly do not think that this is the place that someone such as abhi, should be making disparaging remarks about someone who has a query about an issue he is facing. He approached this forum of ‘professionals’ to seek advice, and this unscrupulous individual abhi decides to attack his intelligence. For all you know “MR. ABHI”, Mr. Scott could be fairly new to this industry in a new environment about something he understands enough to get the job, but is having difficulty in overcoming an issue. Not everyone is blessed with the omniscience of computer workings. I am pretty sure that if you took your CCNA exam, and failed it the first time, you went and asked for help. Even then, IF you enrolled in school, and learned it from someone else, THEY had the patience to answer your questions when you didn’t know. Give the guy a break. As for you MR. Scott, if these people don’t help you, don’t get discouraged. Keep looking, you’ll find the answer from someone who will be patient enough to give it to you.

      • JohnSmith Mar 19, 2012 @ 5:51

        ^ Here we have an excellent example of “white knighting.”

        Comprehension, do you know it? You didn’t even read T.Scott’s intelligible gibberish, did you? Yeah, thought not.

  • koulis Dec 11, 2007 @ 16:13

    i very appreciate this tutorial but
    part-ii ( http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/11/understanding-unixlinux-filesystem.php ) forwords to a 404 error.
    pls fix toc ontinue reading 😀

  • koulis Dec 11, 2007 @ 16:28

    ok i googled a bit and found the correct url ( http://www.cyberciti.biz/tips/understanding-unixlinux-filesystem-superblock.html )

    pls fix it for others and sorry for posting a comment instead of mail.

  • 🐧 nixCraft Dec 11, 2007 @ 16:53


    I’ve updated php regex and it should now redirect to correct url.

  • srees Dec 13, 2007 @ 14:50

    will linux support RAW file system?
    my USB drive was changed by Trojan horse to Raw.
    how can i recover it?

  • ami Jan 2, 2008 @ 8:21

    Is there a way to add custom properties (attirbutes) to iNode structure?

  • savi Feb 26, 2008 @ 5:43

    diagrms would have helped the user to understand the things easily.

  • AMITKUMAR May 15, 2008 @ 6:51

    hi, all

    i’ve to design ext3 linux file system, so please any body can suggest me, that from where i can get the proper knowledge of ‘ext3 linux file system’ architecture/ structure

  • franklin Aug 4, 2008 @ 5:52

    Can Someone clear my doubt in ext3 file system
    what is meaning of journalising in ext3 and describe?

  • franklin Aug 4, 2008 @ 6:06

    nixcrft excellent and delicious site,thanks Vivek sir.

  • 🐧 nixCraft Aug 4, 2008 @ 8:41


    Under ext3 there is a journal where file system logs the changes before committing them to disk / main file system. ext3 less likely to become corrupted in the event of power failure or system crash. See this tutorial for more info.

  • nari Dec 24, 2008 @ 9:01

    Q). Files (Types of files, attributes, device files, usage, how to control hw with files, cdrom, hdd, tapedrive)

  • veera Feb 2, 2009 @ 10:02

    I wants to find dump(crash dump) file system name and FS type and how many blocks it has? for all unix plat forms linix ,aix,hp-ux and solaris.
    please any body suggest the commands for getting above values.

  • HungryCoder Feb 16, 2009 @ 19:09

    nice article. it helped me a lot. thank u so much.

  • amin Apr 15, 2009 @ 6:37

    unix or linux are support FAT / NTFS

  • AMOL Aug 5, 2009 @ 19:15

    CORE 2 DUO

  • Rahul Tripathi Oct 28, 2009 @ 21:50

    Hi All,

    I have a problem.One of my collegue has mistakenly deleted / file system on one of production server[Linux based] which is not coming up.

    We have restored /etc of the same server on some other server in the network. But we are not able to logon to main server.

    Please suggest an alternative so as how to restore my server within 1 hour time.


  • Sani Abdul Feb 21, 2010 @ 23:52

    I appreciate your services

  • Saeed Ahmad Nov 13, 2010 @ 11:59

    Dear AMOL

    You use the Suse / Fedora or the RHEL


  • akhil Feb 27, 2011 @ 14:59

    i want to detailes of internal file structure in linex

  • budhi prakash chhipa Mar 30, 2011 @ 9:14

    Thank U;

  • rekha Jun 5, 2011 @ 16:05

    plz tell me more abt unix file system performance

  • shailesh Jul 18, 2011 @ 7:00

    Dear Sir.
    Kindly provide solution for how to working file system

  • anup mukherjee Jul 22, 2011 @ 5:51

    Thanks a ton….nice helpful article…………..

  • irshad khan Jul 26, 2011 @ 10:22

    hey hi friends,,,, i just want to know that is this uses in real life means any one can use this file system (normal operator) otherwise networking specialists required to remember this only…….. reply

  • piet Oct 19, 2011 @ 21:32

    typo: “lsofs” should be “lofs”.

  • manisha rai Jan 18, 2012 @ 9:52

    Which files is a part of Linux System??
    (a)Autoexec.bat (b)config.sys
    (c)both A & b (d)None

    • Bill Gates Jun 17, 2014 @ 11:38

      We don’t give answers to your exams!!!
      Study for your own exams!

  • prasad Feb 4, 2012 @ 7:36

    i found your site from googled… can i know what is the command to view version of linux OS

  • satyendra kumar Feb 9, 2012 @ 9:58

    Dear sir,

    I want to know that which type of file system in use in linux..

    Please reply

  • ali Feb 29, 2012 @ 9:04

    i did n’t understand.plz tell me more.

  • Ramkumar Mar 14, 2012 @ 10:41

    i really get good information from this site…may know what the main difference from windows files system with linux

  • yp_1981 Jul 26, 2012 @ 11:01

    I am searching for the file system which is compatible to Linux kernel 3.4.1. During booting kernel thought NFS I am getting error VFS: Cannot open root device “nfs” or unknown-block(2,0). Is this because i am using filesystem for rootfs which are for kenernal 2.6.32?

  • DEEPAK Nov 27, 2013 @ 11:07

    Which is the fastest and best filesystem ?

  • John Mar 1, 2016 @ 18:44

    very interesting. Also very true!

  • vishal619 Dec 17, 2016 @ 8:32

    I want partition information in the following type…. plzz tell me… if anybdy knows

    Partition/File System Information (Threshold 80% & 85%)
    1. /dev/sda1 primary bootable ext4 100M /boot
    2. /dev/sda2 primary swap 200M
    3. /dev/sda3 extended ext3 8000M
    4. /dev/sda4 logical ext4 LVM 3000M /

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum