\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{skittleys} \pdfinfo{ /Title (linux-command-line.pdf) /Creator (Cheatography) /Author (skittleys) /Subject (Linux Command Line 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}{A33179} \definecolor{LightBackground}{HTML}{F9F2F6} \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 Command Line Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{skittleys} via \textcolor{DarkBackground}{\uline{cheatography.com/19023/cs/2083/}}} \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}skittleys \\ \uline{cheatography.com/skittleys} \\ \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 13th May, 2016.\\ 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.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{grep {[}OPTION{]}... PATTERN {[}FILE{]}...}} \tn % Row 0 \SetRowColor{LightBackground} -i & case insensitive \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} -n & line numbers \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} -r & recursive \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} -L & only list files that don't match \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\emph{ can put multiple file names \newline }} PATTERN is a basic regex by default \newline * egrep for extended regex} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{PyTyle3}} \tn % Row 0 \SetRowColor{LightBackground} Ctrl-Alt-v & tile \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Ctrl-Alt-BkSp & untile \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Ctrl-Alt-s & ⇩ master window space \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} Ctrl-Alt-r & ⇧ master window space \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} Ctrl-Alt-g & close master \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} Ctrl-Alt-d & add new master \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} Ctrl-Alt-c & rotate windows clockwise \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} Ctrl-Alt-f & float \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} Ctrl-Alt-q & quit \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.39356 cm} x{3.58344 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{terminator}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Ctrl+Shift+O} & Split horizontally \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{Ctrl+Shift+F} & Split vertically \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{Ctrl+Shift+F} & search \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{(Shift+)Win+R} & rotate windows (counter)clockwise \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{Alt+(arrow)} & Move terminal focus ... \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.09848 cm} x{2.83774 cm} p{0.64078 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{find {[}-HLP{]} {[}path...{]} {[}expression{]}}} \tn % Row 0 \SetRowColor{LightBackground} -P & never follow symlinks & \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} -L & follow symlinks & \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{{[}expression{]}} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} * options & -maxdepth \# & \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} & -mindepth \# & \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} * tests & (+n,-n,n) & \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} & -atime n & n*24h \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} & -amin n & \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} & -executable & \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} & -group {\emph{name}} & or ID \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} & -size n{[}cwbkMG{]} & \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} & -type {[}bc{\bf{d}}p{\bf{f}}ls{]} & \tn % Row Count 12 (+ 1) % Row 12 \SetRowColor{LightBackground} & -user {\emph{name}} & or ID \tn % Row Count 13 (+ 1) % Row 13 \SetRowColor{white} & -writable & \tn % Row Count 14 (+ 1) % Row 14 \SetRowColor{LightBackground} * actions & -delete & \tn % Row Count 15 (+ 1) % Row 15 \SetRowColor{white} & -exec {\emph{cmd}} & \tn % Row Count 16 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{* path can be specific or {\bf{.}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Referencing previous commands}} \tn % Row 0 \SetRowColor{LightBackground} \$? & exit status of last command \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\$0} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \$\# & \# args passed to current script/ function \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \$* & list of args passed, as a space-separated string \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \$@ & list of args passed, as a delimited list \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} \$\_ & most recent arg \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} \$! & PID of last bg command \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} \$\$ & pid of current shell \tn % Row Count 11 (+ 1) % Row 8 \SetRowColor{LightBackground} \$- & option flags used \tn % Row Count 12 (+ 1) % Row 9 \SetRowColor{white} \${\emph{n}} & reference to arg {\emph{n}} in last command \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.54287 cm} x{3.43413 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Bash History: "Event Designators"}} \tn % Row 0 \SetRowColor{LightBackground} !{\emph{n}} & Repeat {\emph{n}}\textasciicircum{}th\textasciicircum{} command \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} !-{\emph{n}} & Repeat command {\emph{n}} lines back \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} !! & Last command; synonymous w/ !-1 \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} !{\emph{string}} & Most recent command starting with {\emph{string}} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} !?{\emph{string}}? & Most recent command containing {\emph{string}} \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} \textasciicircum{}{\emph{str1}}\textasciicircum{}{\emph{str2}}\textasciicircum{} & repeat last command, replacing {\emph{str1}} w/ {\emph{str2}} \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} !!:s/{\emph{str1}}/{\emph{str2}} & synonymous with the above \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} !\$ & last arg of last cmd; synonymous w/ !!:\$ \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{History "Word Designators"}} \tn % Row 0 \SetRowColor{LightBackground} \$ & last argument \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 0 \seqsplit{(zero)} & 0\textasciicircum{}th\textasciicircum{} argument, usually the cmd word \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} {\emph{n}} & the {\emph{n\textasciicircum{}th\textasciicircum{}}} word ({\emph{n}}-1 arg) \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \textasciicircum{} & 1st argument (word 1) \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} \% & word matched by most recent ?{\emph{str}}? search \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} * & all words except the 0\textasciicircum{}th\textasciicircum{} (i.e., all args) \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Word designator is separated from event by a colon ':' unless it is \textasciicircum{},\$,{\emph{,-,\%. \newline For example, !!:\$ becomes !\$. \newline Words are counted from 0, so the command itself is 0. \newline Words can be used with events. For example, !}}foo{\emph{:3 finds the last command starting with }}foo*, then takes the 3rd word (2nd argument).} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{History: Modifiers}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{[}g{]}s/{\emph{str1}}/{\emph{str2}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \& & repeat prev substitution \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} p & prints resulting command but doesn't execute it \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} e & removes all but trailing suffix (e.g., .txt) \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} r & removes trailing suffix, keeps basename \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} h & removes "trailing" last dir in pathname, keeping "head" (path to that directory's directory) \tn % Row Count 11 (+ 3) % Row 6 \SetRowColor{LightBackground} t & removes all dirs in path except the last one ("tail") \tn % Row Count 13 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Used after the event and word designators. \newline Gets very complex. \newline I'm only showing the sed-like ones here.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.14471 cm} x{3.83229 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{pacman}} \tn % Row 0 \SetRowColor{LightBackground} -S {\emph{pkg}} & install \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} -Su & upgrade all out-of-date pkgs (prompts for confirmation 1st) \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} -Sy & refresh pkg list \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} -Ql {\emph{pkg}} & list all files owned by pkg \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} -Qs \textless{}regex\textgreater{} & search for package (local) \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} -Ss \textless{}regex\textgreater{} & search repo \tn % Row Count 9 (+ 2) % Row 6 \SetRowColor{LightBackground} -Qi {\emph{pkg}} & pkg info (local) \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} -Si {\emph{pkg}} & pkg info (repo) \tn % Row Count 11 (+ 1) % Row 8 \SetRowColor{LightBackground} -R {\emph{pkg}} & remove pkg \tn % Row Count 12 (+ 1) % Row 9 \SetRowColor{white} -Rn {\emph{pkg}} & don't back up configs \tn % Row Count 13 (+ 1) % Row 10 \SetRowColor{LightBackground} -Qm & list all pkgs not found in DB (manually installed) \tn % Row Count 15 (+ 2) % Row 11 \SetRowColor{white} -T & check all dependencies \tn % Row Count 16 (+ 1) % Row 12 \SetRowColor{LightBackground} -Qc {\emph{pkg}} & view changelog \tn % Row Count 17 (+ 1) % Row 13 \SetRowColor{white} -Qd & packages installed as dependencies \tn % Row Count 19 (+ 2) % Row 14 \SetRowColor{LightBackground} -Qtd & orphan packages \tn % Row Count 20 (+ 1) % Row 15 \SetRowColor{white} -Qu & view all out-of-date pkgs \tn % Row Count 21 (+ 1) % Row 16 \SetRowColor{LightBackground} -Sii {\emph{pkg}} & info re: {\emph{pkg}} \& what other pkgs depend on it \tn % Row Count 23 (+ 2) % Row 17 \SetRowColor{white} -Sl {[}{\emph{repo}}{]} & list all pkgs in specified repo \tn % Row Count 25 (+ 2) % Row 18 \SetRowColor{LightBackground} -Suu & downgrade pkgs to version in repo (i.e., if installed from testing repo, downgrade to stable) \tn % Row Count 29 (+ 4) % Row 19 \SetRowColor{white} -Sw {\emph{pkg}} & download but don't install \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.14471 cm} x{3.83229 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{pacman (cont)}} \tn % Row 20 \SetRowColor{LightBackground} -Syy & force refresh \tn % Row Count 1 (+ 1) % Row 21 \SetRowColor{white} -Syu & update + upgrade \tn % Row Count 2 (+ 1) % Row 22 \SetRowColor{LightBackground} -Syu {\emph{pkg}} & update + upgrade all, then install {\emph{pkg}} if still not there \tn % Row Count 4 (+ 2) % Row 23 \SetRowColor{white} -U /path/ & install from local file (will get dependencies from repo) \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}