TLDR · · 2 min read

Linux Cheatsheet - General Commands

We've put together a list and a PDF cheatsheet of the most commonly used Linux commands (of any flavour) as a reference for all.

Image displaying the words TLDR, with a lightning bolt and next to it, the words Linux. This featured image is used for this post that goes through Linux Commands, in a cheatsheet style.

Here, I've put together some of the most used commands you'll use when working with Linux, in any flavour, in a neat cheat sheet.

Below, you'll find the commands in code-blocks as well as a nifty PDF that you can print off to hang on your wall and show off to all your friends! (if that's your thing)

File and Directory Commands

$ ls       [ls -la]                  # List directory contents
$ cd       [cd /var/log]             # Change the current directory
$ pwd      [pwd]                     # Print the current directory path
$ mkdir    [mkdir new_folder]        # Create a new directory
$ cp       [cp file.txt /backup/]    # Copy files or directories
$ mv       [mv old.txt new.txt]      # Move or rename files/ directories
$ rm       [rm file.txt]             # Deletes files or directories
$ touch    [touch myfile.txt]        # Create an empty file
$ find     [find / -name '*.log']    # Search files in a directory tree

File Viewing and Text Processing

$ cat      [cat file.txt]                 # Display file content
$ nano     [nano config.cfg]              # Simple terminal text editor
$ less     [less file22.txt]              # View file one page at a time
$ head     [head -n 20 file.txt]          # Show first X amount of lines
$ tail     [tail log.txt]                 # Show last lines of file
$ grep     [grep 'error' logfile.txt]     # Search text patterns in files
$ sort     [sort names.txt]               # Sort lines in text
$ wc       [wc file.txt]                  # Count lines, words, bytes
$ sed      [sed 's/old/new/g']            # Find and replace in text
$ awk      [awk '{print $1}' file.txt]    # Pattern scanning and text processing
$ diff     [diff file1.txt file2.txt]     # Compare files line by line

System and Process Management

$ uname    [uname -a]                # Shows system information
$ whoami   [whoami]                  # Displays current username
$ free     [free -h]                 # Show memory usage
$ df       [df -h]                   # Show disk space usage
$ du       [du -sh *]                # Estimate file space usage
$ ps       [ps aux]                  # Display running processes
$ top      [top]                     # Monitor processes and utilisation live
$ kill     [kill -9 1234]            # Terminate a process by ID

User/Permissions and Shell/Utilities

$ sudo     [sudo apt update]                 # Run command as super user
$ passwd   [passwd]                         # Change password
$ tar      [tar -czvf file.tar.gz folder/]  # Archive file
$ echo     [echo $HOME]                     # Print text or variables
$ which    [which python3]                  # Locate executable path
$ man      [man grep]                       # Display command manual
$ alias    [alias ll='ls -la']              # Create a command shortcut


If you feel additional commands would be handy to have here and help others, please let me know in the comments and I'll ensure to update it/ include an additional page in the PDF.

Read next