\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{Torvak} \pdfinfo{ /Title (shell.pdf) /Creator (Cheatography) /Author (Torvak) /Subject (Shell 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}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \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{Shell Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Torvak} via \textcolor{DarkBackground}{\uline{cheatography.com/32041/cs/9845/}}} \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}Torvak \\ \uline{cheatography.com/torvak} \\ \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 5th January, 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*}{3} \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Variables}} \tn % Row 0 \SetRowColor{LightBackground} `var=value;` & Initialisation \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} list=\$(ls) & put ls command in a variable 'list' \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{nbLines=\$((nbLines+1))} & increment nbLines \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `\$0` & the filename of the current script \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} `\$0` & n is a positive decimal number corresponding to the position of an argument (the 1st arg is \$1, the 2nd arg is \$2, ect) \tn % Row Count 12 (+ 5) % Row 5 \SetRowColor{white} `\$\#` & the number of arguments supplied to a script \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} `\$*` & all the arguments are double quoted. If a script receives two arguments, \$* is equivalent to \$1 \$2 \tn % Row Count 18 (+ 4) % Row 7 \SetRowColor{white} `\$@` & all the arguments are individually double quoted. If a script receives two arguments, \$@ is equivalent to \$1 \$2 \tn % Row Count 23 (+ 5) % Row 8 \SetRowColor{LightBackground} `\$?` & the exit status of the last command executed \tn % Row Count 25 (+ 2) % Row 9 \SetRowColor{white} `\$\$` & the process number of the current shell. For shell scripts, this is the process ID under which they are executing \tn % Row Count 30 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Variables (cont)}} \tn % Row 10 \SetRowColor{LightBackground} `\$!` & the process number of the last background command \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{NOTE:}}There's no need to specify whether var is string or numerical \newline {\bf{-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-}} \newline `nbLigne=1\{\{nl\}\}list=\$(ls)\{\{nl\}\}for i in \$list\{\{nl\}\}do \{\{nl\}\}\textless{}tab\textgreater{}echo "\$nbLigne -\textgreater{} \$i"\{\{nl\}\}\textless{}tab\textgreater{}nbLigne=\$((nbLigne+1))\{\{nl\}\}done\{\{nl\}\}`} \tn \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}{Directory commands}} \tn % Row 0 \SetRowColor{LightBackground} `touch fic\{1,2\}` & creates files: fic1 and fic2 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `mkdir folder` & create a folder named 'folder' \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `mkdir -p fold1/fold2/fold3` & fold1 contains fold2 and fold2 contains fold3 \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} `mkdir -p fold1/fold2/fold3 toto/tutu` & same as above create fold1 and toto with their sub directories \tn % Row Count 11 (+ 4) % Row 4 \SetRowColor{LightBackground} rm -R * & removes all folders and their subfolders \tn % Row Count 13 (+ 2) % Row 5 \SetRowColor{white} rm filename & remove a file \tn % Row Count 14 (+ 1) % Row 6 \SetRowColor{LightBackground} rm *.jpg & removes all jpg files \tn % Row Count 16 (+ 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}{LOOP examples}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-WHILE LOOP-{}-{}-{}-{}-{}-{}-{}-{}-}} \newline a=0 \newline while {[} \$a -lt 10 {]} \newline do \newline echo \$a \newline a=`expr \$a + 1` \newline done \newline {\bf{-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-FOR LOOP(1)-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-}} \newline for var in 0 1 2 3 4 5 6 7 8 9 \newline do \newline echo \$var \newline done \newline {\bf{-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-FOR LOOP(2)-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-}} \newline for FILE in \$HOME/.bash{\emph{ \newline do \newline echo \$FILE \newline done \newline {\bf{-{}-{}-{}-{}-{}-{}-{}-{}-{}--FOR LOOP(3)-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-}} \newline nbLigne=1 \newline for i in \$(ls) \newline do \newline echo "\$nbLigne -\textgreater{} \$i" \newline nbLigne=\$((nbLigne+1)) \newline done \newline {\bf{-{}-{}-{}-{}-{}-{}-{}-{}-{}-FOR LOOP(4)-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}--}} \newline for TOKEN in \$}} \newline do \newline echo \$TOKEN \newline done \newline {\bf{-{}-{}-{}-{}-{}-{}-{}-{}-{}-UNTIL LOOP-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-}} \newline a=0 \newline until {[} ! \$a -lt 10 {]} \newline do \newline echo \$a \newline a=`expr \$a + 1` \newline done \newline {\bf{-{}-{}-{}-{}-{}-{}-{}-{}-SELECT LOOP-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-}} \newline select DRINK in tea cofee water juice appe all none \newline do \newline case \$DRINK in \newline tea|cofee|water|all) \newline echo "Go to canteen" \newline ;; \newline juice|appe) \newline echo "Available at home" \newline ;; \newline none) \newline break \newline ;; \newline *) echo "ERROR: Invalid selection" \newline ;; \newline esac \newline done \newline {\bf{-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-SIMPLE BREAK-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}--}} \newline a=0 \newline while {[} \$a -lt 10 {]} \newline do \newline echo \$a \newline if {[} \$a -eq 5 {]} \newline then \newline break \newline fi \newline a=`expr \$a + 1` \newline done \newline {\bf{-{}-{}-{}--BREAK WITH ARGUMENT-{}-{}-{}-}} \newline for var1 in 1 2 3 \newline do \newline for var2 in 0 5 \newline do \newline if {[} \$var1 -eq 2 -a \$var2 -eq 0 {]} \newline then \newline break 2 \newline else \newline echo "\$var1 \$var2" \newline fi \newline done \newline done \newline {\bf{NOTE: a break command with the argument 2-\textgreater{}break out of outer loop and ultimately from inner loop as well.}} \newline {\bf{-{}-{}-{}-{}-{}-{}-{}-{}-CONTINUE-{}-{}-{}-{}-{}-{}-{}-{}-{}--}} \newline NUMS="1 2 3 4 5 6 7" \newline \newline for NUM in \$NUMS \newline do \newline Q=`expr \$NUM \% 2` \newline if {[} \$Q -eq 0 {]} \newline then \newline echo "Number is an even number!!" \newline continue \newline fi \newline echo "Found odd number" \newline done} \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}{Pipes and filters}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{`grep pattern file(s)print all lines that do not match pattern`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `grep -v` & print all lines that do not match pattern \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} `grep -n` & print the matched line and its line number \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} `grep -l` & print only the names of files with matching lines (letter "l") \tn % Row Count 12 (+ 4) % Row 4 \SetRowColor{LightBackground} `grep -c` & print only the count of matching lines \tn % Row Count 14 (+ 2) % Row 5 \SetRowColor{white} `grep -i` & match either upper- or lowercase \tn % Row Count 16 (+ 2) % Row 6 \SetRowColor{LightBackground} `ls -l | grep -i "carol.*aug"` & find lines with "carol", followed by zero or more other characters abbreviated in a regular expression as ".*"), then followed by "Aug" \tn % Row Count 23 (+ 7) % Row 7 \SetRowColor{white} `sort fileName` & arranges lines of text alphabetically or numerically \tn % Row Count 26 (+ 3) % Row 8 \SetRowColor{LightBackground} `sort -n` & sort numerically (example: 10 will sort after 2), ignore blanks and tabs \tn % Row Count 30 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Pipes and filters (cont)}} \tn % Row 9 \SetRowColor{LightBackground} `sort -r` & reverse the order of sort \tn % Row Count 2 (+ 2) % Row 10 \SetRowColor{white} `sort -f` & sort upper- and lowercase together \tn % Row Count 4 (+ 2) % Row 11 \SetRowColor{LightBackground} `sort +x` & ignore first x fields when sorting \tn % Row Count 6 (+ 2) % Row 12 \SetRowColor{white} `ls -l | grep "Aug" | sort +4n` & sorts all files in your directory modified in August by order of size, +4n skips four fields (fields are separated by blanks) then sorts the lines in numeric order \tn % Row Count 15 (+ 9) % Row 13 \SetRowColor{LightBackground} `ls -l \$dir |egrep "\textasciicircum{}-|\textasciicircum{}l" |rev |cut -d' ' -f 1|rev` & \textgreater{} list contents starting by '-' or 'l' (file) \{\{nl\}\}\textgreater{}reverse letters\{\{nl\}\}\textgreater{}cut with delimiter ' '(space)\{\{nl\}\}\textgreater{}select field 1\{\{nl\}\}\textgreater{}reverse \tn % Row Count 22 (+ 7) % Row 14 \SetRowColor{white} `ls -l \$dir |egrep "\textasciicircum{}d" |rev |cut -d' ' -f 1|rev` & \textgreater{} list contents starting by 'd' (directory)\{\{nl\}\}\textgreater{}rest same as above \tn % Row Count 26 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Conditional structure}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{/-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-IF\_ELIF\_FI-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-/}} \newline \#!/bin/sh \newline \newline a=10 \newline b=20 \newline \newline if {[} \$a == \$b {]} \newline then \newline echo "a is equal to b" \newline elif {[} \$a -gt \$b {]} \newline then \newline echo "a is greater than b" \newline elif {[} \$a -lt \$b {]} \newline then \newline echo "a is less than b" \newline else \newline echo "None of the condition met" \newline fi \newline \newline {\bf{RESULT: a is less than b}} \newline \newline {\bf{/-{}-{}-{}--SIMPLE CASE...ESAC EXAMPLE-{}-{}-{}-{}-{}-/}} \newline FRUIT="kiwi" \newline \newline case "\$FRUIT" in \newline "apple") echo "Apple pie is quite tasty." \newline ;; \newline "banana") echo "I like banana nut bread." \newline ;; \newline "kiwi") echo "New Zealand is famous for kiwi." \newline ;; \newline esac \newline {\bf{RESULT: New Zealand is famous for kiwi.}} \newline \newline /-{}-{}-{}-COMPLEXE CASE\_ESAC-{}-{}-{}--/ \newline option="\$\{1\}" \newline case \$\{option\} in \newline -f) FILE="\$\{2\}" \newline echo "File name is \$FILE" \newline ;; \newline -d) DIR="\$\{2\}" \newline echo "Dir name is \$DIR" \newline ;; \newline *) \newline echo "`basename \$\{0\}`:usage: {[}-f file{]} | {[}-d directory{]}" \newline exit 1 \# Command to come out of the program with status 1 \newline ;; \newline esac \newline \newline {\bf{EXAMPLE RUN OF THE PROGRAME: }} \newline \$./test.sh \newline test.sh: usage: {[} -f filename {]} | {[} -d directory {]} \newline \$ ./test.sh -f index.htm \newline \$ vi test.sh \newline \$ ./test.sh -f index.htm \newline File name is index.htm \newline \$ ./test.sh -d unix \newline Dir name is unix} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.24425 cm} x{3.73275 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Operators}} \tn % Row 0 \SetRowColor{LightBackground} +, -, *, /, \% & Basic arithetic operators \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} = & Assignment - Assign right operand in left operand \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} == & Equality - Compares two numbers, if both are same then returns true. \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} != & Not Equality - Compares two numbers, if both are different then returns true. \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} -eq & Checks if the value of two operands are equal or not, if yes then condition becomes true. \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} -ne & Checks if the value of two operands are equal or not, if values are not equal then condition becomes true. \tn % Row Count 17 (+ 4) % Row 6 \SetRowColor{LightBackground} -gt & Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true \tn % Row Count 21 (+ 4) % Row 7 \SetRowColor{white} -lt & Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true \tn % Row Count 25 (+ 4) % Row 8 \SetRowColor{LightBackground} -ge & Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. \tn % Row Count 30 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.24425 cm} x{3.73275 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Operators (cont)}} \tn % Row 9 \SetRowColor{LightBackground} -le & Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true \tn % Row Count 5 (+ 5) % Row 10 \SetRowColor{white} ! & This is logical negation. This inverts a true condition into false and vice versa \tn % Row Count 8 (+ 3) % Row 11 \SetRowColor{LightBackground} -o & This is logical OR. If one of the operands is true then condition would be true \tn % Row Count 11 (+ 3) % Row 12 \SetRowColor{white} -a & This is logical AND. If both the operands are true then condition would be true otherwise it would be false \tn % Row Count 15 (+ 4) % Row 13 \SetRowColor{LightBackground} -e & check if right operand exists \tn % Row Count 16 (+ 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}{Input, Output to Promt screen}} \tn % Row 0 \SetRowColor{LightBackground} `read varName` & Store user input in varName \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `echo \$varName` & Outputs to screen content of \$varName \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `echo "You entered \$varName"` & Same as above \tn % Row Count 6 (+ 2) \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}{File systems}} \tn % Row 0 \SetRowColor{LightBackground} `who \textgreater{} users` & Puts output of command 'who' in the file 'users' (NOTE: if file already contains content, it will be overwritten) \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} `cat users` & lists content of file 'users' \tn % Row Count 8 (+ 2) % Row 2 \SetRowColor{LightBackground} `echo new line \textgreater{}\textgreater{} users` & append to last line of file 'users' \tn % Row Count 10 (+ 2) % Row 3 \SetRowColor{white} `wc -l \textless{} users` & get contents of file 'users' as standar input \tn % Row Count 13 (+ 3) % Row 4 \SetRowColor{LightBackground} `command \textless{}\textless{} delimiter \{\{nl\}\} document \{\{nl\}\}delimiter` & a here document is used to redirect input into an interactive shell script or program \tn % Row Count 18 (+ 5) % Row 5 \SetRowColor{white} `command \textgreater{} /dev/null` & discard command output \tn % Row Count 20 (+ 2) % Row 6 \SetRowColor{LightBackground} `command \textgreater{} /dev/null 2\textgreater{}\&1` & same as above but doesn't display errors. 2 represents STDERR and 1 represents STDOUT. \tn % Row Count 25 (+ 5) % Row 7 \SetRowColor{white} `echo message 1\textgreater{}\&2` & display a message on to STDERR by redirecting STDOUT into STDERR \tn % Row Count 29 (+ 4) \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}{Permissions}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{`chmod o+wx,u-x,g=rx testfile \{\{nl\}\}ls -l testfile \{\{nl\}\}-rw-r-xrwx 1 amrood users 1024 Nov 2 00:10 testfile`} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} `chown userName filelist` & change ownership of filelist to userName \tn % Row Count 5 (+ 2) \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}{Navigating file system}} \tn % Row 0 \SetRowColor{LightBackground} `cat filename` & displays contents of filename \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `cd dirname` & moves you to dirname directory \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `cp file1 file2` & copies 1 file/directiry to specified location \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} `file filename` & identifies the fie type(binary, tect, etc..) \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} `find filename dir` & finds a file/directory \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} `head filename` & shows the begining of a file \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} `less filename` & browses through a file from begining to end \tn % Row Count 17 (+ 3) % Row 7 \SetRowColor{white} `ls dirname` & shows contents of directory \tn % Row Count 19 (+ 2) % Row 8 \SetRowColor{LightBackground} `mkdir dirname` & creates speicified directory \tn % Row Count 21 (+ 2) % Row 9 \SetRowColor{white} `more filename` & browses through a file from begining to end \tn % Row Count 24 (+ 3) % Row 10 \SetRowColor{LightBackground} `mv file1 file2` & moves the location of or renames a file/directory \tn % Row Count 27 (+ 3) % Row 11 \SetRowColor{white} `pwd` & shows the current directory the users is in \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Navigating file system (cont)}} \tn % Row 12 \SetRowColor{LightBackground} `rmdir dirname` & removes a a directory \tn % Row Count 2 (+ 2) % Row 13 \SetRowColor{white} `rm filename` & removes a file \tn % Row Count 3 (+ 1) % Row 14 \SetRowColor{LightBackground} `tail filename` & shows the end of a file \tn % Row Count 5 (+ 2) % Row 15 \SetRowColor{white} `touch filename` & creates a blank file or modifies an existing file's attrbites \tn % Row Count 9 (+ 4) % Row 16 \SetRowColor{LightBackground} `whereis filename` & shows the location of a file \tn % Row Count 11 (+ 2) % Row 17 \SetRowColor{white} `which filename` & shows the location of a file if it is in your path \tn % Row Count 14 (+ 3) % Row 18 \SetRowColor{LightBackground} `df -k` & displays disk space sage in kilobytes \tn % Row Count 16 (+ 2) % Row 19 \SetRowColor{white} `du dirname` or `du -h dirname` & show disk usage on particular directory \tn % Row Count 18 (+ 2) % Row 20 \SetRowColor{LightBackground} `mount` & view what is currently mounted \tn % Row Count 20 (+ 2) % Row 21 \SetRowColor{white} `mount -t fileSysType deviceToMount dir\_to\_mount\_to` & mount a filesystem (CD etc..) \tn % Row Count 23 (+ 3) % Row 22 \SetRowColor{LightBackground} `mount -t iso9660 /dev/cdrom /mnt/cdrom` & example of above command \tn % Row Count 25 (+ 2) % Row 23 \SetRowColor{white} `unmount mountPointOrDevice` & unmount a filesystem \tn % Row Count 27 (+ 2) % Row 24 \SetRowColor{LightBackground} `quota` & displays disk usage and limits for a user of group \tn % Row Count 30 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{`echo \$(find \$dir -type f -printf "\%f\textbackslash{}n") |tr " " "\textbackslash{}n"` \newline {\bf{What this does?}} \newline \textgreater{} display path of contents of dir \newline \textgreater{} select only content of type file -f \newline \textgreater{} print the result in the same line \newline \textgreater{} tr (translate) ' ' (space) into '\textbackslash{}n' line break} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}