\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{myriamsouaya} \pdfinfo{ /Title (linux.pdf) /Creator (Cheatography) /Author (myriamsouaya) /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}{4854A3} \definecolor{LightBackground}{HTML}{F3F4F9} \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}{myriamsouaya} via \textcolor{DarkBackground}{\uline{cheatography.com/171877/cs/36113/}}} \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}myriamsouaya \\ \uline{cheatography.com/myriamsouaya} \\ \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 19th July, 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{3.28 cm} x{4.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Viewing Output}} \tn % Row 0 \SetRowColor{LightBackground} cat {\emph{\textless{}filename\textgreater{}}} & view contents of file \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} cat {\emph{\textless{}file\textgreater{}}} | sort & alphabetical output; does not change file \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} more {\emph{\textless{}filename\textgreater{}}} & view contents 1 screen at a time \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} less {\emph{\textless{}filename\textgreater{}}} & view contents, scroll up and down \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} & / allows for a keyword search \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} sort {\emph{\textless{}file\textgreater{}}} & sorts file; does not change file \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} sort -r {\emph{\textless{}file\textgreater{}}} & reverse sorts file; does not change file \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} sort {\emph{\textless{}file\textgreater{}}} \textgreater{} somefile.txt & creates somefile.txt of sorted content of \tn % Row Count 15 (+ 2) % Row 8 \SetRowColor{LightBackground} touch {\emph{\textless{}touch.txt\textgreater{}}} & creates new file \tn % Row Count 17 (+ 2) % Row 9 \SetRowColor{white} & updates access and modification times on a file \tn % Row Count 20 (+ 3) \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}{Searching for Files}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\{\{width=60\}\} \{\{bb\}\}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} find -name \textless{}{\emph{file}}\textgreater{} & search for files by filename \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} find \textless{}{\emph{dir path}}\textgreater{} -name \textless{}{\emph{file}}\textgreater{} & search with dir path \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} find \textless{}{\emph{dir path}}\textgreater{} -type d -name \textless{}{\emph{file}}\textgreater{} & narrow search for directory only \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} find \textless{}{\emph{dir path}}\textgreater{} -type f -name \textless{}{\emph{file}}\textgreater{} & narrow search for files only \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} find -user \textless{}{\emph{username}}\textgreater{} & search files by user \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} which \textless{}{\emph{command}}\textgreater{} & returns location of command based on PATH settings \tn % Row Count 14 (+ 3) % Row 7 \SetRowColor{white} whereis \textless{}{\emph{command}}\textgreater{} | tr " " '\textbackslash{}n' & returns location of binary, source files and man pages \tn % Row Count 17 (+ 3) % Row 8 \SetRowColor{LightBackground} type & returns info about command type \tn % Row Count 19 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{The format of the whereis command is designed to pipe the output to the translate command and format the output line by line, by changing spaces to newline characters} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.76 cm} x{4.24 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Tests and Actions with `find`}} \tn % Row 0 \SetRowColor{LightBackground} Tests: & Actions: \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} -nouser = file not owned by user & -print=default output \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} -name = file name, can use wildcards & -ls = output long style listing \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} & -exec = execute "cmd \{\} \textbackslash{};" \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} & -ok = same as exec, but prompts for permission \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{The syntax for using find this way is: \newline `find -options /path -tests -actions`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{File Transfer}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{scp {[}flag{]} \textless{}filename\textgreater{} \textless{}user@destination\_host:remote\_directory\textgreater{}} \tn % Row Count 2 (+ 2) \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}{Compression and Archive}} \tn % Row 0 \SetRowColor{LightBackground} tar & collects a series of files and directories into a single file \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} tar \textless{}options\textgreater{} \textless{}name of tar.tar\textgreater{} \textless{}path to dir being backed up\textgreater{} & create tar file \tn % Row Count 8 (+ 4) % Row 2 \SetRowColor{LightBackground} & options: \tn % Row Count 9 (+ 1) % Row 3 \SetRowColor{white} & c = create; v = verbose \tn % Row Count 11 (+ 2) % Row 4 \SetRowColor{LightBackground} & f = file; x = extract; z = zip \tn % Row Count 13 (+ 2) % Row 5 \SetRowColor{white} tar -tf \textless{}name of tar file\textgreater{} & view contents of zipped archive file \tn % Row Count 15 (+ 2) % Row 6 \SetRowColor{LightBackground} tar xvfz \textless{}name of file to extract\textgreater{} & restore archive files \tn % Row Count 17 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{To change the directory being extracted to add `-{}-directory=name\_of\_directory` to the end of the command; \newline Often need sudo permissions; \newline When zipping, name file with .tar.gz extension} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{3.268 cm} p{1.064 cm} p{3.268 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Chmod Octals}} \tn % Row 0 \SetRowColor{LightBackground} rwx & 7 & 111 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} rw- & 6 & 110 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} r-x & 5 & 101 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} r-{}- & 4 & 100 \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} -wx & 3 & 011 \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} -w- & 2 & 010 \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} -{}-x & 1 & 001 \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} -{}-{}- & 0 & 000 \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{8.4cm}}{The order of permissions in the chmod command is owner, group, others} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} x{7.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Input and Output redirection}} \tn % Row 0 \SetRowColor{LightBackground} \textgreater{} & create/overwrite file \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textgreater{}\textgreater{} & create/append to file \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \textless{} & direct file contents to a command or script \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} 2\textgreater{} & redirect error output to a file or location \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \&\textgreater{} & redirect stdout and stderr to a file or location \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{* /dev/null location is a "black hole" for sending things you don't need. When you inspect the directory you will find it empty \newline \newline It can be used for redirecting output that you don't want to see} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.28 cm} x{4.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Comparing Files}} \tn % Row 0 \SetRowColor{LightBackground} diff \textless{}file1\textgreater{} \textless{}file2\textgreater{} & outputs differences between 2 files \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} & context option: -c \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} diff \textless{}filepath1\textgreater{} \textless{}filepath2\textgreater{} & outputs differences between 2 directories \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} comm \textless{}file1\textgreater{} \textless{}file2\textgreater{} & compares 2 sorted files \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} cmp \textless{}file1\textgreater{} \textless{}file2\textgreater{} & compares files byte by byte \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} & returns position of 1st difference \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}