Linux Commands Examples

A great documentation place for Linux commands

df

report file system disk space usage

Synopsis

df [OPTION]... [FILE]...


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

0
source
            
/bin/df -Ph
0
source
            
df -k
ls
0
source

How to analyse disk usage in command line linux?

Use some combination of the commands and options:

du --max-depth=1 2> /dev/null | sort -n -r | head -n20

to view only the largest few. If you'd like to use it a lot, then bind it to an alias, e.g. in bash by adding to ~/.bashrc

alias largest='du --max-depth=1 2> /dev/null | sort -n -r | head -n20'
0
source

How do I change the default for the "df" command in the Unix/Linux Terminal in the tcsh shell?

My df takes a -m flag:

$ df -m
Filesystem                  1M-blocks   Used Available Capacity  Mounted on
/dev/disk0s2                   380516 311007     69258    82%    /
devfs                               0      0         0   100%    /dev
map -hosts                          0      0         0   100%    /net
map auto_home                       0      0         0   100%    /home
/dev/disk0s3                    96094  42464     53630    45%    /Volumes/BOOTCAMP

You can also use df -h to get 'human-readable' values:

$ df -h
Filesystem                    Size   Used  Avail Capacity  Mounted on
/dev/disk0s2                 372Gi  304Gi   68Gi    82%    /
devfs                        124Ki  124Ki    0Bi   100%    /dev
map -hosts                     0Bi    0Bi    0Bi   100%    /net
map auto_home                  0Bi    0Bi    0Bi   100%    /home
/dev/disk0s3                  94Gi   41Gi   52Gi    45%    /Volumes/BOOTCAMP

You can also set the environment variable BLOCKSIZE to 1M, and save that in your .profile to make it the default.

$ BLOCKSIZE=1M df
Filesystem                  1M-blocks   Used Available Capacity  Mounted on
/dev/disk0s2                   380516 311008     69257    82%    /
devfs                               0      0         0   100%    /dev
map -hosts                          0      0         0   100%    /net
map auto_home                       0      0         0   100%    /home
/dev/disk0s3                    96094  42464     53630    45%    /Volumes/BOOTCAMP
0
source

Running out of disk space on /home directory?

The output of df -h ("human-readable sizes") might be a little clearer than plain df.

In fact, it would probably show that the size of / is only about 13 GB – I'm guessing you created a second ~190 GB partition for /home but forgot to actually have it mounted, so all files are being stored on the first (/) partition.

You can use lsblk or partitioning tools such as parted/gparted to list all existing partitions and their sizes.

Check if the partition for /home is listed by lsblk or in your /etc/fstab, then try to mount it. But for now, mount it somewhere else than /home, though – for example, /mnt – to make transferring the files easier.


Your update shows a large partition at /dev/sda1. You can mount it temporarily on /mnt:

# mount /dev/sda1 /mnt

If the command succeeds, it will return quietly. If it complains about "unknown fstype", it might be that the partition does not have any file system yet – mkfs.ext4 /dev/sda1 would format it as ext4, the most common one.

To move your files over, log out from your account, then log in as root, and use rsync -avP /home/ /mnt/ to transfer data. Afterwards, delete it from old /home manually.

To make the partition permanenly mounted on /home, add the following to fstab:

/dev/sda1  /home  ext4  rw,relatime,acl  0  2

Having / and /home separate makes it much easier to reinstall Linux (e.g. if you ever want to switch distributions). But if you want to merge them, you can do that with gparted – however, only from a live CD, not from the same system.

Inside GParted, simply delete the large empty partition, and resize the existing 13 GB one. Be aware that you might need to reinstall your bootloader (GRUB or whatever) after doing so.

0
source

df reported size/used/available discrepancy

This is most likely due to reserved space for the super-user on an ext2/ext3/ext4 filesystem, plus a small rounding error when converting blocks to gigabyte sizes. See this similar discussion.

0
source

Missing space on hdd linux?

Linux by default reserves 5% of each partition for the root user. 5% of 71G = 3.55G; 2.0G + 3.55G = 5.55G; 65G + 5.55G = 70.55G which rounds up to 71G.

0
source

In Linux, is it possible to get a listing of drives' disk space usage that also shows volume labels?

You can use df to find out the disk space information and use blkid -o list to obtain information about the disk labels and UUIDs.

# blkid -o list
device     fs_type label    mount point    UUID
-------------------------------------------------------------------------------
/dev/sda1  ext4             /              2ea411b8-f6eb-456b-9ac8-efc1f264bee4
/dev/sda5  swap             <swap>         e5732469-d123-4f24-948b-ab356576c140

You have to be root to see the label and UUID values.

0
source

Get hard disk size without df

While not the easiest to parse, and not recommended for scripting purposes, fdisk -l /dev/sdX should give you the information you're looking for.

description

This manual page documents the GNU version of df. df displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown. Disk space is shown in 1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.

If an argument is the absolute file name of a disk device node containing a mounted file system, df shows the space available on that file system rather than on the file system containing the device node (which is always the root file system). This version of df cannot show the space available on unmounted file systems, because on most kinds of systems doing so requires very nonportable intimate knowledge of file system structures.

options

Show information about the file system on which each FILE resides, or all file systems by default.

Mandatory arguments to long options are mandatory for short options too.
-a
, --all

include dummy file systems

-B, --block-size=SIZE

scale sizes by SIZE before printing them. E.g., ’-BM’ prints sizes in units of 1,048,576 bytes. See SIZE format below.

--total

produce a grand total

-h, --human-readable

print sizes in human readable format (e.g., 1K 234M 2G)

-H, --si

likewise, but use powers of 1000 not 1024

-i, --inodes

list inode information instead of block usage

-k

like --block-size=1K

-l, --local

limit listing to local file systems

--no-sync

do not invoke sync before getting usage info (default)

-P, --portability

use the POSIX output format

--sync

invoke sync before getting usage info

-t, --type=TYPE

limit listing to file systems of type TYPE

-T, --print-type

print file system type

-x, --exclude-type=TYPE

limit listing to file systems not of type TYPE

-v

(ignored)

--help

display this help and exit

--version

output version information and exit

Display values are in units of the first available SIZE from --block-size, and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).

copyright

Copyright © 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

reporting bugs

Report df bugs to bug-coreutils[:at:]gnu[:dot:]org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report df translation bugs to <http://translationproject.org/team/>


see also

The full documentation for df is maintained as a Texinfo manual. If the info and df programs are properly installed at your site, the command

info coreutils 'df invocation'

should give you access to the complete manual.


author

Written by Torbjorn Granlund, David MacKenzie, and Paul Eggert.

How can this site be more helpful to YOU ?


give  feedback