Free space available linux

Linux: Find Out How Much Disk Space Left On Hard Drive

I am a desktop support professional with experience working in a corporate call center environment. Recently, I started to admin RHEL based IBM Linux server. How do I determine how much disk space left in my Linux server? How do I find out how much disk space I have in Linux for each partition?

You need to use the df command. It shows the amount of disk space available on the currently mounted file system. df is used to show or find out following information:

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements df
Est. reading time 2 minutes
  1. Used and available space.
  2. File system mount points.
  3. File system capacity.
  4. The number of inodes available.
  5. Find of whether there is sufficient space to upgrade or install new apps.

Syntax

The basic syntax is as follows:

df
df /path/to/dev
df [options] df [options] /path/to/dev

Examples

Type the following command:
# df
# df -H
Sample outputs:

Fig.01: df command in action

The following example will provide information only for the partition/device that contains the /home directory:
# df /home
# df -h /home
To see inode usage instead of block usage, type:
# df -i
# df -i /
# df -ih /
# df -i /dev/md0
Sample outputs:

Pass the -T to find out file system type:
# df -T -h
Sample outputs:

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

df command options

From the df command man page:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

Again, thank you! 😀

Great! Thank you.

Df is great for finding the space available on a partition, but it doesn’t paint the entire picture of how much space is available on a hard drive. You would need to check the LVM displays as well as fdisk in order to best answer the question laid out in this article’s title.

Thnaks for providing the answer to this question in complete detail….

you can alse use “findmnt” which might not be provided in ALL UNIX-like variants.

Findmnt or df command

I use df to see how much available space there is on a mounted partition, but is there a good way to see how much space is used vs available on a whole disk, including unpartitioned space?
i suppose i could just look at df output and then compare that to fdisk’s output…
but i’m lazy and i’d love to find a better way or just a single utility/command that would do that for me.

use “cfdisk” command

Thanks for the tip. Cfdisk works pretty good. It makes my life a lot easier when I want to manage partitions from the CLI. Its a lot more visual than fdisk or parted and it’s dead simple. Seems like the next best thing if you don’t have access to gparted.
But even though cfdisk is great, I still wish there was a command like df that would simply return the available free space on the drive, like df does with partitions.

Источник

Linux / Unix – Checking Free Disk Space

Tutorial details
Difficulty level Easy
Root privileges No
Requirements None
Est. reading time 1m

(a) df command : Report file system disk space usage.

(b) du command : Estimate file space usage.

df command examples to check free disk space

Type df -h or df -k to list free disk space:
$ df -h
OR
$ df -k
Sample outputs that show disk space utilization:

The df utility displays statistics about the amount of free disk space on the specified file system or on the file system of which file is a part. Values are displayed in 512-byte per block counts. The -H option is called as “Human-readable” output. It use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to four or fewer using base 10 for sizes i.e. you see 30G (30 Gigabyte).

How to check free disk space in Linux

To see the file system’s complete disk usage pass the -a option:
df -a
Find out disk usage and filesystem type by passing the -T option:
df -T
Want to get used and free inodes information on Linux? Try:
df -i

du command examples for checking free and used disk space

The du command shows how much space one ore more files or directories is using, enter:
$ du -sh
Sample outputs:

Fig.01: Unix df and du command outputs from my FreeBSD server

Say hello to ncdu command

ncdu (NCurses Disk Usage) is a curses-based version of the well-known ‘du’, and provides a fast way to see what directories are using your disk space. One can install with the following apt command/apt-get command:
sudo apt install ncdu
For RHEL/CentOS, first enable EPEL repo (see CentOS 8 turn on EPEL repo and RHEL 8 enable epel repo) and type the following yum command:
sudo yum install ncdu
Now just type:
ncdu
ncdu [dir] ncdu /etc/

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

GUI program

Above programs are good if GUI is not installed or you are working with remote system over the ssh based session. Linux and UNIX-like oses comes with KDE and Gnome desktop system. You will find Free Disk Space Applet located under GUI menus. Here is a sample from Fedora Linux version 22 system:

Conclusion

You learned how to keep track of disk utilization, and disk space with various Linux and Unix commands.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

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

Last updated March 21, 2021 By Abhishek Prakash 18 Comments

How much disk space I have 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.

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:

» data-medium-file=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/free-disk-space-linux-df-command-output.png?fit=300%2C181&ssl=1″ data-large-file=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/free-disk-space-linux-df-command-output.png?fit=786%2C475&ssl=1″ loading=»lazy» width=»786″ height=»475″ src=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/free-disk-space-linux-df-command-output.png?resize=786%2C475&ssl=1″ alt=»Free Disk Space Linux Df Command Output» srcset=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/free-disk-space-linux-df-command-output.png?w=786&ssl=1 786w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/free-disk-space-linux-df-command-output.png?resize=300%2C181&ssl=1 300w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/free-disk-space-linux-df-command-output.png?resize=768%2C464&ssl=1 768w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/free-disk-space-linux-df-command-output.png?resize=150%2C91&ssl=1 150w» sizes=»(max-width: 786px) 100vw, 786px» data-recalc-dims=»1″/> Checking free disk space with df command in Linux

If the above output is confusing for you, don’t worry. I’ll explain a few things around checking available disk space in Linux. I’ll also show the GUI method for desktop Linux users.

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

» data-medium-file=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/df-command-output.png?fit=300%2C225&ssl=1″ data-large-file=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/df-command-output.png?fit=800%2C600&ssl=1″ loading=»lazy» width=»800″ height=»600″ src=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/df-command-output.png?resize=800%2C600&ssl=1″ alt=»Df Command Output» srcset=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/df-command-output.png?w=800&ssl=1 800w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/df-command-output.png?resize=300%2C225&ssl=1 300w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/df-command-output.png?resize=768%2C576&ssl=1 768w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/df-command-output.png?resize=150%2C113&ssl=1 150w» sizes=»(max-width: 800px) 100vw, 800px» data-recalc-dims=»1″/> Understanding 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.

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.

» data-medium-file=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/lsblk-command-to-see-disks-linux.png?fit=300%2C205&ssl=1″ data-large-file=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/lsblk-command-to-see-disks-linux.png?fit=786%2C538&ssl=1″ loading=»lazy» width=»786″ height=»538″ src=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/lsblk-command-to-see-disks-linux.png?resize=786%2C538&ssl=1″ alt=»Lsblk Command To See Disks Linux» srcset=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/lsblk-command-to-see-disks-linux.png?w=786&ssl=1 786w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/lsblk-command-to-see-disks-linux.png?resize=300%2C205&ssl=1 300w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/lsblk-command-to-see-disks-linux.png?resize=768%2C526&ssl=1 768w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/lsblk-command-to-see-disks-linux.png?resize=150%2C103&ssl=1 150w» sizes=»(max-width: 786px) 100vw, 786px» data-recalc-dims=»1″/>

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.

Источник

Читайте также:  Как прописать dns сервер windows
Оцените статью