\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{amicheletti} \pdfinfo{ /Title (my-linux.pdf) /Creator (Cheatography) /Author (amicheletti) /Subject (My 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}{3C84A3} \definecolor{LightBackground}{HTML}{F2F7F9} \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{My Linux Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{amicheletti} via \textcolor{DarkBackground}{\uline{cheatography.com/39488/cs/12261/}}} \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}amicheletti \\ \uline{cheatography.com/amicheletti} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 11th July, 2017.\\ Updated 11th July, 2017.\\ 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}{p{0.8 cm} x{7.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Navigation}} \tn % Row 0 \SetRowColor{LightBackground} pwd & Print Working Directory, this shows the path you are currently working on \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} cd & Change Directory, it can be a relative or absolute path (. is the directory itself and .. is the parent directory) Quick shotcuts `cd` goes to your home directory `cd -` goes to the last working directory `cd \textasciitilde{}user\_name` goes to the home directory of that username \tn % Row Count 11 (+ 8) % Row 2 \SetRowColor{LightBackground} ls & List contents of the directory \tn % Row Count 12 (+ 1) % Row 3 \SetRowColor{white} file & Determine file type, extensions in Linux does not necessarily determine the purpose of the file. This command shows a brief description of the file's content. \tn % Row Count 17 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Important facts: \newline - Filenames and directory names are case sensitive \newline - Filenames starting with an period (.) are hidden \newline - Do not use special characters other than period, dash and underscore} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.88 cm} x{7.12 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{I/O Redirection}} \tn % Row 0 \SetRowColor{LightBackground} \#\#\#\#\# & Operators \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \textgreater{} & Output truncate redirect \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \textgreater{}\textgreater{} & Output append redirect \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} 2\textgreater{} & Error redirect \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} \#\#\#\#\# & Commands \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} cat & Concatenate \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} sort & Sort lines of text \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} grep & Print lines matching a pattern \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} head & Output the first specified part of a file \tn % Row Count 12 (+ 2) % Row 9 \SetRowColor{white} tail & Output the last specified part of a file \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Input, Output and errors are actually sent to special files called stdin, stdout and stderr. But by default, output and errors are linked to the screen and input is attached to the keyboard. \newline \newline We can redirect where output goes and where input comes from, and using that with pipelines, we can perform complex tasks.} \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}{Pipelines}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Operator: | \newline % Row Count 1 (+ 1) The difference of redirection and pipeline is that pipeline sends output as input for another command, while redirection does this to files.% Row Count 4 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.88 cm} x{7.12 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{General Commands}} \tn % Row 0 \SetRowColor{LightBackground} clear & Clears the terminal screen \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} date & Display current time and date \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} cal & Display a calendar of the current month \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} man & Manual for commands \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.88 cm} x{7.12 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Manipulating Files and Directories}} \tn % Row 0 \SetRowColor{LightBackground} cp & Copy files `-a` Copy all attributes of the original file `-i` Interactive mode (ask for confirmation), default is not ask `-r` Recursive copy (required when copying entire directories) `-u` Update, only overwrite if the copied files are newer \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} mv & Move or rename files (original file ceases to exist) \tn % Row Count 9 (+ 2) % Row 2 \SetRowColor{LightBackground} mkdir & Create directories \tn % Row Count 11 (+ 2) % Row 3 \SetRowColor{white} rm & Remove (delete) files and directories `-i` Prompt for confirmation, it does not ask for default `-r` Recursive remove files, required for directory `-f` Force, ignore nonexistent files and do not prompt \tn % Row Count 17 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{1.04 cm} x{6.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Important Directories}} \tn % Row 0 \SetRowColor{LightBackground} / & Root directory, everything begins here \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} /bin & contains programs for the system to boot and run (commands in bash are here too) \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} /dev & Devices mounted \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} /etc & System configuration files, and also shell scripts that run when the system boots. Important ones: `/etc/crontab` - definition for automated jobs `/etc/passwd` - list of user accounts \tn % Row Count 12 (+ 6) % Row 4 \SetRowColor{LightBackground} /home & Home directories for users \tn % Row Count 13 (+ 1) % Row 5 \SetRowColor{white} /lib & Shared libraries \tn % Row Count 14 (+ 1) % Row 6 \SetRowColor{LightBackground} \seqsplit{/media} & Removable media mount points \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} /root & The home directory for the root user \tn % Row Count 18 (+ 2) % Row 8 \SetRowColor{LightBackground} /tmp & Temporary files \tn % Row Count 19 (+ 1) % Row 9 \SetRowColor{white} /usr & Large directory tree, contains all the program files for regular users \tn % Row Count 22 (+ 3) % Row 10 \SetRowColor{LightBackground} /var & Directory for data that changes frequently \tn % Row Count 24 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}