\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{Yule} \pdfinfo{ /Title (linux-basic-commands.pdf) /Creator (Cheatography) /Author (Yule) /Subject (Linux Basic Commands 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}{5CB8FF} \definecolor{LightBackground}{HTML}{EAF6FF} \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 Basic Commands Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Yule} via \textcolor{DarkBackground}{\uline{cheatography.com/206656/cs/44193/}}} \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}Yule \\ \uline{cheatography.com/yule} \\ \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 22nd August, 2024.\\ 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{tabularx}{17.67cm}{x{5.0083 cm} x{12.2617 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Keyboard Shortcuts}} \tn % Row 0 \SetRowColor{LightBackground} Ctrl + A & Sets cursor at beginning of a command \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Ctrl + C & Kill process running in the terminal \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Ctrl + E & Sets cursor at end of a command \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Ctrl + K & Cut part of the line after the cursor and add to clipboard \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} Ctrl + U & Cut part of the line before the cursor and add to clipboard \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} Ctrl + W & Cut one word before the cursor and add to clipboard \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} Ctrl + Y & Paste from clipboard \tn % Row Count 15 (+ 1) % Row 7 \SetRowColor{white} Ctrl + Z & Stop the current process. Can be resumed in Foreground {[}fg{]} or Background {[}bg{]} \tn % Row Count 18 (+ 3) % Row 8 \SetRowColor{LightBackground} echo \textgreater{} OR \textgreater{}\textgreater{} & \textgreater{} overwrites existing file \textgreater{}\textgreater{} adds your content to the end (echo "time" \textgreater{} permissions.txt) \tn % Row Count 22 (+ 4) % Row 9 \SetRowColor{white} | & 'Piping' commands together \tn % Row Count 24 (+ 2) % Row 10 \SetRowColor{LightBackground} !! & Run the last command again \tn % Row Count 25 (+ 1) % Row 11 \SetRowColor{white} Tab & Provides available suggestions for completing your text \tn % Row Count 27 (+ 2) % Row 12 \SetRowColor{LightBackground} clear & Clears the terminal screen \tn % Row Count 28 (+ 1) % Row 13 \SetRowColor{white} exit & Log out of current session \tn % Row Count 29 (+ 1) % Row 14 \SetRowColor{LightBackground} nano {[}file\_name{]} & Open or create a file using the nano text editor \tn % Row Count 31 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.1169 cm} x{9.1531 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Files}} \tn % Row 0 \SetRowColor{LightBackground} touch {[}file\_name{]} & Creates a new file {\emph{(touch {[}directory\_name{]})}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} rm {[}file\_name{]} & Removes a file \tn % Row Count 4 (+ 1) % Row 2 \SetRowColor{LightBackground} mkdir {[}diectory\_name{]} & Create a new directory \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} rmdir {[}directory\_name{]} & Removes a directory \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} cat {[}file\_name{]} & Show the contents of a file \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} head {[}file\_name{]} & Show the first ten lines of a file {\emph{(-n {[}\#{]} specify how many lines to return)}} \tn % Row Count 14 (+ 4) % Row 6 \SetRowColor{LightBackground} tail {[}file\_name{]} & Show the last ten lines of a file {\emph{(-n {[}\#{]} specify how many lines to return)}} \tn % Row Count 18 (+ 4) % Row 7 \SetRowColor{white} more {[}file\_name{]} & Display contents of a file page by page \tn % Row Count 20 (+ 2) % Row 8 \SetRowColor{LightBackground} less {[}file\_name{]} & Show the contents of a file with navigation \tn % Row Count 23 (+ 3) % Row 9 \SetRowColor{white} mv {[}source\_file{]} {[}destination\_file{]} & Move or rename files or directories {\emph{(rename using 2nd argument)}} \tn % Row Count 27 (+ 4) % Row 10 \SetRowColor{LightBackground} cp {[}source\_file{]} {[}destination\_file{]} & Copies a file or directory to a new location \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.1169 cm} x{9.1531 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Files (cont)}} \tn % Row 11 \SetRowColor{LightBackground} chmod {[}u/g/o +/- r/w/x{]} {[}file\_name{]} & Changes permissions on files and directories \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Searching}} \tn % Row 0 \SetRowColor{LightBackground} man & Manual. Displays info on other commands \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} apropos & Searches the manual {\emph{(use -a to refine)}} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} whatis & Displays a description of a command on a single line \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} whoami & See which user you are using \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} find {[}path{]} & Find files and directories \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} find {[}directory\_name{]} -name {[}"{\emph{search\_pattern}}"{]} & case-sensitive {\emph{(* wildcard for zero or more unknown characters)}} \tn % Row Count 15 (+ 4) % Row 6 \SetRowColor{LightBackground} find {[}directory\_name{]} -iname {[}"{\emph{search\_pattern}}"{]} & NOT case-sesitive {\emph{(* wildcard for zero or more unknown characters)}} \tn % Row Count 19 (+ 4) % Row 7 \SetRowColor{white} grep {[}search\_pattern{]} {[}file\_name{]} & Search for a specific pattern in a file \tn % Row Count 21 (+ 2) % Row 8 \SetRowColor{LightBackground} grep -r {[}search\_pattern{]} {[}directory\_name{]} & Recursively search for a pattern in a directory \tn % Row Count 24 (+ 3) % Row 9 \SetRowColor{white} -mtime & Directories last modified within a certain time frame using days {[}+1 or -1{]} \tn % Row Count 28 (+ 4) % Row 10 \SetRowColor{LightBackground} -mmin & Directories last modified within a certain time frame using minutes {[}+60 or -60{]} \tn % Row Count 32 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{Note: An asterisk (*) is used as a wildcard to represent zero or more unknown characters. \newline Note: grep needs {[}"quotes"{]} to search for more than one word} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.3537 cm} x{11.9163 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Directory Navigation}} \tn % Row 0 \SetRowColor{LightBackground} pwd & Show the directory you are currently working in \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cd {[}diectory\_name{]} & Navigates to that directory \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} cd .. & Move up one directory level \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} cd - & Change to the previous directory \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} ls & List files and directories in the current directory \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} ls {[}diectory\_name{]} & List files and directories in specific location \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} ls -l & List files and directories in long format {\emph{(can combine -la)}} \tn % Row Count 14 (+ 3) % Row 7 \SetRowColor{white} ls -a & Shows hidden files {\emph{(can combine -la)}} \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.0083 cm} x{12.2617 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Navigating in less}} \tn % Row 0 \SetRowColor{LightBackground} less {[}file\_name{]} & Show the contents of a file with navigation \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Up/Down arrow & Move up/down one line \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Left/Right arrow & Move left/right half of page \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Page Up/Down & Move up/down one page \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} g & Go to the first line \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} G & Go to the last line \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} F & Go to the last line, and display any new lines {\emph{{[}similar to tail -F{]} {[}Ctrl+C to exit{]}}} \tn % Row Count 14 (+ 4) % Row 7 \SetRowColor{white} b & Move back one page \tn % Row Count 15 (+ 1) % Row 8 \SetRowColor{LightBackground} n & Repeat a previous search \tn % Row Count 16 (+ 1) % Row 9 \SetRowColor{white} N & Repeat a previous search, but in the opposite direction \tn % Row Count 18 (+ 2) % Row 10 \SetRowColor{LightBackground} q & Quit \tn % Row Count 19 (+ 1) % Row 11 \SetRowColor{white} ?malware & Search -go to the previous line containing the word 'malware' \tn % Row Count 22 (+ 3) % Row 12 \SetRowColor{LightBackground} /!malware & Search -go to the next line NOT containing the word 'malware' \tn % Row Count 25 (+ 3) % Row 13 \SetRowColor{white} /malware & Search -go to the next line containing the word 'malware' \tn % Row Count 28 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Users and Groups}} \tn % Row 0 \SetRowColor{LightBackground} sudo useradd {[}user\_name{]} & Create new user account \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} sudo userdel {[}user\_name{]} & Deletes a user account \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} sudo groupdel {[}user\_name{]} & Deletes a group \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} sudo chown {[}user\_name{]} {[}file\_name{]} & Changes ownership of a file or directory {\emph{(use : to designate a group)}} \tn % Row Count 10 (+ 4) % Row 4 \SetRowColor{LightBackground} sudo usermod {[}prefix{]} {[}group\_name{]} {[}user\_name{]} & Changes existing user accounts \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} -g OR -G & Adds a user to a primary OR secondary group. {\emph{(sudo useradd -g security username)}} \tn % Row Count 18 (+ 5) % Row 6 \SetRowColor{LightBackground} -a & Appends the user to an existing group {\emph{(sudo usermod -a -G marketing username)}} \tn % Row Count 22 (+ 4) % Row 7 \SetRowColor{white} -d & Changes user's home directory {\emph{(sudo usermod -d /home/name\_user username)}} \tn % Row Count 26 (+ 4) % Row 8 \SetRowColor{LightBackground} -l & Changes user's login name \tn % Row Count 28 (+ 2) % Row 9 \SetRowColor{white} -L & Locks the account from user \tn % Row Count 30 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \end{document}