Skip to main content
eLearner.app

Linux Terminal

Cheatsheet

A quick reference — the essential Linux Terminal syntax on a single page. Press Ctrl/Cmd + P to print it.

Linux · Cheatsheet — eLearner.app

Navigation & Exploration

  • Current path (pwd)

    pwd

    Print Working Directory: displays the absolute path of the current directory.

  • List files (ls)

    ls

    Lists visible files and folders in the current directory.

  • Show hidden files (ls -a)

    ls -a

    Includes hidden files (those starting with a dot, e.g., .bashrc).

  • Detailed listing (ls -l)

    ls -l

    Shows permissions, owner, file size, and last modified date.

Moving in the File System (cd)

  • Enter a folder

    cd documents
    cd /var/log

    Accepts relative paths (documents) or absolute paths (starting with /).

  • Go back (cd ..)

    cd ..

    Moves the terminal up one directory level to the parent folder.

  • Home folder (cd ~)

    cd ~

    Moves to the home directory of the current user (e.g., /home/user).

  • Previous folder (cd -)

    cd -

    Returns to the last directory visited before the current one.

Resource Creation

  • Create an empty file (touch)

    touch app.log
    touch index.html

    If the file already exists, updates its modification timestamp without modifying its contents.

  • Create a directory (mkdir)

    mkdir projects
  • Create nested paths (mkdir -p)

    mkdir -p projects/frontend/src

    The -p option creates any missing parent directories recursively.

Copying & Moving

  • Copy a file (cp)

    cp info.txt backup.txt
  • Copy a directory (cp -r)

    cp -r documents backup_documents

    The -r option indicates recursive copying, which is mandatory for directories.

  • Move or rename (mv)

    mv info.txt docs/info.txt
    mv old.txt new.txt

    If the destination is a directory, moves the file; otherwise, renames it.

Deleting Resources

  • Delete files (rm)

    rm file.txt

    Warning: command line deletion is immediate and permanent (does not go to trash).

  • Delete directories (rm -r)

    rm -r projects_folder

    Recursive deletion, required to remove directories and all their contents.

  • Force delete (rm -f)

    rm -f protected_file.txt
    rm -rf folder_to_delete

    The -f option ignores non-existent files and never prompts for confirmation.

Contents & Redirects

  • Print messages (echo)

    echo "Welcome to the terminal"
  • Read file content (cat)

    cat notes.txt

    Concatenates and prints: prints the entire contents of one or more files.

  • Redirect and overwrite (>)

    echo "New text" > file.txt

    Redirects the output of a command into a file, overwriting its existing content.

  • Redirect and append (>>)

    echo "Additional note" >> file.txt

    Appends output to the end of the file, without erasing pre-existing text.

Pipelines & Filters

  • Chain commands (|)

    cat log.txt | grep "ERROR"

    The pipe (|) feeds the standard output of the first command as standard input to the second.

  • Search within a file (grep)

    grep "warning" sys.log

    Filters and prints only the lines containing the specified text pattern.

  • Case-insensitive search (grep -i)

    grep -i "error" sys.log

    Searches while ignoring case differences (e.g., matches Error, ERROR, error).

  • Recursive folder search (grep -r)

    grep -r "TODO" src/

    Searches for the text pattern inside all files in the target directory and its subdirectories.

eLearner.app · Linux Course · cheatsheet generated from lesson contents.