🖥️df

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the df command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ███████╗
#                ██╔══██╗██╔════╝
#                ██║  ██║█████╗  
#                ██║  ██║██╔══╝  
#                ██████╔╝██║     
#                ╚═════╝ ╚═╝     

# Printout disk free space in a human readable format 
df -h

# Disk free space for ext2 file systems
df -t ext2

# Disk free space for file systems except ext2
df -x ext2

# Show inode usage. On Linux and others, display the inodes used per filesystem. Useful for determining how long it takes to backup or search the fs.
df -i

# Show information about a distinct file system /path
df /path

#==============================#
# CMD DF
#==============================##==============================#
df -hi

# Quickly find out how much data space is left on the partition that the current directory you are in resides.
df -h . 

df -k | grep "/dev/hd\|/dev/sd\|\>awk '{print $1, $4/2^10}'"

# If your Linux device names are long enough that it wraps lines, try using -hP and pipe to column for nicer output.
df -hP | column -t 

# Sort the output of df while keeping the header at the top. 
df -hP | awk 'NR==1;NR>1{print|"sort -k5rn"}' 

# Show the total space used on all your local disk partitions.
df -lP |awk '{sum += $3} END {printf "%d GiB\n", sum/2**20}'

# Annoyed by wrapped lines in df output. Try -P to unwrap the lines and piping to column will align the columns.
df -P | column -t

# Print disk space used on all ext3 or 4 FS in GiB.
df -Pl -t ext3 -t ext4 | tail -n+2 | awk '{ sum+=$3 } END { print sum/2**20 }'

#  How do you find out the file system capacity or free space? 
df -h
    Filesystem   Size  Used   Avail Use%  Mounted on
    /dev/dev1    97G   6.0G   86G   7%    /
    /dev/dev2    97G   96G     1G   99%   /home
# The df command lists all the filesystems in the system. Infact, df -h gives more readable output - The used column tells the used space, and the available column tells the available space. This indicates /home is 99% full. The "-h" is to give the output in readable format such as kb,MB or GB.

df -text{2..4} -hP |column -t |tail -n+2 |sort -k5nr -k4n 
# Show ext2, 3 & 4 FS w/ human readable output. Sort percent,space left.

# Show used disk space:
df -klP -t xfs -t ext2 -t ext3 -t ext4 -t reiserfs | grep -oE ' [0-9]{1,}( +[0-9]{1,})+' | awk '{sum_used += $2} END {printf "%.0f GB\n", sum_used/1024/1024}'

# Show allocated disk space:
df -klP -t xfs -t ext2 -t ext3 -t ext4 -t reiserfs | grep -oE ' [0-9]{1,}( +[0-9]{1,})+' | awk '{sum_used += $1} END {printf "%.0f GB\n", sum_used/1024/1024}'

# Get the available space on a partition as a single numeric value
df /path/to/dir | sed -ne 2p | awk '{print $4}'

# Explanation: 
    # sed -ne 2p prints the 2nd line
    # awk '{print $4}' prints the 4th column

# Limitations: The output of the df command might be different depending on the system, and the available space might not be the 4th column. Make the necessary adjustments depending on your system.

#==============================##==============================#
# CMD df						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░