\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{Kyngo (Kyngo)} \pdfinfo{ /Title (command-line-and-terminal-navigation.pdf) /Creator (Cheatography) /Author (Kyngo (Kyngo)) /Subject (Command Line and Terminal navigation 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}{569054} \definecolor{LightBackground}{HTML}{F4F8F4} \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{Command Line and Terminal navigation Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Kyngo (Kyngo)} via \textcolor{DarkBackground}{\uline{cheatography.com/131267/cs/26366/}}} \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}Kyngo (Kyngo) \\ \uline{cheatography.com/kyngo} \\ \uline{\seqsplit{arnaumart}.in} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 29th January, 2021.\\ Updated 14th January, 2022.\\ 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}{x{2.09034 cm} x{2.88666 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Basics}} \tn % Row 0 \SetRowColor{LightBackground} cd {[}path{]} & change your current directory to the specified one \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} cd \textasciitilde{} & go to your home folder \tn % Row Count 4 (+ 1) % Row 2 \SetRowColor{LightBackground} cd - & go the the folder you were before \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} ls & list the contents of the directory \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} ls -lh & list the contents of the directory in a human-friendly format \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} cp {[}origin{]} {[}destination{]} & copies the given file wherever you want to \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} mv {[}origin{]} {[}destination{]} & moves or renames the given file \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} pwd & get the current directory you're in \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} mkdir {[}name{]} & create a folder \tn % Row Count 18 (+ 1) % Row 9 \SetRowColor{white} mkdir -p {[}name{]} & create a folder and all its parents, if needed \tn % Row Count 20 (+ 2) % Row 10 \SetRowColor{LightBackground} chmod 755 {[}name{]} & change a file's permissions - Allows the user to read, write and execute, and anyone else to just read and execute \tn % Row Count 25 (+ 5) % Row 11 \SetRowColor{white} chmod 400 {[}name{]} & change a file's permissions - Only the owner will be able to read the file \tn % Row Count 29 (+ 4) % Row 12 \SetRowColor{LightBackground} chown user:group {[}name{]} & changes the owners of a given file or folder \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.09034 cm} x{2.88666 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Basics (cont)}} \tn % Row 13 \SetRowColor{LightBackground} chown -R user:group {[}name{]} & changes the owners of a given file or folder, and all of its contents \tn % Row Count 3 (+ 3) % Row 14 \SetRowColor{white} touch {[}name{]} & creates a file with the given name \tn % Row Count 5 (+ 2) % Row 15 \SetRowColor{LightBackground} file {[}name{]} & reports the file type \tn % Row Count 6 (+ 1) % Row 16 \SetRowColor{white} rm {[}file{]} & removes a file \tn % Row Count 7 (+ 1) % Row 17 \SetRowColor{LightBackground} rm -rf {[}file{]} & removes a folder and all of its contents \tn % Row Count 9 (+ 2) % Row 18 \SetRowColor{white} cat {[}file{]} & prints a file's contents \tn % Row Count 11 (+ 2) % Row 19 \SetRowColor{LightBackground} tac {[}file{]} & prints a file's contents from bottom to top \tn % Row Count 13 (+ 2) % Row 20 \SetRowColor{white} sed & allows replacing of contents in files with regular expressions \tn % Row Count 16 (+ 3) % Row 21 \SetRowColor{LightBackground} grep {[}pattern{]} {[}file{]} & prints the contents of a given file that match the given pattern \tn % Row Count 19 (+ 3) % Row 22 \SetRowColor{white} tr -s {[}pattern{]} & replaces all concurrent duplicates of a given pattern \tn % Row Count 22 (+ 3) % Row 23 \SetRowColor{LightBackground} tr {[}pattern{]} {[}replacement{]} & replaces the given pattern with the given replacement string \tn % Row Count 25 (+ 3) % Row 24 \SetRowColor{white} tr -d {[}pattern{]} & removes the given pattern from a string \tn % Row Count 27 (+ 2) % Row 25 \SetRowColor{LightBackground} head {[}file{]} & prints the first lines of a given file \tn % Row Count 29 (+ 2) % Row 26 \SetRowColor{white} tail {[}file{]} & prints the last lines of a given file \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.09034 cm} x{2.88666 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Basics (cont)}} \tn % Row 27 \SetRowColor{LightBackground} cut -f {[}field{]} -d {[}separator{]} & allows you to print specific fields from an origin that have a given separator \tn % Row Count 4 (+ 4) % Row 28 \SetRowColor{white} uname & gets the OS kernel's name (Linux, Darwin...) \tn % Row Count 6 (+ 2) % Row 29 \SetRowColor{LightBackground} uname -m & gets the machine's architecture (if not within an emulator) \tn % Row Count 9 (+ 3) % Row 30 \SetRowColor{white} uname -r & gets the kernel version \tn % Row Count 10 (+ 1) % Row 31 \SetRowColor{LightBackground} uname -a & shows all the details of your UNIX OS \tn % Row Count 12 (+ 2) % Row 32 \SetRowColor{white} less {[}file{]} & prints a file using pagination \tn % Row Count 14 (+ 2) % Row 33 \SetRowColor{LightBackground} more {[}file{]} & same as `less {[}file{]}` \tn % Row Count 15 (+ 1) % Row 34 \SetRowColor{white} ln -s {[}source{]} {[}destination{]} & makes a symbolic link of a given source at the given destination \tn % Row Count 18 (+ 3) % Row 35 \SetRowColor{LightBackground} cal & prints a calendar on the terminal \tn % Row Count 20 (+ 2) % Row 36 \SetRowColor{white} date & reports the current date and time \tn % Row Count 22 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Write (or append to) a file without an editor}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{cat \textgreater{} {[}file{]} \textless{}\textless{} EOF \newline hello world \newline this is a file's content \newline blah blah blah \newline \newline hello again \newline \newline bye for now \newline EOF} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{In order to append to a file instead of replacing all of its contents, add two output cones instead of only one (\textgreater{}\textgreater{}).} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Command pipeline concatenation example}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`curl -s \seqsplit{"https://developer.android.com/studio\#downloads"} | grep ".dmg" | grep href | head -n1 | cut -f2 -d"=" | tr -d '"'` \newline % Row Count 3 (+ 3) This command will: \newline % Row Count 4 (+ 1) - download the downlaods page for Android Studio \newline % Row Count 5 (+ 1) - find for the lines that contain ".dmg" within them \newline % Row Count 7 (+ 2) - filter again to get only those that contain "href" \newline % Row Count 9 (+ 2) - filter again to get only the first occurrence \newline % Row Count 10 (+ 1) - split the result to get only the second field using = as a separator \newline % Row Count 12 (+ 2) - remove any double quotation marks on the string \newline % Row Count 13 (+ 1) The result should be a link that, when opened, will download the macOS installer for Android Studio. \newline % Row Count 16 (+ 3) Please note, if the website changes, this command may not work as is.% Row Count 18 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Manuals}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Almost all programs on any Unix OS will have what's called a "manpage". This is an instruction manual with details on how to use a program. \newline % Row Count 3 (+ 3) In order to read the manual for a specific application, just type `man {[}application{]}` and you will be able to read how it works. Press "Q" to close the manual when you're done.% Row Count 7 (+ 4) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{sed examples}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{The `sed` command uses a string as parameter to determine what to oeprate, and can receive several more parameters to configure the behavior. \newline % Row Count 3 (+ 3) `sed -i 's/hello/hi/' file.txt` will replace the first instance of "hello" that the script can find at each line, and write the result at the same given file. To avoid overwriting, you can just remove the `-i` argument. \newline % Row Count 8 (+ 5) `sed -i 's/hello/hi/g' file.txt` will replace every instance of "hello" that exist in the file. \newline % Row Count 10 (+ 2) To apply the patterns from a file, use the `-f`parameter with a path to a file. \newline % Row Count 12 (+ 2) If you want to make a backup of the file, add a suffix for said file after the `-i` parameter. For example: \newline % Row Count 15 (+ 3) `sed -i".bkp" 's/hello/hi/g' file.txt` will generate a file named `file.txt.bkp` with the original contents. \newline % Row Count 18 (+ 3) Regular expressions can be applied to the pattern given to sed, as maybe you want to replace something that may not be an exact string, but rather a pattern of it.% Row Count 22 (+ 4) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Networks}} \tn % Row 0 \SetRowColor{LightBackground} ifconfig & Shows a general network brief \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ip addr show & Same as `ifconfig` but on Linux \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} nmap {[}ip{]}/32 & Scans the ports of the given IP \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} ping {[}host{]} & Send a sequence of ICMP packets to a host \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} whois {[}host{]} & Tells you information about the domain \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} dig {[}domain{]} & Tells you how a specific domain resolves \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} nslookup {[}domain{]} & The same as `dig {[}domain{]}` \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} host {[}domain{]} & Reports several types of records for a given domain \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} wget {[}url{]} -O {[}file{]} & Downloads the given URL to the specified file \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} curl {[}url{]} -o {[}file{]} & Downloads the given URL to the specified file \tn % Row Count 20 (+ 2) % Row 10 \SetRowColor{LightBackground} iftop & Allows you to monitor the network throughput (Linux) \tn % Row Count 22 (+ 2) % Row 11 \SetRowColor{white} netstat -tulpn & Shows which applications are using what ports (Linux) \tn % Row Count 25 (+ 3) % Row 12 \SetRowColor{LightBackground} sudo lsof -i -n -P & Shows which applications are using what ports (macOS) \tn % Row Count 28 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Pipelines and operators}} \tn % Row 0 \SetRowColor{LightBackground} {[}command{]} \textgreater{} {[}file{]} & outputs the result of a command to a file \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {[}command{]} \textgreater{}\textgreater{} {[}file{]} & outputs the result of a command to the end of a file \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} {[}command{]} \textless{} {[}file{]} & gets a file and prints its content as if it were you entering it \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} {[}command{]} \textless{}\textless{} {[}file{]} & appends a file's contents into the program \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} {[}command1{]} \&\& {[}command2{]} & if command1 succeeds, command2 will be executed \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} {[}command1{]} || {[}command2{]} & if command1 fails, command2 will be executed \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} \& & the process will be run in the background \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} !! & the last executed command \tn % Row Count 18 (+ 2) % Row 8 \SetRowColor{LightBackground} \$? & the last command's exit code \tn % Row Count 20 (+ 2) % Row 9 \SetRowColor{white} {[}command1{]} | {[}command2{]} & sends the output of command1 to command2's input \tn % Row Count 22 (+ 2) % Row 10 \SetRowColor{LightBackground} {[}command{]} \textbackslash{} & allows you to make a line break without executing the command \tn % Row Count 25 (+ 3) % Row 11 \SetRowColor{white} {[}command{]} 2\textgreater{}\&1 & redirects the command's stderr to stdout \tn % Row Count 27 (+ 2) % Row 12 \SetRowColor{LightBackground} \textbackslash{}`{[}command{]}\textbackslash{}` & runs the given command, and then runs the result as a command itself \tn % Row Count 30 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Remote hosts}} \tn % Row 0 \SetRowColor{LightBackground} ssh {[}server{]} & connects to a server via SSH \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{ssh {[}server{]} -p {[}port{]}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{ssh {[}server{]} -i {[}certificate{]}} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} scp {[}user{]}@{[}server{]}:{[}path{]} {[}local path{]} & copies a file from a remote server to your machine \tn % Row Count 7 (+ 3) % Row 4 \SetRowColor{LightBackground} telnet {[}host{]} {[}port{]} & makes a raw tcp connection to a given host and port \tn % Row Count 10 (+ 3) % Row 5 \SetRowColor{white} w & reports who's connected at the machine \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} who & same as `w` \tn % Row Count 13 (+ 1) % Row 7 \SetRowColor{white} whoami & tells you your username \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{For SCP, you can upload from your machine to a remote server by changing the order of the commands. You can also use SSH's parameters with SCP (for port, you must use `-P` (capital)).} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.64701 cm} x{4.32999 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Environment variables}} \tn % Row 0 \SetRowColor{LightBackground} PATH & the directories where the shell will find for the command binaries \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} HOME & your home directory \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} UID & the user ID \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} EUID & the user ID running the command \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} SHELL & your current shell \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} PS1 & your prompt's style \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} PWD & your current directory \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} \seqsplit{RANDOM} & random number \tn % Row Count 10 (+ 2) % Row 8 \SetRowColor{LightBackground} HOST & the host's name \tn % Row Count 11 (+ 1) % Row 9 \SetRowColor{white} LANG & the shell's language \tn % Row Count 12 (+ 1) % Row 10 \SetRowColor{LightBackground} TTY & your current session's TTY \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Loops and decision taking}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{"For" loop \newline % Row Count 1 (+ 1) `for i in \{1..10\}` \newline % Row Count 2 (+ 1) `do` \newline % Row Count 3 (+ 1) ` echo \$i` \newline % Row Count 4 (+ 1) `done` \newline % Row Count 5 (+ 1) "While" loop (example of an infinite loop) \newline % Row Count 6 (+ 1) `while {[} true {]}` \newline % Row Count 7 (+ 1) `do` \newline % Row Count 8 (+ 1) `echo hello` \newline % Row Count 9 (+ 1) `done` \newline % Row Count 10 (+ 1) "Until" loop (do while) \newline % Row Count 11 (+ 1) `until {[} \$IDX -eq 5 {]}` \newline % Row Count 12 (+ 1) `do ` \newline % Row Count 13 (+ 1) `echo \$IDX` \newline % Row Count 14 (+ 1) `((IDX++))` \newline % Row Count 15 (+ 1) `done` \newline % Row Count 16 (+ 1) "If-else if-else" operator \newline % Row Count 17 (+ 1) `if {[} \$UID -eq 0 {]}` \newline % Row Count 18 (+ 1) `then` \newline % Row Count 19 (+ 1) `echo You are root` \newline % Row Count 20 (+ 1) `elif {[} \$UID -eq 1 {]}` \newline % Row Count 21 (+ 1) `echo You are user with ID 1` \newline % Row Count 22 (+ 1) `else` \newline % Row Count 23 (+ 1) `echo You are NOT root` \newline % Row Count 24 (+ 1) `fi`% Row Count 25 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4577 cm} p{0.50347 cm} x{3.61583 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Permission bits}} \tn % Row 0 \SetRowColor{LightBackground} 0 & -{}-{}- & Do nothing \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 1 & -{}-x & Execution \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 2 & -w- & Write \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 3 & -wx & Execute and write \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} 4 & r-{}- & Read \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} 5 & r-x & Read and execute \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} 6 & rw- & Read and write \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} 7 & rwx & Read, write and execute \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Here "r" stand for "read", "w" stands for "write", and "x" stands for "execute". It may be useless to have permissions below 4, as you won't be able to read the file. A 0 permission is useful to fully restrict access to any other user. \newline \newline Permissions are usually represented by three digits, and their meaning is the following: the first one represents the owner user of the file, the second number represents the owner group's permissions, and the last one represents everybody else's permissions.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{1.09494 cm} x{3.88206 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Package Managers}} \tn % Row 0 \SetRowColor{LightBackground} apt & Debian, Ubuntu \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} yum & Amazon Linux, Red Hat \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} dnf & Red Hat, Fedora \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} pacman & Arch Linux \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} emerge & Gentoo \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} brew & macOS (Homebrew) \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} choco & Windows (Chocolatey) \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Searching}} \tn % Row 0 \SetRowColor{LightBackground} find {[}path{]} -name {[}name pattern{]} & finds anything within a given path with a given pattern on its name \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} whereis {[}name{]} & tells you all the locations for a given binary name \tn % Row Count 7 (+ 3) % Row 2 \SetRowColor{LightBackground} which {[}name{]} & tells you the given binary name's path that will be run according to your PATH \tn % Row Count 11 (+ 4) % Row 3 \SetRowColor{white} locate {[}name{]} & tells you the location of any kind of file within your machine \tn % Row Count 14 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Monitoring the OS}} \tn % Row 0 \SetRowColor{LightBackground} ps aux & prints a snapshot of all system processes \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} top & shows the processes running on the machine \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} htop & shows the processes running on the machine with some graphs for memory usage \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} df -h & prints the system's storage devices' usage \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} du -hs {[}path{]} & prints a folder or file size \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} free -m & reports used and free ram and swap \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} kill {[}pid{]} & kills a process with the given pid \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} kill -9 {[}pid{]} & forcefully kills a process with the given pid \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} kill -l & lists the termination codes available to send the processes \tn % Row Count 20 (+ 3) % Row 9 \SetRowColor{white} pkill {[}process name{]} & kills any processes with the name provided (also works with -9 and other numeric signals) \tn % Row Count 24 (+ 4) % Row 10 \SetRowColor{LightBackground} xkill & kills a graphical process (Xorg) \tn % Row Count 26 (+ 2) % Row 11 \SetRowColor{white} lsblk & lists the drives, its partitions, and space (Linux) \tn % Row Count 28 (+ 2) % Row 12 \SetRowColor{LightBackground} blkid & shows the mount details of each volume (Linux) \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Monitoring the OS (cont)}} \tn % Row 13 \SetRowColor{LightBackground} lspci & lists PCI devices \tn % Row Count 1 (+ 1) % Row 14 \SetRowColor{white} lsusb & lists USB devices \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Compression}} \tn % Row 0 \SetRowColor{LightBackground} tar xf {[}file{]} & extracts a tar file at the current path \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} tar cf {[}filename{]} {[}content{]} & creates a tar file with the given name from the given content \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} tar zcf {[}filename{]} {[}content{]} & creates a gzipped tar file with the given name from the given content \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} unzip {[}file{]} & unzips a .zip file \tn % Row Count 9 (+ 1) % Row 4 \SetRowColor{LightBackground} zip {[}filename{]} {[}content{]} & creates a .zip file with the given name from the given content \tn % Row Count 12 (+ 3) \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}{`ls` parameters}} \tn % Row 0 \SetRowColor{LightBackground} -l & detailed list \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} -h & human-readable file size, used with -l \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} -r & reversed \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} -d & list directories themselves \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} -a & include dotfiles (hidden files) \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} -{}-si & list using base 1000 instead of 1024 \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} -m & list with commas instead of tabs \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} -t & sort by newest to oldest \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.04517 cm} x{3.93183 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{grep parameters}} \tn % Row 0 \SetRowColor{LightBackground} -i & case insensitive \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} -v & hide all matches \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} -r & recursive search \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} -e & regular expression pattern \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} -x & match entire line \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} -w & match entire word \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} -f {[}file{]} & use patterns from file \tn % Row Count 8 (+ 2) % Row 7 \SetRowColor{white} -I & do not search inside binary files \tn % Row Count 10 (+ 2) % Row 8 \SetRowColor{LightBackground} -R & recursive, even with symlinks \tn % Row Count 11 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{screen parameters}} \tn % Row 0 \SetRowColor{LightBackground} screen & creates a new screen session \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} screen -ls & lists the existing screen sessions \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} screen -r {[}name{]} & resume a given screen \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `CTRL + A` & activates commands for the active screen session \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} `CTRL + A, D` & disconnects from the screen \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{sort parameters}} \tn % Row 0 \SetRowColor{LightBackground} -n & numeric \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} -r & reverse \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} -k {[}number{]} & specific field \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} -f & case insensitive \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{`ls -l | sort -n -k5` will list a folder's contents by its size, from the least to the most sized.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Niceness}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Niceness is they way Unix OSes give priority to the applications running on the machine. A niceness of 19 means it's got the {\bf{least}} priority, whereas a -20 priority means it's got the {\bf{most}} priority. \newline % Row Count 5 (+ 5) `renice 19 {[}pid{]}` will make the process with given PID have the least priority within the CPU. This means that, when the OS is running low on CPU resources, this process will be more ignored than one with a lower niceness number. \newline % Row Count 10 (+ 5) `renice -20 {[}pid{]}` will make this process have the most CPU availability even when resources are scarce.% Row Count 13 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{S3 Commands (`aws s3`)}} \tn % Row 0 \SetRowColor{LightBackground} `ls s3://bucket/file` & Lets you know if a file exists or not \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `cp s3://bucket/file /path/on/machine` & Downloads a file into your computer \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `cp -{}-recursive s3://bucket/folder /path/on/machine` & Downloads a folder and its content into your computer \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} `rm s3://bucket/file` & Removes a remote file \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{All commands must begin by `aws s3`. \newline Paths can be specified in both ways: from local to remote, or from remote to local. They can also work from remote to remote, but will use your device as a bridge.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}