Ubuntu Tutorial

free command : it is used to display amount of free and used memory in the system. it displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. output will display total, used, free, shared, buffers, cache, buff/cache, available columns. for more information use man free or info free commands.

  • total : Total installed memory (MemTotal and SwapTotal)
  • used : Used memory (calculated as total - free - buffers - cache)
  • free : Unused memory (MemFree and SwapFree)
  • shared : Memory used (mostly) by tmpfs.
  • buffers : Memory used by kernel buffers (Buffers)
  • cache : Memory used by the page cache and slab
  • buff/cache : Sum of buffers and cache
  • available : Estimation of how much memory is available for starting new applications, without swapping.

syntax : free option

free command

following are options for free command.

Option Description
-b or --bytes display memory in bytes
-k or --kibi display memory in kibibytes. this is by default
-m or --mebi display memory in mebibytes
-g or --gibi display memory in gibibytes
-h or --human display memory in human readable format
-w or --wide switch to the wide mode. In this mode buffers and cache are reported in two separate columns
-c or --count count display the result count times. Requires the -s option
-l or --lohi show detailed low and high memory statistics
-s or --seconds delay continuously display the result delay seconds apart
--si Use kilo, mega, giga etc (power of 1000) instead of kibi, mebi, gibi (power of 1024).
-t or --total display a line showing the column totals

df command : it is used to report file system disk space usage.df displays the amount of disk space available on the file system containing each file name argument. If no file name is given, then it print space available on all currently mounted file systems. by default Disk space is given in 1K blocks. for more information use man df or info df commands.

syntax : df options files

df command

following table shows option for df command.

Option Description
-a or --all include pseudo, duplicate, inaccessible file systems
-h or --human-readable print sizes in human readable format (powers of 1024)
-H or --si print sizes in powers of 1000
-i or --inodes list inode information instead of block usage
-l, --local limit listing to local file systems
--no-sync this is by default. do not invoke sync before getting usage info
-P or --portability use the POSIX output format
--sync invoke sync before getting usage info
--total elide all entries insignificant to available space, and produce a grand total
-t or --type=TYPE limit listing to file systems of type TYPE
-T or --print-type print file system type
-x or --exclude-type=TYPE limit listing to file systems not of type TYPE

watch command : it is used to execute a command or program periodically and print output in full screen. it allows to watch output changing over time. at the top of full screen(right hand side) it will display the interval, command, and current time. by default command or program will run periodically in every 2 seconds. to close or exit the output use shortcut. ctrl + c

syntax : watch option command or program

in following Example we keep watch on free command. it will run periodically in every 2 seconds. so any change in memory will be visible on screen.

watch command

following table shows options for watch command.

Option Description
-b or --beep beep if command has a non-zero exit
-d or --differences highlight the changes when any change happen in output.
-e or --errexit freeze updates on command error and exit after a key press
-g or --chgexit exit when the output of command changes
-n N or --interval N specify interval to update or periodically run command or program.
here N is seconds
-t or --no-title turn off the header showing the interval, command, and current time at the
top of the display, as well as the following blank line

in following examples we set watch on ls command. this will allow us to see any updates in file operations like new file created, new sub directory created, deletion of file or directory.

command : watch ls

output :

watch ls command output