Available space on directory linux

5 Linux commands to check free disk space

Lewis Cowles, CC BY-SA 4.0

Keeping track of disk utilization information is on system administrators’ (and others’) daily to-do list. Linux has a few built-in utilities that help provide that information.

Linux df command

The df command stands for «disk-free,» and shows available and used disk space on the Linux system.

df -h shows disk space in human-readable format

df -a shows the file system’s complete disk usage even if the Available field is 0

df -T shows the disk usage along with each block’s filesystem type (e.g., xfs, ext2, ext3, btrfs, etc.)

df -i shows used and free inodes

You can get this information in a graphical view using the Disks (gnome-disk-utility) in the GNOME desktop. Launch it to see all disks detected by your computer, and click a partition to see details about it, including space used and space remaining.

Linux du command

The Linux Terminal

du shows the disk usage of files, folders, etc. in the default kilobyte size

du -h shows disk usage in human-readable format for all directories and subdirectories

du -a shows disk usage for all files

du -s provides total disk space used by a particular file or directory

The following commands will check your total space and your utilized space.

This information can be represented visually in GNOME with the Disk Usage application, or with Filelight in the KDE Plasma desktop. In both applications, disk usage is mapped to concentric circles, with the middle being the base folder (usually your /home directory, but it’s up to you) with each outer ring representing one directory level deeper. Roll your mouse over any segment for detailed information about what’s taking up space.

Linux ls -al command

ls -al lists the entire contents, along with their size, of a particular directory

Linux stat command

stat displays the size and other stats of a file/directory or a filesystem.

Linux fdisk -l command

fdisk -l shows disk size along with disk partitioning information

These are most of the built-in utilities for checking file space in Linux. There are many similar tools, like Disks (GUI), Ncdu, etc., that also show disk space utilization. Do you have a favorite tool that’s not on this list? Please share in the comments.

This article was originally published in July 2018 and has been updated to include additional information.

Check used disk space on Linux with du

Find out how much disk space you’re using with the Linux du command.

Use df to check free disk space on Linux

Find out how much Linux disk space you have left with the df command.


2 ways to Check Disk space usage in Linux

How to check disk space is a commonly asked question during a Linux job interview.

Disk space usage and disk utilization are different in Linux. Disk space usage means how much percent of space we use on the disk. Disk utilization means how busy the disk is when there is some workload on it. Today we will look at more details about this.

Check disk space usage with df command in Linux

df command can be used to show disk usage.

Читайте также:  Ricoh aficio gx e7700n картридж

we can use df command to display information about total space and available space on a file system. The FileSystem parameter specifies the name of the device on which the file system resides, the directory on which the file system is mounted, or the relative path name of a file system.

Normally, the df command uses free counts contained in the superblock. Under certain exceptional conditions, these counts might be in error. For example, if a file system is being actively modified when the df command is running, the free count might not be accurate.

  • Filesystem The name of the disk partition.
  • Size The total size of the file system.
  • used The total amount of space allocated to existing files in the file system.
  • Available The total amount of space available within the file system.
  • Percentage used The percentage of the available space that currently allocated to all files on the file system.
  • Mounted on The directory in which the file system appears.

Df command Options

  • df -h shows disk space in human-readable format
  • df -a shows the file system’s complete disk usage even if the Available field is 0
  • df -T shows the disk usage along with each block’s filesystem type (e.g., xfs, ext2, ext3, btrfs, etc.)
  • df -i shows used and free inodes
  • df -t, –type=TYPE : limit listing to file systems of type TYPE

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/wbx_vg-root 20G 1.8G 18G 9% /
/dev/mapper/wbx_vg-opt 9.8G 217M 9.6G 3% /opt
/dev/mapper/wbx_vg-tmp 4.9G 45M 4.9G 1% /tmp
/dev/mapper/wbx_vg-u00 43G 20G 24G 46% /u00
/dev/mapper/wbx_vg-var 9.8G 757M 9.1G 8% /var
/dev/mapper/wbx_vg-var_crash 33G 39M 33G 1% /var/crash
/dev/sdo1 509M 159M 350M 32% /boot

Check disk space usage for file or directory with du command in Linux

du command, short for disk usage, is used to estimate file space usage. The du command can be used to track the files and directories which are consuming excessive amount of space on hard disk drive.

# du -h /home/howtouselinux/test

44K /home/howtouselinux/test/data
2.0M /home/howtouselinux/test/system design
24K /home/howtouselinux/test/table/sample_table/tree

Difference between df and du in Linux

  • df – check disk space
  • du – check disk space for file or directory
  • df is a standard Linux command used to display the amount of available disk space for file systems.
  • du is a standard Linux command used to estimate file space usage—space used under a particular directory or files on a file system. The du command summarizes disk space used for each FILE and/or directory.

How to fix disk space issue in Linux?

We can get how much percent space we already used on the disk or disk partition from df command Use% column. If it is over 80%, we should check which file or directories take up this space with du command. Then we need to remove some unwanted files to release the space or move the large files to other disks.

check disk performance in Linux with iostat command

Disk performance can be a tricky thing to optimize, especially on Linux systems. In this blog post, we will discuss three different ways to check disk performance in Linux. This is a handy trick to know if you are experiencing slowdowns or if you want to optimize your disk performance. We will be using the “iostat” command, the “iotop” command, and the “dd” command to check our disk performance.

The iostat command is a great way to see your current disk utilization. You can use the following syntax to run iostat: iostat -x /dev/sda

This will print out a report of your disk activity, including the amount of read and write operations, the average response time etc.

Check which process using the most disk io in Linux with iotop command

The iotop command is another great way to see what processes are using the most disk I/O. You can use the following syntax to run iotop: iotop -aoP

This will print out a report of the processes that are using the most disk I/O, along with the percentage of disk I/O each process is using. You can then use this information to determine which processes are causing slowdowns.

Check disk performance with dd command in Linux

The dd command is a great way to check the read and write speed of your disk. You can use the following syntax to run dd: dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync

This will create a file called “test” that is 64KB in size and will write zeros to it. This is a good way to test the write speed of your disk. To test the read speed, you can use the following syntax: dd if=test of=/dev/null bs=64k count=16k

Читайте также:  Install linux make file

How to check disk utilization on Linux?

Iostat command can be used to show disk utilization. We can get how busy our disk is when there is some workload on it from column %util. If it is over 80%, we need to check the workload like iops, io size or storage latency to fix it. More details here about disk utilization.

# iostat -kx 3 /dev/sdo
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sdo 0.06 0.78 1.62 13.27 98.69 177.04 37.04 0.50 33.48 72.83 28.68 4.21 6.27
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sdo 0.00 0.00 0.00 12.00 0.00 82.50 13.75 0.18 15.22 0.00 15.22 4.56 5.47


How to check empty space in a folder using commandline?

I tried du but that doesn’t output the empty space of a folder. Any commands to do this?

3 Answers 3

Folders are as big as the total size of their contents; they do not have any free space.

The df command shows empty disk space.

There is no meaning of a folder size. In really a folder/directory is just a File in Linux as the concept everything is a file in Linux.

So a folder is a file of files. I,e it’s just a place to hold files, though it has no size, its size is related to the size of files inside.

So, there is nothing called free space on a folder.

You can know the size of a directory

also you can know the free space of your whole filesystem

Just to clarify it a little more (hope i do not miss any special filesystem):

  • Folders are a small file
  • Folders grow as more files / sub folders are added to it (but not to a sub folder of it), only directly to it
  • Folders (on some systems do not) decrease on size when files / sub folders directly on it are removed from it
  • Think on folders as a phonebook list
  • Most filesystems leave empty entries on folders (just to not move all the rest up), so size most of the times only grows
  • Folder size does not include any file size (unless such folder is a container where talking about free space may have a meaning: size to reach max container size)
  • Folder size depends on the number of entries (including the ones than have been blanked) ceiling it to a multiply of a number
  • Folders does not hold inside it any content of any file (except special folders that are really a container, with or without a max size defined)

At least for FAT12, FAT16, FAT32, exFAT, NTFS, ext, ext2, ext3, ext4, and maybe for much more filesystems, folders are a small file that identifies what folders and files are under it, just like a phonebook list, it only describes what is inside it (beware: only directly on it, nothing about what is inside any sub folder).

NTTS has some extra things, but all has it’s unique identificator (a number), folders identify only what of such identificators are just directly on such folder, not the ones that are in a sub folder of it, etc.

Beware there are filesystems very special, on that ones a Folder can have a size (upper limit) and so it has sence to talk about free space inside that folder.

For most Linux users to understand that, treat such Folder as a Container with a max size, concept is near the VDI files of VirtualBOX, etc. They can grow up to a limited size. Some special filesystems use that concept for a Folder, while others (like Pismo Private Folders) use a no max size limit.

For most Windows users to understand that, treat such Folder a a sparse big file, that with some 3rd part tool is seen as a folder.

In other words, the are three common well defined type of thing on a file system (including some special filesystems not so much common to see):

  1. Files (hold information, or links to other files)
  2. Normal folders, they are really a small file (hold a list of what is directly on its 1st level inside them)
  3. Special folders, they can be seen as a huge file, with or without an upper size limit (holds all what is inside them, list and content of all, including sub folders, etc); not all filesystems allow them natively, most use the trick of defining a file and then mount it as if it where a folder (like .zip, .rar, .7z mounter utilities, etc), but a few filesystems allow them natively.
Читайте также:  Как обнулить чип на картридже принтера canon

If you want to see something very weird, try this (on a NTFS):

  1. Create a folder on the root, called for example: MyWeirdFolder
  2. Then inside it create a sub folder with a very large name (more than 200 characters)
  3. Create another folder, but with a short name, like WillBeRenamed
  4. Move the long one inside the short one
  5. Rename the short one to a very long name (more than 200) characters

You will get a path that is not accesible due to very long path, just rename such long names to shorter ones and will get access to it again.


12 Useful “df” Commands to Check Disk Space in Linux

On the internet, you will find plenty of tools for checking disk space utilization in Linux. However, Linux has a strong built-in utility called ‘df‘.

The ‘df‘ command stands for “disk filesystem“, it is used to get a full summary of available and used disk space usage of the file system on the Linux system.

Using ‘ -h ‘ parameter with (df -h) will show the file system disk space statistics in “human-readable” format, means it gives the details in bytes, megabytes, and gigabyte.

Useful df Command Examples

This article explains a way to get the full information of Linux disk space usage with the help of the ‘df‘ command with their practical examples. So, you could better understand the usage of the df command in Linux.

1. Check File System Disk Space Usage

The “df” command displays the information of device name, total blocks, total disk space, used disk space, available disk space, and mount points on a file system.

2. Display Information of all File System Disk Space Usage

The same as above, but it also displays information of dummy file systems along with all the file system disk usage and their memory utilization.

3. Show Disk Space Usage in Human Readable Format

Have you noticed that the above commands display information in bytes, which is not readable at all because we are in a habit of reading the sizes in megabytes, gigabytes, etc. as it makes it very easy to understand and remember.

The df command provides an option to display sizes in Human Readable formats by using ‘-h’ (prints the results in human-readable format (e.g., 1K 2M 3G)).

4. Display Information of /home File System

To see the information of only device /home file systems in human-readable format use the following command.

5. Display Information of File System in Bytes

To display all file system information and usage in 1024-byte blocks, use the option ‘ -k ‘ (e.g. —block-size=1K ) as follows.

6. Display Information of File System in MB

To display information of all file system usage in MB (MegaByte) use the option ‘ -m ‘.

7. Display Information of File System in GB

To display information of all file system statistics in GB (Gigabyte) use the option as ‘df -h‘.

8. Display File System Inodes

Using ‘ -i ‘ switch will display the information of a number of used inodes and their percentage for the file system.

9. Display File System Type

If you notice all the above commands output, you will see there is no Linux file system type mentioned in the results. To check the file system type of your system use the option ‘ T ‘. It will display file system type along with other information.

10. Include Certain File System Type

If you want to display a certain file system type use the ‘ -t ‘ option. For example, the following command will only display the ext3 file system.

11. Exclude Certain File System Type

If you want to display a file system type that doesn’t belongs to the ext3 type use the option ‘ -x ‘. For example, the following command will only display other file systems types other than ext3.

12. Display Information of df Command.

Using ‘—help ‘ switch will display a list of available option that is used with df command.

Read Also :

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.


Поделиться с друзьями