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)
pwdPrint Working Directory: displays the absolute path of the current directory.
List files (ls)
lsLists visible files and folders in the current directory.
Show hidden files (ls -a)
ls -aIncludes hidden files (those starting with a dot, e.g., .bashrc).
Detailed listing (ls -l)
ls -lShows permissions, owner, file size, and last modified date.
Moving in the File System (cd)
Enter a folder
cd documents cd /var/logAccepts 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.htmlIf the file already exists, updates its modification timestamp without modifying its contents.
Create a directory (mkdir)
mkdir projectsCreate nested paths (mkdir -p)
mkdir -p projects/frontend/srcThe -p option creates any missing parent directories recursively.
Copying & Moving
Copy a file (cp)
cp info.txt backup.txtCopy a directory (cp -r)
cp -r documents backup_documentsThe -r option indicates recursive copying, which is mandatory for directories.
Move or rename (mv)
mv info.txt docs/info.txt mv old.txt new.txtIf the destination is a directory, moves the file; otherwise, renames it.
Deleting Resources
Delete files (rm)
rm file.txtWarning: command line deletion is immediate and permanent (does not go to trash).
Delete directories (rm -r)
rm -r projects_folderRecursive deletion, required to remove directories and all their contents.
Force delete (rm -f)
rm -f protected_file.txt rm -rf folder_to_deleteThe -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.txtConcatenates and prints: prints the entire contents of one or more files.
Redirect and overwrite (>)
echo "New text" > file.txtRedirects the output of a command into a file, overwriting its existing content.
Redirect and append (>>)
echo "Additional note" >> file.txtAppends 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.logFilters and prints only the lines containing the specified text pattern.
Case-insensitive search (grep -i)
grep -i "error" sys.logSearches 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.