Commands to Check Filesystem in Linux Ubuntu

On Ubuntu Linux, determine filesystem type. Learn how to check filesystem in Linux using command. Here is the terminal command to check file system in Ubuntu Linux.

What is a file system in Linux?

A file system is the method in which files are managed in Linux. File system determines how files are named, stored, updated, accessed on a storage hard disk or partition. There are different types of Linux file system such as Ext2, Ext3, Ext4, BtrFS, GlusterFS.

When a new file is created, it gets a free inode (inode describes a data structure on the hard disk, storing the properties of a file, including the physical location of the file data). inode contains the following information about the file:

  • Owner and group owner of the file.
  • File type (regular, directory, …)
  • Permissions on the file.
  • Date and time of creation, last read and change.
  • Date and time this information has been changed in the inode.
  • Number of links to this file (see later in this chapter).
  • File size
  • An address defining the actual location of the file data.

The only information not included in an inode, is the file name and directory (stored in the special directory files).

NOTE: In Linux and UNIX based Systems, everything is a file, be it text files, images and compiled executable programs, directories, partitions and hardware device drivers.

Each filesystem contains a control block, which holds information about that filesystem. The other blocks in the filesystem are inodes, which contain information about individual files, and data blocks, which contain the information stored in the individual files.

The filesystem has as a hierarchical arrangement of directories that contain files and subdirectories.

Directories and files are identified by their names. This hierarchy starts from a single directory called root, which is represented by a “/” (forward slash). Root is a user who has administrative privileges on the computer.

Also note that “/” is as a separator between directories or between a directory and a file, similar to the backward slash used in MS-DOS.

In Linux, the Filesystem Hierarchy Standard (FHS) defines the main directories and their contents. All files and directories appear under the root directory, even if they are stored on different physical devices (e.g., on different disks or on different computers). A few of the directories defined by the FHS are /bin (command binaries for all users), /boot (boot loader files such as the kernel), /home (users home directories), /mnt (for mounting a CDROM or floppy disk), /root (home directory for the root user), /sbin (executables used only by the root user) and /usr (where most application programs get installed).

Commands To Check Filesystem In Linux Ubuntu

Let us see about some of the commands to find check filesystem in Linux Ubuntu:

Using df command

The easiest way to check filesystem in Linux Ubuntu systems is by using df command with the following command options. Run the following command in terminal and you will see the list of filesystems:

df -m --print-type

Using fstab command

fstab is a system configuration file on Linux systems that contains information about filesystems on the system. It is located in the /etc directory. The configuration file /etc/fstab contains the necessary information to automate the process of mounting partitions. /etc/fstab can be safely viewed by using the cat command (which is used to read text files) as follows:

$ cat /etc/fstab

Using df Command

The ‘df’ command displays the amount of disk space used and available on file systems. With no arguments, ‘df’ reports the space used and available on all currently mounted file systems (of all types). Otherwise, ‘df’ reports on the file system containing each argument FILE.

The following two df command options are used:

-T’ or ‘–print-type’ : This command argument prints each file system’s type. The types printed here are the same ones you can include or exclude with ‘-t’ and ‘-x’. The particular types printed are whatever is supported by the system.

Here are some of the common names (this list is certainly not exhaustive):

  1. ‘nfs’: An NFS file system, i.e., one mounted over a network from another machine. This is the one type name which seems to be used uniformly by all systems.
  2. ‘ext2, ext3, ext4, xfs, btrfs…’: A file system on a locally-mounted hard disk. (The system might even support more than one type here; Linux does.)
  3. ‘ntfs,fat’: File systems used by MS-Windows / MS-DOS.
  4. ‘iso9660, cdfs’: A file system on a CD or DVD drive. HP-UX uses ‘cdfs’, most other systems use ‘iso9660’.

‘-h’ or ‘–human-readable’: Append a size letter to each size, such as ‘M’ for mebibytes. Powers of 1024 are used, not 1000; ‘M’ stands for 1,048,576 bytes. This option is equivalent to ‘–block-size=human-readable’.


$ df -Th


$ df -Th | grep "^/dev"

Using fsck Command

The fsck command is used to check and optionally repair one or more Linux filesystems. filesys can be a device name (e.g. /dev/hdc1, /dev/sdb2), a mount point (e.g. /, /usr, /home), or an ext2 label or UUID specifier (e.g. UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root). Normally, the fsck program will try to handle filesystems on different physical disk drives in parallel to reduce the total amount of time needed to check all of them.

If no filesystems are specified on the command line, and the -A option is not specified, fsck will default to checking filesystems in /etc/fstab serially. This is equivalent to the -As options.


$ fsck -N /dev/sda3


$ fsck -N /dev/sdb1

Using lsblk Command

The lsblk command lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information. The command prints all block devices (except RAM disks) in a tree-like format by default.

The -f, –fs lsblk command options shows info about filesystems. This option is equivalent to -o NAME,FSTYPE,LABEL,UUID,MOUNTPOINT. The authoritative information about filesystems and raids is provided by the blkid command.

Users can use lsblk –help to get a list of all available columns.


$ lsblk -f

Using mount Command

$ mount | grep "^/dev"

Using file Command

$ sudo file -sL /dev/sda3

If you are not certain and sure about any command, don’t run it in terminal. Using wrong commands can alter or wipe off the filesystem.

Original Article