На информационном ресурсе применяются рекомендательные технологии (информационные технологии предоставления информации на основе сбора, систематизации и анализа сведений, относящихся к предпочтениям пользователей сети "Интернет", находящихся на территории Российской Федерации)

Feedbox

12 подписчиков

How to View Free Disk Space and Disk Usage From the Linux Terminal

Author: Dave McKay / Source: How-To Geek

Bash shell on Unity desktop concept
Fatmawati Achmad Zaenuri/Shutterstock.com

The df and du commands report on disk space usage from within the Bash shell used on Linux, macOS, and many other Unix-like operating systems. These commands let you easily identify what’s using up your system’s storage.

Viewing the Total, Available and Used Disk Space

Bash contains two useful commands related to disk space. To find out the available and used disk space, use df (disk filesystems, sometimes called disk free). To discover what’s taking up the used disk space, use du (disk usage).

Type df and press enter in a Bash terminal window to get started. You’ll see a lot of output similar to the screenshot below. Using df without any options will display the available and used space for all mounted filesystems. At first glance, it might look impenetrable, but it is quite easy to understand.

df
output from df command

Each line of the display is made up of six columns.

  • Fileystem: The name of this filesystem.
  • 1K-Blocks: The number of 1K blocks that are available on this filesystem.
  • Used: The number of 1K blocks that have been used on this file system.
  • Available: The number of 1K blocks that are unused on this file system.
  • Use%: The amount of space used in this file system given as a percentage.
  • File: The filesystem name, if specified on the command line.
  • Mounted on: The mount point of the filesystem.

You can replace the 1K block counts with more useful output by using the -B (block size) option. To use this option, type df, a space, and then -B and a letter from the list of K, M, G, T, P, E, Z or Y. These letters represent the kilo, mega, giga, tera, peta, exa, zeta, and yotta values from the multiple of 1024 scale.

For example, to see the disk usage figures in megabytes, you would use the following command. Note there is no space between the B and M.

df -BM
output from df command with -BM options

The -h (human readable) option instructs df to use the most applicable unit for the size of each filesystem. In the next output note that there are filesystems with gigabyte, megabyte and even kilobyte sizes.

df -h
Output from df command with -h option

If you need to see the information represented in numbers of inodes, use the -i (inodes) option. An inode is a data structure used by Linux filesystems to describe files and to store metadata about them. On Linux, inodes hold data such as the name, modification date, position on the hard drive, and so on for each file and directory. This isn’t going to be useful to the majority of people, but system administrators must sometimes refer to this type of information.

df -i
output from df command with -i option

Unless told not to, df will provide information on all of the mounted file systems. This can lead to a cluttered display with a lot of output. For example, the /dev/loop entries in the lists are pseudo file systems that allow a file to be mounted as though it were a partition. If you use the new Ubuntu snap method of installing applications, you can acquire a lot of these. The space available on these will always be 0 because they aren’t really a filesystem, so we don’t need to see them.

We can tell df to exclude filesystems of a specific type. To do so, we need to know what type of filesystem we wish to exclude. The -T (print-type) option will give us that information. It instructs df to include the type of filesystem in the output.

df -T
Output from df command with -T option

The /dev/loop entries are all squashfs filesystems. We can exclude them with the following command:

df -x squashfs
Output from df command with df -x squashfs options

That gives us a more manageable output. To get a total, we can add the --total option.

df -x squashfs --total
Output from df command with df -x squashfs --total options

We can ask df

Click here to read more

The post How to View Free Disk Space and Disk Usage From the Linux Terminal appeared first on FeedBox.

Ссылка на первоисточник

Картина дня

наверх