Linux get free space

How to Check Free Disk Space on Linux [Terminal and GUI Methods]

Wondering how much free space you are left with? Here are terminal and GUI methods for checking the free disk space and disk usage on Linux.

How much disk space have I utilized? The simplest way to find the free disk space on Linux is to use df command. The df command stands for disk-free and quite obviously, it shows you the free and available disk space on Linux systems.

Free Disk Space Linux Df Command Output

With -h option, it shows the disk space in human-readable format (MB and GB). Here’s the output of the df command for my Dell XPS system that has only Linux installed with encrypted disk: If the above output is confusing for you, don’t worry. I’ll explain a few things about checking available disk space on Linux. I’ll also show the GUI method for desktop Linux users. Overall, I’ll mention three methods:

  • Using df command
  • Using alternative commands like du and dust
  • Using a graphical user interface

With the information you gather, you can go about making some free space on Ubuntu.

Method 1: Checking free disk space in Linux with df command (and understanding its output)

When you use the df command to check disk space, it will show a bunch of ‘file systems’ with their size, used space and free space. Your actual disks should normally be listed as one of the following:

This is not a hard and fast rule but it gives you an indication to easily recognize the actual disk from the crowd.

Your Linux system might have several partitions on your disk for boot, EFI, root, swap, home etc. In such cases, these partitions are reflected with a number at the end of the ‘disk name’, like /dev/sda1, /dev/nvme0n1p2 etc.

You could identify which partition is used for what purpose from its mount point. Root is mounted on /, EFI in /boot/EFI etc.

In my case, I have used 41% of the 232 GB of disk space under root. If you have 2-3 big partitions (like root, home etc), you’ll have to make a calculation here.

Df Command Output

  • tmpfs: The tmpfs (temporary filesystem) used for keeping files in virtual memory. You can ignore this virtual filesystem comfortably.
  • udev: The udev filesystem is used for storing information related to devices (like USB, network card, CD ROM etc) plugged to your system. You may ignore it as well.
  • /dev/loop: These are loop devices. You’ll see plenty of them while checking disk space in Ubuntu because of snap applications. Loops are virtual devices that allow normal files to be accessed as block devices. With the loop devices, snap applications are sandboxed in their own virtual disk. Since they are under root, you don’t need to count their used disk space separately.
Читайте также:  Whonix kali linux установка

And, if you want to view the disk usage with more details like filesystem type and blocks, you can use the command:

df t command

Missing disk space? Check if you have mounted all disks and partitions

Keep in mind that the df command only shows disk space for mounted filesystems. If you are using more than one Linux distribution (or operating systems) on the same disk or you have multiple disks on your system, you need to mount them first in order to see the free space available on those partitions and disks.

For example, my Intel NUC has two SSDs and 4 or 5 Linux distributions installed on them. It shows additional disks only when I mount them explicitly.

You can use the lsblk command to see all the disks and partitions on your system.

Lsblk Command To See Disks Linux

Once you have the disk partition name, you can mount it in this fashion:

I hope this gives you a pretty good idea about checking hard drive space on Linux. Let’s see how to do it graphically.

Method 2: Using du, ls, and Other Commands

While df command is quite popular and should be enough for the use case, there are other alternatives that you can try including:

  • 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 the total disk space used by a particular file or directory.
  • ls -al →Lists the entire contents, along with their size, of a particular directory.
  • stat →Displays the size and other stats of a file/directory or a file system.
  • fdisk -l →Shows disk size along with disk partitioning information (may require sudo privileges).
  • dust → An interesting alternative to the du command written in Rust, available for Arch Linux in the repositories. For other Linux distros, you can refer to its GitHub releases section.

Method 3: Check free disk usage graphically

Checking free disk space graphically is much easier in Ubuntu with the Disk Usage Analyzer tool.

Disk Usage Analyzer Tool Linux

You’ll see all the actual disks and partitions here. You may have to mount some partitions by clicking on them. It displays the disk usage for all the mounted partitions.

Free Disk Space Ubuntu Desktop

Checking free disk space with GNOME Disks utility

Otherwise, the GNOME Disks utility is also a pretty handy tool.

Disks Tool Linux

Start the tool and select the disk. Select a partition to see the free disk space. If a partition is not mounted, mount it first by clicking the ‘play’ icon.

Free Disk Space Check Ubuntu Desktop

I think all major desktop environments have some sort of graphical tool to check the disk usage on Linux. You can search for it in the menu of your desktop Linux system.

Conclusion

Of course, there can be more ways and tools to check disk space. I showed you the most common command line and GUI methods for this purpose.

I also explained a few things that might trouble you in understanding disk usage. I hope you like it.

Running out of disk space? How about cleaning it up and get it back?

Please let me know in the comment section if you have questions or suggestions.

Источник

5 Linux commands to check free disk space

How to find files in Linux

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 command

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 command

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.

GNOME Disks

Linux du command

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

du command

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.

Disk usage

Linux ls -al command

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

ls -al command

Linux stat command

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

stat command

Linux fdisk -l command

fdisk -l shows disk size along with disk partitioning information

fdisk - l command

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 disk usage

Check used disk space on Linux with du

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

Free disk space

Use df to check free disk space on Linux

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

Источник

How to Check Disk Space in Linux

Managing disk space on a Linux server is an important task. For example, package manager applications notify you how much disk space will be required for an installation. For that information to be meaningful, you should know how much space your system has available.

In this tutorial, learn how to use the df command to check disk space in Linux and the du command to display file system disk space usage.

Tutorial on checking available disk space in Linux

  • A Linux-based system
  • A terminal window / command line
  • A user account with sudo or root privileges

Check Linux Disk Space Using df Command

You can check your disk space simply by opening a terminal window and entering the following:

Command to check disk space on Linux.

The df command stands for disk free, and it shows you the amount of space taken up by different drives. By default, df displays values in 1-kilobyte blocks.

Display Usage in Megabytes and Gigabytes

You can display disk usage in a more human-readable format by adding the -h option:

This displays the size in kilobytes (K), megabytes (M), and gigabytes (G).

Command to check disk space in human-readable format of kilobytes, megabytes,and gigabytes

Understanding the Output Format

The df command lists several columns:

Filesystem Size Used Avail Use% Mounted on udev 210M 0 210M 0% /dev tmpfs 49M 1004K 48M 3% /run /dev/sda2 7.9G 4.3G 3.2G 58% /

Your output may have more entries. The columns should be self-explanatory:

  • Filesystem – This is the name of each particular drive. This includes physical hard drives, logical (partitioned) drives, and virtual or temporary drives.
  • Size The size of the filesystem.
  • Used – Amount of space used on each filesystem.
  • Avail – The amount of unused (free) space on the filesystem.
  • Use% – Shows the percent of the disk used.
  • Mounted on – This is the directory where the file system is located. This is also sometimes called a mount point.
Читайте также:  Running office on linux

The list of filesystems includes your physical hard drive, as well as virtual hard drives:

  • /dev/sda2 – This is your physical hard drive. It may be listed as /sda1, /sda0, or you may even have more than one. /dev stands for device.
  • udev This is a virtual directory for the /dev directory. This is part of the Linux operating system.
  • tmpfs – You may have several of these. These are used by /run and other Linux processes as temporary filesystems for running the operating system. For example, the tmpfs /run/lock is used to create lockfiles. These are the files that prevent multiple users from changing the same file at the same time.

Display a Specific File System

The df command can be used to display a specific file system:

You can also use a backslash:

This displays the usage on your primary hard drive. Use the mount point (in the Mounted on column) to specify the drive you want to check.

Command to display the usage of a specific file system.

Note: The df command only targets a full filesystem. Even if you specify an individual directory, df will read the space of the whole drive.

Display File Systems by Type

To list all file systems by type, use the command:

This lists drives with the ext4 type, in human-readable format.

Command to list drives with the ext4 type with size and available space show

Display Size in 1000 Instead of 1024

You can display disk usage in units of 1000 instead of 1024:

This can address a point of confusion in storage technology. Hard drive manufacturers sell hard drives in sizes based on 1000 bytes = 1 kilobyte.

However, operating systems divide that space up so that 1024 bytes = 1 kilobyte. Because of this, a 1000-gigabyte hard drive ends up with roughly 930 gigabytes of usable storage.

Note: Check out our overview of the Linux free command used to check total, used, shared, free, and available memory and swap space.

Check Disk Space in Linux With du Command

The du command displays disk usage. This tool can display disk usage for individual directories in Linux, giving you a finer-grained view of your disk usage. Use it to display the amount of space used by your current directory:

Du command for displaying disk usage in Linux.

Like the df command, you can make du human-readable:

It displays a list of the contents of the current directory, and how much space they’re using. You can simplify the display with the -s option:

This shows how much space the current directory uses.

example of how much space is left in a linux directory

To specify the directory or file, check use the following options:

With the second command, you may have noticed a permission denied error message. This means the current user doesn’t have the privileges to access certain directories. Use the sudo command to elevate your privileges:

Note: If you’re working on CentOS Linux, you may need to use the su command to switch to the root user to access protected directories.

You should now understand how to use df and du commands to check disk space on your Linux system. Remember, to display a complete list of options, use either df —help or du —help .

Check out our article on how to use fsck command to run a filesystem check as preventive maintenance or when there is an issue with your system.

Источник

Оцените статью
Adblock
detector