Cheat sheet for Common Linux commands

Published On: June 3, 2022

For years I used an IP subnet cheat sheet when I first got into networking. Recently I saw the site I used, which is still the top result on google more than a decade later.

Here is a command cheat sheet for Linux, that I will expand on to include commands I use almost daily. In the hopes, it might grow into something useful to someone.

As Debian is our distribution of choice, some of these might not apply if you make use of different distributions.

Finding files

My go-to package is mlocate. To install, simply run:

• apt-get update
• apt-get install mlocate

Then to build the DB run:

• updatedb

Then to find a file is as easy as typing

• locate filename

History of commands

To see a history of the commands run, simply type:

• history

If you only want the history related to a specific term, let’s say mysql, simply use grep (We will expand on grep later.).

• history | grep mysql


Show the IP Address config of the host

• Ip Address

Sizing commands

– du command
  • Common flags
    • -0, –null : end each output line with NULL
    • -a, –all : write count of all files, not just directories
    • –apparent-size : print apparent sizes, rather than disk usage
    • -B, –block-size=SIZE : scale sizes to SIZE before printing on console
    • -c, –total : produce grand total
    • -d, –max-depth=N : print total for directory only if it is N or fewer levels below command line argument
    • -h, –human-readable : print sizes in human readable format
    • -S, -separate-dirs : for directories, don’t include size of subdirectories
    • -s, –summarize : display only total for each directory
    • –time : show time of last modification of any file or directory
    • –exclude=PATTERN : exclude files that match PATTERN
  • The most common form of this command I use is to get the size of a folder:

• du -sh /tmp/folderIWantTheSizeOf

‘s’ to summarize the total size for the directory, instead of list it next level contents

‘h’ for human-readable, which will show it in mb, gb, tb depending on the most appropriate size to round to

– df command

  • Common flags

    -a, –all : includes pseudo, duplicate and inaccessible file systems

    -B, –block-size=SIZE : scales sizes by SIZE before printing them

    -h, –human-readable : print sizes in power of 1024

    -H, –si: print sizes in power of 1000

    -i, –inodes : list inode information instead of block usage

    -l, –local : limit listing to local file systems

    -P, –portability : use POSIX output format

    –sync : invoke sync before getting usage info

    –total : elide all entries insignificant to available space, and produce grand total

    -t, –type=TYPE : limit listing to file systems of type TYPE

    -T, –print-type : print file system type

    The most common form of this command I run is to see the space usage of the drives

• df -h

‘h’ for human-readable, which will show it in mb, gb, tb depending on the most appropriate size to round to

If this was helpful go and have a look at our other blog posts!

About the Author: Jaco Jacobs

Avatar photo
Jaco Jacobs has been involved in the Information Technology industry for more than 23 years. The founder of Grand Communication Networks and currently spearheading the expansion into the U.S.

Related Articles

  • Published On: November 30, 2023

    Introduction In today's fast-paced e-commerce landscape, providing customers with accurate and up-to-date information is essential for success. At Grand Communication Networks, we understand the [...]

  • Published On: June 30, 2023

    I often start off these posts with telling you how excited our team was in a specific project, but this was especially true on this [...]

  • Published On: June 30, 2023

    Our team recently got commissioned to integrate Shopify and Karmak for a solution to sell auto parts online. With our interactions with the auto [...]