Ultimate Linux Cheat Sheet: Quick Reference for Beginners

Ultimate Linux Cheat Sheet: Quick Reference for Beginners

File Commands

CommandDescription
catPrint file contents
touchCreate file (or update timestamp)
cpCopy a file
mvMove / rename a file
rmRemove file
headPrint first 10 lines of file
tailPrint last 10 lines of file
tail -fPrint last 10 lines and new lines added to file

Directory Commands

CommandDescription
lsList files in the current directory
ls -lList files with details
ls -aList all files (including hidden)
ls -alList all files with details
pwdPrint the current/working directory
cdChange current directory

System Information Commands

CommandDescription
dfShow file system disk usage
df -hShow disk usage in MB/GB/TB
duShow disk usage per directory
du -hShow disk usage in MB/GB/TB
freeShow memory usage
free -hShow memory usage in MB/GB/TB
uptimeShow uptime
whoamiShow current user
unameShow system information
uname -aShow all system information

Shutdown/Reboot Commands

CommandDescription
shutdownPower off the system after 1 minute
shutdown nowPower off the system immediately
shutdown 16:30Power off the system at 16:30
shutdown -cCancel a scheduled shutdown
rebootReboot system
poweroffPower off system

Process Commands

CommandDescription
psList processes
ps -efList all processes
topDisplay processes in real-time
killKill process
pkillKill process with name
killallKill all processes with name

Bash Shortcuts

ShortcutDescription
Ctrl + CStop current command
Ctrl + AGo to beginning of line
Ctrl + EGo to end of line
Ctrl + KCut current line
Ctrl + LClear screen

Secure Shell (SSH) Commands

CommandDescription
ssh-keygenGenerate SSH key pair
ssh-addAdd SSH key to SSH agent
ssh-add -lList SSH keys in SSH agent
ssh-copy-id @Copy SSH key to <user@host>
sshConnect to <host> as current user
ssh @Connect to <user@host>
scp <file> <host>:Copy local file <file> to <host>
scp <host>:<file>Copy file <file> from <host> to local

APT Commands (Debian/Ubuntu)

CommandDescription
apt installInstall package
apt removeRemove package
apt purgeRemove package and config files
apt updateUpdate package list
apt upgradeUpgrade packages
apt searchSearch for package

IO Redirection

CommandDescription
>Replace contents of file with output
>>Append output to file
<Redirect input from file
2>Redirect stderr to file
&>Redirect stdout and stderr to file

Pipe Commands

CommandDescription
<cmd1><cmd2>Pipe stdout to next cmd
<cmd1>&<cmd2>Pipe stderr to next cmd

Directory Structure

DirectoryDescription
/Root
/binBinary or executable programs
/etcSystem configuration files
/homeUser home directories
/optOptional or third-party software
/tmpTemporary files
/usrUser programs
/varVariable data
/var/logLog files

Other Commands

CommandDescription
echoPrint message to stdout
manDisplay manual page for a command
historyDisplay history of given commands
whichFind path to executable
whereisLocate binary, source, and manual page for a command