\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{hapuchu} \pdfinfo{ /Title (devops.pdf) /Creator (Cheatography) /Author (hapuchu) /Subject (DevOps 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}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \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{DevOps Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{hapuchu} via \textcolor{DarkBackground}{\uline{cheatography.com/164363/cs/34441/}}} \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}hapuchu \\ \uline{cheatography.com/hapuchu} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 1st October, 2022.\\ Updated 16th January, 2023.\\ 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*}{2} \begin{tabularx}{8.4cm}{x{4.4 cm} x{3.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{grep}} \tn % Row 0 \SetRowColor{LightBackground} grep -r pattern & find in files \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} grep -i pattern & ignore case \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} grep -o pattern & print file:match \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} grep -h pattern & hide filename \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} grep -e pattern -e str2 & multiples strings \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} grep -v pattern & complimenting line \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} grep -c pattern & print count \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} grep -n pattern & print \# of matches \tn % Row Count 9 (+ 1) % Row 8 \SetRowColor{LightBackground} grep -w pattern & match whole pattern \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.8 cm} x{3.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{find}} \tn % Row 0 \SetRowColor{LightBackground} find path -type f -name file & search only filenames \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} find path -type d -name dir & search only dir names \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} find path -mtime +7 -ls & older than 7 days \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} find path -size -10M -ls & less than 10 MB G/K \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} find path -exec grep -i str \{\} + & find in files \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.48 cm} x{3.52 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{du}} \tn % Row 0 \SetRowColor{LightBackground} du -a dir & all files \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} du -h dir & human \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} du -m dir & in mb \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} du -c dir & sum \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} du -s dir & only sum \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} du -{}-max-depth=1 dir & 1 dir level deep \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{loops}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{seq 5 | xargs -I\{\} cmd} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{for i in \{1..5\};\{\{nl\}\}do\{\{nl\}\}~~~~date;\{\{nl\}\}done} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{for vm in web log db;\{\{nl\}\}do\{\{nl\}\}~~~~uptime;\{\{nl\}\}done} \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.24 cm} x{3.76 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{archives and zips}} \tn % Row 0 \SetRowColor{LightBackground} tar cvf f.tar f1 f2 f3 ... & create tar \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} tar xvf f.tar & extract tar \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} tar tvf f.tar & view tar \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} gzip -d filename.gz & extract gzip file \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} zip -r dir-name.zip \textless{}dir\textgreater{} & zip a dir \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} zip -d f.zip fname & delete file from zip \tn % Row Count 9 (+ 2) % Row 6 \SetRowColor{LightBackground} unzip -p zipfile.zip fname.txt & cat a file inside a zip file \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.56 cm} x{3.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{sed}} \tn % Row 0 \SetRowColor{LightBackground} sed -i'.bak' 's/old/new/g' & replace after backup \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} sed 's/ab/xy/g;s/de/pq/g' & multiple replaces \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} sed '10,20 s/abc/xyz/g' & replace in range \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.4 cm} x{3.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{awk}} \tn % Row 0 \SetRowColor{LightBackground} awk -F',' '\{print \$1"@"\$3\}' & print col1@col3 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} awk -F'\textbackslash{}t' '/str/ \{print \$0\}' & print line with str \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} awk -F: '\{print \$(NF-1)\}' & print II col from right \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} awk -F'(,|:|;)' '\{print \}' & multiple separators \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} awk '\$1 == 100 \{print\}' & comparison \textless{}, \textgreater{}, \textless{}=, \textgreater{}= \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} awk 'END \{print NR " \& " NF\}' & print \# of rows and cols \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{awk 'BEGIN \{action\} /pattern/ END \{action\}'} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.4 cm} x{5.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{stdin stdout}} \tn % Row 0 \SetRowColor{LightBackground} cmd 1\textgreater{}f.out & stdout to f.out \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} cmd 1\textgreater{}f.out & stderr to f.out \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} cmd \&\textgreater{}f.out & stdout and stderr to f.out \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{sort}} \tn % Row 0 \SetRowColor{LightBackground} sort -n & numeric \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} sort -r & reverse \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.12 cm} x{4.88 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{uniq}} \tn % Row 0 \SetRowColor{LightBackground} uniq -c & print count \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} uniq -d & only dups \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} uniq -u & only unique \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} uniq -i & ignore case \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\{\{ac\}\}ideally uniq should be used after sort} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{cut}} \tn % Row 0 \SetRowColor{LightBackground} cut -d ',' -f 1,3,5 & print csv cols 1, 3 and 5 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cut -d: -f 1 -{}-compliment & print all cols except 1 \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} cut -f -3 & print cols 1, 2 and 3 \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} cut -f 3- & print cols 3, 4 ... \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.84 cm} x{6.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{tr}} \tn % Row 0 \SetRowColor{LightBackground} tr old new & replace old with new \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} tr -s ' ' & replace multiple space with single \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\{\{ac\}\}typical use: cat something | tr old new} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.4 cm} x{3.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{curl}} \tn % Row 0 \SetRowColor{LightBackground} curl -o file url & save to file \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} curi -I url & only header \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} curl -k https://url & ignore cert \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} curl -u \textless{}usr:pwd\textgreater{} url & username password \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} curl -w & add timeout \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.92 cm} x{4.08 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{misc 1}} \tn % Row 0 \SetRowColor{LightBackground} top & cpu mem info \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} free -m & mem status \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} lsof & open files \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} netstat & nw traffic \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} dig servername & dns \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} nslookup servername & dns \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} time cmd & exe time \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} watch cmd & auto exe \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} zip -d f.zip fname & delete file from zip \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} umount -l mnt & unmount when free \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} mount -a & mount all \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} ln -s file link & create symlink \tn % Row Count 12 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{misc 2}} \tn % Row 0 \SetRowColor{LightBackground} | xargs cmd & throws what pipe gave after cmd \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ps -ef & list processes \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} nc -l 1234 & listen on 1234 \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} nc 127.0.0.1 1234 & send data to 1234 \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} cp -p old new & cp permissions also \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}