Linux Command Reference
Every essential Linux command, shell feature and system file in one place: concise, accurate pages with live examples that run in a real Bash shell, with syntax, options and common mistakes.
Files and Directories
-
lsList directory contents. -
cdChange the working directory. -
pwdPrint the working directory. -
mkdirCreate directories. -
rmdirRemove empty directories. -
touchCreate files and set timestamps. -
cpCopy files and directories. -
mvMove or rename files. -
rmRemove files and directories. -
lnCreate hard and symbolic links. -
readlinkResolve symbolic links. -
realpathPrint resolved absolute paths. -
basenameStrip directory and suffix from a path. -
dirnameStrip the last component of a path. -
statShow detailed file metadata. -
fileGuess a file's type from its content. -
treeShow directories as a tree. -
mktempCreate safe temporary files and directories. -
installCopy files and set mode in one step. -
truncateShrink or extend a file to a size. -
ddLow-level block copying and conversion. -
shredOverwrite a file to hide its content. -
pushd, popd and dirsDirectory stack builtins. -
mkfifoCreate named pipes. -
chattr and lsattrExtended file attributes.
Viewing and Searching Files
-
catConcatenate and print files. -
tacPrint files in reverse line order. -
lessPage through text. -
headPrint the first lines. -
tailPrint the last lines and follow files. -
wcCount lines, words and bytes. -
nlNumber lines. -
odDump bytes in octal and other formats. -
xxd and hexdumpHex dumps of files. -
stringsPrint printable strings in binaries. -
findSearch directory trees by attributes. -
locateSearch a filename database. -
whichLocate a command on PATH. -
typeDescribe how a name is interpreted. -
whereisLocate binary, source and man page. -
xargsBuild commands from standard input. -
teeCopy input to a file and to output. -
diffCompare files line by line. -
cmpCompare files byte by byte. -
commCompare two sorted files. -
patchApply a diff to files. -
md5sum and sha256sumChecksums of files. -
splitSplit a file into pieces. -
csplitSplit a file by context.
Text Processing
-
grepSearch text with patterns. -
grep -E and grep -FExtended and fixed-string matching. -
sedStream editor for substitution and editing. -
awkPattern-action text processing language. -
cutExtract columns or fields. -
pasteMerge lines of files side by side. -
joinJoin lines on a common field. -
sortSort lines of text. -
uniqReport or omit repeated lines. -
trTranslate or delete characters. -
foldWrap long lines. -
fmtReformat paragraphs. -
columnFormat text into columns. -
expand and unexpandConvert tabs and spaces. -
revReverse each line. -
shufShuffle lines or pick random ones. -
seqPrint number sequences. -
echoPrint arguments. -
printfFormatted output. -
yesRepeat a string forever. -
numfmtConvert numbers to human-readable units. -
iconvConvert text encodings. -
tsortTopological sort. -
bcArbitrary-precision calculator. -
exprEvaluate simple expressions. -
edThe line editor behind sed. -
vim and nanoTerminal text editors.
Permissions and Users
-
chmodChange file mode bits. -
chownChange file owner and group. -
chgrpChange group ownership. -
umaskDefault permission mask. -
idPrint user and group IDs. -
whoamiPrint the effective user name. -
groupsList group memberships. -
who and wShow logged-in users. -
lastShow login history. -
suRun a shell as another user. -
sudoRun commands as another user. -
useraddCreate user accounts. -
usermodModify user accounts. -
userdelDelete user accounts. -
groupaddCreate groups. -
passwdChange passwords. -
getfacl and setfaclAccess control lists. -
newgrpSwitch the active group.
Processes and Signals
-
psSnapshot of running processes. -
topLive view of processes. -
pgrep and pkillFind and signal processes by name. -
killSend signals to processes. -
killallSignal processes by exact name. -
jobsList shell jobs. -
bg and fgMove jobs between background and foreground. -
waitWait for background processes. -
nohupRun immune to hangups. -
nice and reniceScheduling priority. -
timeMeasure running time. -
timeoutLimit how long a command runs. -
sleepPause for a while. -
watchRun a command repeatedly. -
pstreeShow processes as a tree. -
lsofList open files. -
straceTrace system calls. -
ulimitResource limits. -
execReplace the shell with a command. -
envRun a command with a changed environment. -
cron and atScheduling (read-only). -
uptimeLoad averages and uptime. -
freeMemory usage summary. -
vmstatVirtual memory statistics.
Disks and Filesystems
-
dfFree space per filesystem. -
duDisk usage of files and directories. -
lsblkList block devices. -
mountMount filesystems. -
umountUnmount filesystems. -
fdisk and partedPartition tables. -
mkfsCreate filesystems. -
fsckCheck and repair filesystems. -
blkidShow block device attributes. -
findmntShow mounted filesystems as a tree. -
syncFlush filesystem buffers. -
fstab and mount optionsHow filesystems mount at boot. -
pvcreate, vgcreate and lvcreateLogical volume management. -
swapon and mkswapSwap space. -
quotaDisk quotas.
Archives and Compression
-
tarCreate and extract tar archives. -
gzip and gunzipgzip compression. -
bzip2bzip2 compression. -
xzxz compression. -
zstdZstandard compression. -
zip and unzipZIP archives. -
zcat and zgrepRead compressed files directly. -
cpioCopy files to and from archives. -
rsyncEfficient file synchronization. -
base64Encode and decode Base64. -
arStatic library archives.
Networking
-
pingTest reachability. -
curlTransfer data with URLs. -
wgetDownload files. -
sshSecure remote shell. -
scp and sftpSecure file transfer. -
ssh-keygenCreate and manage SSH keys. -
ipShow and configure network interfaces. -
ssInspect sockets. -
netstatLegacy network statistics. -
dig and nslookupDNS queries. -
hostSimple DNS lookup. -
tracerouteTrace the route to a host. -
ncNetcat for TCP and UDP. -
nmapPort scanning. -
tcpdumpCapture packets. -
iptables and nftFirewall rules. -
hostnameShow or set the host name. -
opensslTLS and cryptography toolkit. -
telnetTest TCP connections. -
/dev/tcpBash built-in TCP redirection.
Packages and Services
-
apt and apt-getDebian and Ubuntu packages. -
dpkgLow-level Debian packages. -
dnf and yumFedora and RHEL packages. -
rpmLow-level RPM packages. -
pacmanArch Linux packages. -
apkAlpine Linux packages. -
snap and flatpakUniversal package formats. -
pip and npm basicsLanguage package managers. -
makeBuild automation. -
systemctlControl systemd services. -
journalctlQuery the systemd journal. -
serviceLegacy service wrapper. -
crontabEdit scheduled jobs. -
logrotateRotate log files. -
loggerWrite to the system log. -
dmesgKernel ring buffer.
System Information
-
unameKernel and system name. -
hostnamectlHost name and OS information. -
dateShow and format the date and time. -
calPrint a calendar. -
timedatectlTime and time zone settings. -
lscpuCPU architecture information. -
lsmod and modprobeKernel modules. -
lspci and lsusbHardware listings. -
nprocNumber of processors. -
getconfQuery system limits. -
localeLanguage and encoding settings. -
manManual pages. -
info and helpOther documentation. -
aproposSearch manual page descriptions. -
ttyName of the terminal. -
sttyTerminal settings. -
clear and resetClear or reset the terminal. -
historyCommand history. -
aliasCommand shortcuts. -
scriptRecord a terminal session. -
tputTerminal capabilities and colors.
Shell Builtins
-
source and .Run a file in the current shell. -
exportExport variables. -
setShell options and positional parameters. -
unsetRemove variables and functions. -
shoptBash-specific options. -
declareVariable attributes. -
local and readonlyScoped and constant variables. -
readRead a line into variables. -
mapfileRead lines into an array. -
test, [ and [[Condition tests. -
true and falseCommands that succeed and fail. -
:The null command. -
evalEvaluate a string as code. -
trapRun code on signals and exit. -
getoptsParse command-line options. -
shiftShift positional parameters. -
return and exitLeave functions and scripts. -
command and builtinBypass functions and aliases. -
hashCommand lookup cache. -
letArithmetic evaluation with let. -
printf -vFormat into a variable. -
callerCall stack information.
Bash Syntax
-
VariablesAssignment, scope and naming. -
Special parameters$?, $$, $!, $@, $*, $#, $0. -
Common environment variablesPATH, HOME, IFS, PS1 and more. -
Bash's own variablesRANDOM, SECONDS, BASH_VERSION, LINENO. -
QuotingSingle, double and ANSI-C quotes. -
Parameter expansionDefaults, trimming and substitution. -
Substring and case expansionSlicing and changing case. -
Command substitution$(...) and backticks. -
Arithmetic expansion$(( )) and operators. -
Brace expansion{a,b} lists and {1..5} ranges. -
Tilde expansion~ and ~user. -
GlobbingWildcards and extglob. -
Word splittingIFS and unquoted expansions. -
Process substitution<(cmd) and >(cmd). -
Redirection>, >>, <, 2>&1 and file descriptors. -
Here-documents and here-strings<< and <<<. -
PipelinesPipes and pipefail. -
Command lists;, &&, || and &. -
if statementsConditional branches. -
Test operatorsFile, string and number tests. -
[[ ]] conditionsPattern and regex matching. -
case statementsPattern-based branching. -
for loopsList and C-style loops. -
while and until loopsCondition loops and reading lines. -
selectInteractive menus. -
break and continueLoop control. -
FunctionsDefinitions, arguments and return values. -
Indexed arraysCreating and slicing arrays. -
Associative arraysKey-value maps. -
NamerefsVariables that reference variables. -
Subshells and groupsParentheses versus braces. -
coprocCoprocesses. -
Regex matching in Bash=~ and BASH_REMATCH. -
Exit statusCodes and conventions. -
set -euo pipefailStrict mode and its caveats. -
The shebang lineChoosing the interpreter. -
Comments and documentationAnnotating scripts. -
Prompt stringsPS1 to PS4 and escapes. -
Readline shortcutsEditing the command line. -
History expansionBang commands such as !! and !$. -
Startup files.bashrc, .profile and login shells. -
Shell options referenceset -o and shopt flags.
Special Files and Directories
-
/etc/passwdUser account database. -
/etc/shadowPassword hashes. -
/etc/groupGroup database. -
/etc/sudoersSudo policy. -
/etc/hostsStatic host names. -
/etc/resolv.confDNS resolver settings. -
/etc/fstabStatic filesystem table. -
/etc/os-releaseDistribution identification. -
/etc/environment and profile.dSystem-wide environment. -
~/.ssh and sshd_configSSH client and server files. -
/etc/crontabSystem cron table. -
/proc/cpuinfoCPU details. -
/proc/meminfoMemory details. -
/proc/PIDPer-process information. -
/proc/loadavg and uptimeSystem load files. -
/proc/sysTunable kernel parameters. -
/sysKernel objects and devices. -
/dev/nullThe discard device. -
/dev/zero and /dev/urandomZero and random sources. -
/dev/stdin, stdout and stderrStandard stream files. -
/dev/ttyThe controlling terminal. -
/var/logSystem log files. -
/tmp and /var/tmpTemporary directories. -
/bootKernel and boot files. -
/usr, /opt and /usr/localSoftware locations. -
/runRuntime state. -
Home directory dotfilesPer-user configuration. -
/etc/motd and /etc/issueLogin messages.
Systemd and Logging (Read-Only)
-
systemctl statusInspecting service state. -
systemctl enable and disableStarting at boot. -
journalctl filtersUnit, priority and time filters. -
Unit, Service and Install sectionsAnatomy of a unit file. -
Restart policiesRestart=, RestartSec= and limits. -
Unit dependenciesRequires, Wants, After, Before. -
Timer unitsOnCalendar and OnBootSec. -
TargetsRunlevels in systemd. -
Service sandboxingProtectSystem and friends. -
syslog and rsyslogClassic logging. -
Log prioritiesSeverity levels 0 to 7. -
systemd-analyzeBoot time analysis.
Concepts
-
File descriptorsNumbers behind every open file. -
stdin, stdout and stderrThe three standard streams. -
Exit codes cheat sheetCommon statuses and signals. -
Signals tableSignal names, numbers and defaults. -
Permission bits explainedOctal, symbolic, setuid and sticky. -
Hard links vs symbolic linksWhen each one fits. -
InodesHow files are stored. -
Filesystem hierarchyWhat lives where. -
Order of expansionsHow Bash processes a line. -
Quoting pitfallsSpaces, globs and word splitting bugs. -
BRE, ERE and PCRERegular expression flavors. -
Globs vs regular expressionsTwo pattern languages. -
POSIX sh vs BashPortable scripting. -
Bash, dash, zsh and fishComparing shells. -
Login vs interactive shellsWhich files get read. -
Pipes and subshell variablesWhy variables vanish in a pipe. -
find vs locateChoosing a file search tool. -
grep vs sed vs awkChoosing a text tool. -
Safe scriptingInjection, temp files and quoting. -
Process statesRunning, sleeping, zombie. -
The boot processFirmware to login. -
Namespaces and cgroupsWhat containers are made of. -
The Unix philosophySmall tools that compose. -
Useful one-linersPractical recipes. -
Command cheat sheetCommon tasks at a glance.
Nothing matches โโ. Try the site search.