\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Hezart} \pdfinfo{ /Title (linux.pdf) /Creator (Cheatography) /Author (Hezart) /Subject (Linux Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{1482A3} \definecolor{LightBackground}{HTML}{F0F7F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Linux Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Hezart} via \textcolor{DarkBackground}{\uline{cheatography.com/214134/cs/46649/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Hezart \\ \uline{cheatography.com/hezart} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 25th June, 2025.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{p{0.59501 cm} x{1.78503 cm} x{2.19696 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Commonly Used}} \tn % Row 0 \SetRowColor{LightBackground} man & Information about a & -f: summary -k : search for words \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cp & copy a to b & -R: recursive -p: keep permissions \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} mv & moves x to y & -f: force -b: create copy also \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} mkdir & makes directory & -p: also path to it -m: permissions \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} rm & removes file or folder & -r: recursive, -i: warns about each file \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} cd & -P:physical -L:logical & cd -: previous cd \textasciitilde{}: to home \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} df & file information & -h: human readible -i: metadata \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} ps & information on process & -a: all in terminal, -T: threads etc. \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} uniq & removes non-unique lines & eg: a.txt | unique | less \tn % Row Count 19 (+ 2) % Row 9 \SetRowColor{white} head / tail & displays first/last part of file & \tn % Row Count 22 (+ 3) % Row 10 \SetRowColor{LightBackground} wc & information on text in file & -c: bytes, -w: words -l: lines \tn % Row Count 24 (+ 2) % Row 11 \SetRowColor{white} echo & repeat & -n: no linebreak, -e: interpet special chars \tn % Row Count 27 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Pipes \& Output}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Pipe}} \newline % Row Count 1 (+ 1) {\bf{cmd1 | cmd2}} = Send stdout of cmd1 to cmd2 \newline % Row Count 2 (+ 1) {\bf{Redirecting Output}} \newline % Row Count 3 (+ 1) {\emph{Symbol}} {\emph{Description}} \newline % Row Count 4 (+ 1) {\bf{\textgreater{}}} Redirect stdout (overwrite) \newline % Row Count 5 (+ 1) {\bf{\textgreater{}\textgreater{}}} Redirect stdout (append) \newline % Row Count 6 (+ 1) {\bf{2\textgreater{}}} Redirect stderr \newline % Row Count 7 (+ 1) {\bf{2\textgreater{}\textgreater{}}} Append stderr \newline % Row Count 8 (+ 1) {\bf{\&\textgreater{}}} Redirect both stdout and stderr \newline % Row Count 9 (+ 1) {\bf{2\textgreater{}\&1}} Redirect stderr to stdout \newline % Row Count 10 (+ 1) {\bf{Special File Descriptors}} \newline % Row Count 11 (+ 1) {\emph{FD Description}} \newline % Row Count 12 (+ 1) 0 stdin \newline % Row Count 13 (+ 1) 1 stdout \newline % Row Count 14 (+ 1) 2 stderr% Row Count 15 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.50347 cm} x{2.05965 cm} x{2.01388 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Diverse}} \tn % Row 0 \SetRowColor{LightBackground} uname & System/kernel info & -a: all info, -r: kernel version \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{uptime} & How long system been up & \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} top / htop & system monitor & \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{ifconfig} & network interfaces & (older version) \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} ip & replaces ifconfig & ip a: addresses, ip r: routes \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{netstat} & Show open ports and connections & \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} curl & Fetch data from URLs & \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} wget & Download files & \tn % Row Count 16 (+ 1) % Row 8 \SetRowColor{LightBackground} du & Disk usage & du -h: human-readable sizes, du -sh * for summary \tn % Row Count 19 (+ 3) % Row 9 \SetRowColor{white} kill & Terminate by PID & \tn % Row Count 20 (+ 1) % Row 10 \SetRowColor{LightBackground} \seqsplit{killall} & Kill processes by name & e.g. killall firefox \tn % Row Count 22 (+ 2) % Row 11 \SetRowColor{white} tee & Output to screen and file simultaneously & \tn % Row Count 25 (+ 3) % Row 12 \SetRowColor{LightBackground} diff & Compare files line-by-line & \tn % Row Count 27 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Grep}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{grep str file}}% Row Count 1 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{grep johan /etc/passwd}} \newline {\emph{-i}}: case insensitive \newline {\emph{-v}}: show non-matching lines \newline {\emph{-q}}: silent, can be passed with \$? \newline {\emph{-r}}: search recursively in folder \newline {\emph{-w}}: search for complete word (not substr) \newline {\emph{-E}}: search for two terms: grep -E "average|mean" file.txt} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Find}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{find {[}options{]} {[}path...{]} {[}expression{]}}} \newline % Row Count 1 (+ 1) {\emph{find -L /var/www -name "}}.js"* \newline % Row Count 2 (+ 1) {\emph{-L :}} Follow symbolic links \newline % Row Count 3 (+ 1) {\emph{-type f :}} search for file or {[}f: file, d:dir, l:symbolic link...{]} \newline % Row Count 5 (+ 2) {\emph{-name \textless{}name\textgreater{}:}} name of file to search for \newline % Row Count 6 (+ 1) {\emph{-iname \textless{}name\textgreater{}:}} name of file to search for (case-insensitive)% Row Count 8 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Tar \& gz}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{tar {[}options{]} {[}archive-file{]} {[}file(s)/dir(s)...{]}}} \newline % Row Count 2 (+ 2) eg: {\emph{tar -cvf archive.tar file1 file2}} \newline % Row Count 3 (+ 1) eg: {\emph{tar -xvf archive.tar }} \newline % Row Count 4 (+ 1) {\emph{-c :}} Create a new archive \newline % Row Count 5 (+ 1) {\emph{-x :}} Extract files from an archive \newline % Row Count 6 (+ 1) {\emph{-v :}} Verbose output (list files being processed) \newline % Row Count 8 (+ 2) {\emph{-f \textless{}file\textgreater{}:}} Use archive \textless{}file\textgreater{} name \newline % Row Count 9 (+ 1) {\emph{-z :}} Use gzip compression (for .tar.gz or .tgz) \newline % Row Count 11 (+ 2) {\bf{Gzip Compression (.gz)}} \newline % Row Count 12 (+ 1) {\emph{gzip file.txt}} Compress file.txt → file.txt.gz \newline % Row Count 13 (+ 1) {\emph{gzip -k file.txt}} Compress but keep original file \newline % Row Count 15 (+ 2) {\emph{gzip -r folder/}} Recursively compress all files in folder \newline % Row Count 17 (+ 2) {\emph{gunzip file.txt.gz Decompress .gz back to original file}}% Row Count 19 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{File Permissions}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\emph{ Permissions are defined for 3 groups:{[} User {]} {[} Group {]} {[} Others {]}}} \newline % Row Count 2 (+ 2) {\bf{r = read (4)}} \newline % Row Count 3 (+ 1) {\bf{w = write (2)}} \newline % Row Count 4 (+ 1) {\bf{x = execute (1)}} \newline % Row Count 5 (+ 1) {\bf{- = no permission (0)}} \newline % Row Count 6 (+ 1) Order: rwx \newline % Row Count 7 (+ 1) {\emph{To set permission: {\bf{chmod {[}u{]}{[}g{]}{[}o{]}}} (eg: chmod 740 \textless{}file\textgreater{} / chmod rwxr-{}-{}-{}-- \textless{}file\textgreater{})}}% Row Count 9 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{xargs}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{xargs – Turn Input Into Arguments}} \newline % Row Count 1 (+ 1) {\emph{Example Command}} {\emph{Description}} \newline % Row Count 2 (+ 1) find . -name "*.log" | xargs rm Delete all .log files \newline % Row Count 4 (+ 2) echo "file1 file2" | xargs ls -l Run ls -l on each file \newline % Row Count 6 (+ 2) cat list.txt | xargs -n 1 echo Print each line as argument separately \newline % Row Count 8 (+ 2) find . -name "*.jpg" | xargs -I\{\} mv \{\} images/ Move files with placeholders% Row Count 10 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}