'du' - Finding the size of a directory
$ du
Typing the above at the prompt gives you a list of directories
that exist in the current directory along with their sizes.
The last line of the output gives you the total size of the
current directory including its subdirectories. The size given
includes the sizes of the files and the directories that exist
in the current directory as well as all of its subdirectories.
Note that by default the sizes given are in kilobytes.
$ du / -h --max-depth 1 list the same info in GB/MB for the root directory and go only one level in depth/down
$
du /home/deyan
The above command would give you the directory size of the directory
/home/deyan
$ du -h
This command gives you a better output than the default one.
The option '-h' stands for human readable format. So
the sizes of the files / directories are this time suffixed
with a 'k' if its kilobytes and 'M' if its Megabytes and 'G'
if its Gigabytes.
$ du -ah
This command would display in its output, not only the directories
but also all the files that are present in the current directory.
Note that 'du' always counts all files and directories while
giving the final size in the last line. But the '-a' displays
the filenames along with the directory names in the output.
'-h' is once again human readable format.
$
du -c
This gives you a grand total as the last line of the
output. So if your directory occupies 30MB the last 2 lines
of the output would be
30M .
30M total
The first line would be the default last line of the 'du' output
indicating the total size of the directory and another line
displaying the same size, followed by the string 'total'.
This is helpful in case you this command along with the grep
command to only display the final total size of a directory
as shown below.
$ du -ch | grep total
This would have only one line in its output that displays the
total size of the current directory including all the subdirectories.
$ du -s
This displays a summary of the directory size. It is the simplest
way to know the total size of the current directory.
$
du -S
This would display the size of the current directory excluding
the size of the subdirectories that exist within that directory.
So it basically shows you the total size of all the files
that exist in the current directory.
-
'df' - finding the disk free space / disk usage
$ df
Typing the above, outputs a table consisting of 6 columns. All
the columns are very easy to understand. Remember that the 'Size',
'Used' and 'Avail' columns use kilobytes as the unit. The 'Use%'
column shows the usage as a percentage which is also very useful.
$ df -h
Displays the same output as the previous command but the '-h'
indicates human readable format. Hence instead of kilobytes
as the unit the output would have 'M' for Megabytes and 'G'
for Gigabytes.
Showing posts with label df. Show all posts
Showing posts with label df. Show all posts
Wednesday, 15 January 2014
Tuesday, 19 February 2013
Get information about Linux partitions
To Display Hard Disk Partition Size in Mega bytes or GB or TB:
$ df -H
To list all block devices, run:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 1 558G 0 disk ├─sda1 8:1 1 307M 0 part /boot ├─sda2 8:2 1 250G 0 part /webroot ├─sda3 8:3 1 6G 0 part [SWAP] ├─sda4 8:4 1 1K 0 part └─sda5 8:5 1 301.7G 0 part / sr0 11:0 1 1024M 0 rom
To determine the file system type or to find out what type of file systems currently mounted:
$ df -T
df command report filesystem disk space usage and if you pass -T option it will report filesystem type.
$ mount
/dev/hdb1 on / type ext3 (rw,errors=remount-ro) /dev/hdb2 on /home type ext3 (rw,errors=remount-ro) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) usbfs on /proc/bus/usb type usbfs (rw) automount(pid3558) on /data type autofs (rw,fd=4,pgrp=3558,minproto=2,maxproto=4)
As you can see, second last column displays the file system type. For example first line [/dev/hdb1 on / type ext3 (rw,errors=remount-ro)] can be interpreted as follows:
- /dev/hdb1 : Partition
- / : File system
- ext3 : File system type
- (rw,errors=remount-ro) : Mount options
fdisk -l
Disk /dev/sda: 251.1 GB, 251059544064 bytes
255 heads, 63 sectors/track, 30522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008fcd3
Device Boot Start End Blocks Id System
/dev/sda1 * 1 14 104448 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 14 13068 104857600 83 Linux
/dev/sda3 13068 13198 1048576 82 Linux swap / Solaris
/dev/sda4 13198 30523 139163648 5 Extended
/dev/sda5 13198 30523 139162624 83 Linux
the star on /dev/sda1 shows that this is the bootable partitionfdisk -l | grep Disk
fdisk device {fdisk /dev/sda1}
cfdisk
- DOS-based utility to manupulate partitions
sfdisk -l /dev/sda
Subscribe to:
Posts (Atom)