\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{SathyaNarayanan (Sathyanarayanan)} \pdfinfo{ /Title (linux-command-line.pdf) /Creator (Cheatography) /Author (SathyaNarayanan (Sathyanarayanan)) /Subject (Linux Command Line 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}{9863A3} \definecolor{LightBackground}{HTML}{F8F5F9} \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 Command Line Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{SathyaNarayanan (Sathyanarayanan)} via \textcolor{DarkBackground}{\uline{cheatography.com/136085/cs/29006/}}} \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}SathyaNarayanan (Sathyanarayanan) \\ \uline{cheatography.com/sathyanarayanan} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 19th October, 2021.\\ Updated 9th October, 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*}{3} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{shell prompt}} \tn % Row 0 \SetRowColor{LightBackground} \# & Super User \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \$ & normal user \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.59724 cm} x{4.37976 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{simple commands}} \tn % Row 0 \SetRowColor{LightBackground} date & display current date and time \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} cal & display current month calendar \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} df & displays disk usages \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} free & display memory usage \tn % Row Count 4 (+ 1) \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}{Navigation}} \tn % Row 0 \SetRowColor{LightBackground} cd & change the current diretcory \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ls & list the directory \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{cd - : change to previous working directory \newline cd \textasciitilde{}username : change to home directory} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Exploring Filesystem}} \tn % Row 0 \SetRowColor{LightBackground} file & Determine file type \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} less & view file contents \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{ls \newline -l diplay in long format \newline -h human readable \newline -a list all files even those hidden, \newline -d directory \newline -F option will append an indictor charactor to the end of listed names \newline -r display result in reverse order \newline -S sort by file Size \newline -t modification time} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.54747 cm} x{4.42953 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Manipulating Files and Directories}} \tn % Row 0 \SetRowColor{LightBackground} cp & copy the files \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} mv & move the files from one folder to other \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} mkdir & creates a directory \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} rm & remove files and directories \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} ln & create Hard and symbolic link \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{* any character \newline ? any single character \newline {[} character{]} any character that is a member of character \newline {[} ! character{]} any character that is not a member of character \newline {[}{[}:class:{]}{]} any character that is a member of class} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4577 cm} x{3.2039 cm} x{0.9154 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{command Options : cp, mv}} \tn % Row 0 \SetRowColor{LightBackground} i & interactive & same in mv \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} a & copy files and directories of all attributes, ownership and permission & - \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} r & recursively copies directories and contents & same in mv \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} u & copy the files that don't exists & same in mv \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} v & verbose, informative message & same in mv \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.23965 cm} x{2.73735 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Command Substitution}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{echo \$(ls)} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ls -l \$(which cp) & new method \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} ls -l `which cp` & back tick, old method \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.79632 cm} x{4.18068 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Process}} \tn % Row 0 \SetRowColor{LightBackground} ps & reports snap shot of current process \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} top & diskplays task \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} jobs & list active jobs \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} bg & place a job in the background \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} fg & place a job in the foreground \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} kill & send a signal to process \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} \seqsplit{killall} & kill process by name \tn % Row Count 9 (+ 2) \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}{Process commands}} \tn % Row 0 \SetRowColor{LightBackground} ps aux & BSD style ouptut \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} fg \%1 & jobs \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} kill -1 13456 & kill process id 13456 \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{SIGNALS: HUP, INT, KILL, TERM,CONT,STOP,QUIT, SEGV, TSTP. WINCH} \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}{Find command}} \tn % Row 0 \SetRowColor{LightBackground} cmin & match attributes/files/dir modified, n minutes \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cnewer & match file/dir whose content or attribute were last modified n*24 ago \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} ctime n & match file or direct whose content or attribute were modified n*24 hrs ago \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} empty & match empty files and directories \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} group name & match files or direc belonging to group name \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} iname & pattern like the iname test but case insensitive \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} inum n & match files with inode number \tn % Row Count 15 (+ 1) % Row 7 \SetRowColor{white} mmin n & match files or dir whose content were modified n minutes ago \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} mtime n & match files or dir whose content were modified n*24 hours ago \tn % Row Count 20 (+ 3) % Row 9 \SetRowColor{white} name pattern & match files and dir with specified wildcard pattern \tn % Row Count 22 (+ 2) % Row 10 \SetRowColor{LightBackground} nouser & match files and dir that don't belong to valid user \tn % Row Count 24 (+ 2) % Row 11 \SetRowColor{white} nogroup & match files and dir that don't belong to valid group \tn % Row Count 26 (+ 2) % Row 12 \SetRowColor{LightBackground} perm mode & match files and directories set to specified mode \tn % Row Count 28 (+ 2) % Row 13 \SetRowColor{white} samefile name & matches files that share the same inode number as file name \tn % Row Count 30 (+ 2) \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}{Find command (cont)}} \tn % Row 14 \SetRowColor{LightBackground} size n & match file size of n \tn % Row Count 1 (+ 1) % Row 15 \SetRowColor{white} type c & match file type of c \tn % Row Count 2 (+ 1) % Row 16 \SetRowColor{LightBackground} user & match file and directories belong to user \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{find \%test \%action \%options \newline find \textasciitilde{} \newline find \textasciitilde{} | wc -l \newline find \textasciitilde{} -type d | wc -l \newline -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- \newline \newline b block \newline c character special device \newline d directory \newline f regular file \newline l symbolic link} \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}{Find Logical Operator}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{and} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{or} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{not} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{find \textasciitilde{} \textbackslash{}( -type f -not -perm 0600 \textbackslash{}) -or \textbackslash{}( -type d -not -perm -700 \textbackslash{})} \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}{find -actions}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{delete} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{ls} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{print} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{quite} \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{find \textasciitilde{} -type f -name '{\emph{.BAR{]} -print \newline find \textasciitilde{} -type f -and -name '}}.BAR -and -print \newline \newline Userdefined actions \newline -exec comman\{\} \newline \newline find \textasciitilde{} -type f -name 'foo{\emph{' -exec ls -l '\{\}' + \newline find \textasciitilde{} -type f -name 'foo}}' -exec ls -l '\{\}' ';'} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Find Options - scope}} \tn % Row 0 \SetRowColor{LightBackground} depth & to process a directory files before the dir itself \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{maxdepth} & max num of level that find will descend into a directory when performing test and action \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \seqsplit{mindepth} & min num of level that find will descend into a directory when performing test and action \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} mount & direct find not to traverse directories that mounter on other filesystem \tn % Row Count 11 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 11 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.09494 cm} x{3.88206 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Tricks}} \tn % Row 0 \SetRowColor{LightBackground} clear & clears the screen \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} history & stores the history \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} script file & capture all command execution in a file \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{history: CTRL + \{R, P \} \newline !!number : command history number \newline !! : last command \newline !?string : history containing last string \newline !string : history containing last string \newline export HISTCONTROL=ignoredups \newline export HISTSIZE=10000} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.74655 cm} x{4.23045 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Working With Commands}} \tn % Row 0 \SetRowColor{LightBackground} type & Indicate how command name is interpreted \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} which & display which executable program will be executed \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} man & Display manual page \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \seqsplit{apropos} & Display appropriate command \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} info & Display command Info entry \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} \seqsplit{whatis} & Display brief description of command \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} alias & create an alias for command \tn % Row Count 11 (+ 1) \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}{man page options}} \tn % Row 0 \SetRowColor{LightBackground} 1 & User commands \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 2 & Programming interface for system calls \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} 3 & Programming interface for C Library \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} 4 & Special files such devies nodes and drivers \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} 5 & file formats \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} 6 & Games and screen savers \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} 7 & misc \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} 8 & system administrator commands \tn % Row Count 10 (+ 1) \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}{Redirection}} \tn % Row 0 \SetRowColor{LightBackground} cat & concatenates files \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} sort & sort the file \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} uniq & report or omit repeated lines \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} grep & print lines matching pattern \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} head & prints first few lines of file \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} tail & prints las few lines of file \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} tee & reads stdin and send output to stdout and file \tn % Row Count 8 (+ 2) % Row 7 \SetRowColor{white} wc & count number of line, words, and bytes \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.38896 cm} x{2.58804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Redirection Operator}} \tn % Row 0 \SetRowColor{LightBackground} ls -l /usr/bin \textgreater{}file & default stdout to file \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ls -l /usr/bin 2\textgreater{}file & redirects stderr to file \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} ls -l /usr/bin \textgreater{} ls-output 2\textgreater{}\&1 & redirects stderr \& stdout to file \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} ls -l /usr/bin \&\textgreater{} ls-output & redirects stderr \& stdout to file \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} ls -l /usr/bin 2\textgreater{} /dev/null & /dev/null bitbucket \tn % Row Count 10 (+ 2) \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}{Pipelines}} \tn % Row 0 \SetRowColor{LightBackground} | & pipelines \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ls -l /usr/bin/ | tee out | sort & tee reads stdin and writes to files and stdout \tn % Row Count 4 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.94103 cm} x{3.03597 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{view the world as SHELL viewed}} \tn % Row 0 \SetRowColor{LightBackground} echo * & expands all files in the path \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} echo D* & expands all files with starting D \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{\$((expression))} & Arithematic expression \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} echo \$((\$((5{\emph{*2))}}3)) & 75 \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} ls -l `which cp` & backtick instead of expression \tn % Row Count 9 (+ 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}{Braces Expansion}} \tn % Row 0 \SetRowColor{LightBackground} echo Front-\{A,B,C\}-Back & Front-A-Back, Front-B-Back, Front-C-Back \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} echo \{Z..A\} & Z Y X W V U .....A \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} mkdir \{2009..2011\}-0\{1..9\} \{2009..2011\}-\{10..12\} & creates a directory for 12 months in 2009 to 2011 \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Environment}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{printenv} & Print part of all of the environment \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} set & set shell options \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{export} & export environment to subsequently executed programs \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} alias & create an alias for command \tn % Row Count 6 (+ 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}{Login \& Non Login Shell}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Login Shells}} : \newline % Row Count 1 (+ 1) /etc/profile : global configuration \newline % Row Count 2 (+ 1) \textasciitilde{}/.bash\_profile : personal startup efile \newline % Row Count 3 (+ 1) \textasciitilde{}/.bash\_login. : if \textasciitilde{}/.bash\_profile is not found, bash attempts to read this script \newline % Row Count 5 (+ 2) \textasciitilde{}/.profile : if neither \textasciitilde{}/.bash\_profile \& \textasciitilde{}/.bash\_login bash reads this file \newline % Row Count 7 (+ 2) {\bf{Non Login shells }} : \newline % Row Count 8 (+ 1) /etc/bash.bashrc : Global configuration \newline % Row Count 9 (+ 1) \textasciitilde{}/.bashrc : User configuration% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.9908 cm} x{2.9862 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Quoting}} \tn % Row 0 \SetRowColor{LightBackground} echo This is a test & This is a test; space is stripped \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} echo "This is a test" & This is a test \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} echo '\$(echo foo) \$((2+2))' & \$(echo foo) \$((2+2)) \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} echo the total is \$500.00 & \$5 is undefined variable so it supress the value, output will be like the total is 00.00 \tn % Row Count 10 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{" " : all special character looses its meaning, exception (\$, \textbackslash{}, `) \newline ' ' : all special character looses its meaning, and no exceptions} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.74655 cm} x{4.23045 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Searching For Files}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{locate} & find files by name \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} find & search for files in a dir \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} xargs & build and exec cmd lines from stdin \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} touch & change the file times \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} stat & display file or filesystem status \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.9954 cm} x{3.9816 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Networking}} \tn % Row 0 \SetRowColor{LightBackground} Ping & Send ICMP packets \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{traceroute} & Print route packets to a network \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} netstat & print network connection, routing table, interface stats \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{ftp/lftp} & Internet file transfer program \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} wget & Non Interactive network downloader \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} ssh & OpenSSH SSH Client (remote login program) \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} scp & secure copy \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} sftp & Secure File transfer program \tn % Row Count 12 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{OpenSSH package includes two programs that can make use of an SSH encrypted tunnel to copy file across the network. \newline a) scp \newline b) sftp \newline \newline SFTP doesn't require ftp server to connect, it needs only SSH running in machines, any machine that has ssh running, we can able to transfer files to server} \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}{Archiving and Backup}} \tn % Row 0 \SetRowColor{LightBackground} gzip & Compress or expand files \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} bzip2 & A block sorting file compressor \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} tap & tape archving utility \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} zip & Package and compress files \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} rsync & remote file and dir synchronization \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} unzip & Unzip the gzip files \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{compression algorithm: Lossy and Lossless} \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}{Hacks}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Examples: \newline % Row Count 1 (+ 1) ssh remote-sys 'tar cf - Document' | tar xf - \newline % Row Count 2 (+ 1) find playground -name 'file-A' | tar czf playground.tgz -T - \newline % Row Count 4 (+ 2) find playground -name 'file-A' | tar cjf playground.tgz -T - \newline % Row Count 6 (+ 2) rsync -av -{}-delete -{}-rsh=ssh /etc /home /usr/local remote-sys:/backup \newline % Row Count 8 (+ 2) To copy ssh public to remote machine \newline % Row Count 9 (+ 1) ssh-copy-id -i \seqsplit{xxxxx\_ext\_2023-08-22.pub} username@hostname% Row Count 11 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{- or Hyphen is the stdin and stdout} \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}{Text processing examples}} \tn % Row 0 \SetRowColor{LightBackground} cat -A \$FILE & To find any CTRL character introduced \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} sort file1.txt file2.txt file3.txt \textgreater{} \seqsplit{final\_sorted\_list.txt} & sort all files once \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} ls - l | sort -nr -k 5 & key field 5th column \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} sort -{}-key=1,1 -{}-key=2n distor.txt & key field 1,1 sort and second column sort by numeric \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} sort foo.txt | uniq -c & to find repetition \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} cut -f 3 distro.txt & cut column 3 \tn % Row Count 13 (+ 1) % Row 6 \SetRowColor{LightBackground} cut -c 7-10 & cut character 7 - 10 \tn % Row Count 14 (+ 1) % Row 7 \SetRowColor{white} cut -d ':' -f 1 /etc/password & delimiter : \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} sort -k 3.7nbr -k 3.1nbr -k 3.4nbr distro.txt & 3 rd field 7 the character, 3rd field 1 character \tn % Row Count 19 (+ 3) % Row 9 \SetRowColor{white} paste file1.txt file2.txt \textgreater{} newfile.txt & merge two files \tn % Row Count 21 (+ 2) % Row 10 \SetRowColor{LightBackground} join file1.txt file2.txt & join on common two fields \tn % Row Count 23 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.54747 cm} x{4.42953 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Text processing}} \tn % Row 0 \SetRowColor{LightBackground} cat & concatenate files and print stdout \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} sort & sort lines of text files \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} uniq & report or omite repeated lines \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} cut & remove section from each line of files \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} paste & merge lines of files \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} join & join lines of two files on a common field \tn % Row Count 9 (+ 2) % Row 6 \SetRowColor{LightBackground} comm & compare two sorted files line by line \tn % Row Count 11 (+ 2) % Row 7 \SetRowColor{white} diff & compare files \tn % Row Count 12 (+ 1) % Row 8 \SetRowColor{LightBackground} patch & apply a diff file to original \tn % Row Count 14 (+ 2) % Row 9 \SetRowColor{white} tr & translate \tn % Row Count 15 (+ 1) % Row 10 \SetRowColor{LightBackground} sed & stream editor \tn % Row Count 16 (+ 1) % Row 11 \SetRowColor{white} aspel & interactive spell checker \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.79632 cm} x{4.18068 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Permissions}} \tn % Row 0 \SetRowColor{LightBackground} id & display user identity \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} chmod & change's file mode \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} umask & set the default file permission \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} su & Run a shell as another user \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} sudo & Execute command as another user \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} chown & changes file's owner \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} chgrp & change file groups owner \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \seqsplit{passwd} & change a user password \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.9908 cm} x{2.9862 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Read,Write, Execute}} \tn % Row 0 \SetRowColor{LightBackground} - | rwx | rw- | r-{}- & type | owner | group | world \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{type \newline - regular file \newline d directory \newline l symbolic link \newline c character device \newline b block device} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{2.4885 cm} p{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{File Mode {[}Octal{]}}} \tn % Row 0 \SetRowColor{LightBackground} 000 & -{}-{}- \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 001 & -{}-x \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 010 & -w- \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 011 & -wx \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} 100 & r-{}- \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} 101 & r-x \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} 110 & rw- \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} 111 & rwx \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{chmod 0600 file {[} rw- is set for owner {]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Mode symbolic notation}} \tn % Row 0 \SetRowColor{LightBackground} ugo & user, group, others \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} u+x & giving exeute permission for user \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} u=rw,o=x & giveing user read write and others execute perm \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{chmod u=rw,o=x file.txt} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.59264 cm} x{3.38436 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Packaging Ssystem}} \tn % Row 0 \SetRowColor{LightBackground} Debian Style (.dep) & Debain, ubuntu, xandros, Linspire \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} RedHat style(.rpm) & Fedora, CentOS, Redhat Enterprise, OpenSUSE, Mandriva, PCLinuxOS \tn % Row Count 5 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.89586 cm} x{4.08114 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Install from Repo}} \tn % Row 0 \SetRowColor{LightBackground} debian & apt-get install package\_name \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} redhat & yum install package\_name \tn % Row Count 2 (+ 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}{Operation on Package File}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Debian}} : \newline % Row Count 1 (+ 1) dpkg -{}-install packagefile \newline % Row Count 2 (+ 1) apt-get remove package\_name \newline % Row Count 3 (+ 1) apt-get update \newline % Row Count 4 (+ 1) dpkg -{}-list \newline % Row Count 5 (+ 1) dpkg -{}-status package\_name \newline % Row Count 6 (+ 1) apt-cache show package\_name (info about package) \newline % Row Count 7 (+ 1) dpkg -{}-search file\_name (finding which package installed) \newline % Row Count 9 (+ 2) {\bf{Redhat}} : \newline % Row Count 10 (+ 1) rpm -i packagefile \newline % Row Count 11 (+ 1) yum erase package\_name \newline % Row Count 12 (+ 1) yum update \newline % Row Count 13 (+ 1) rpm -u packagefile \newline % Row Count 14 (+ 1) rpm -qa. (list) \newline % Row Count 15 (+ 1) rpm -q package\_name (check package installed) \newline % Row Count 16 (+ 1) yum info package\_name \newline % Row Count 17 (+ 1) rpm -qf file\_name (finding which package installed)% Row Count 19 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.09494 cm} x{3.88206 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{storage media}} \tn % Row 0 \SetRowColor{LightBackground} mount & mount a filesystem \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ummount & unmount a file system \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} fdisk & partition table manipulator \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} fsck & check and repair filesystem \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \seqsplit{fdformat} & format floppy disk \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} mkfs & create a file system \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} dd & write a block oriented data directly to a device \tn % Row Count 8 (+ 2) % Row 7 \SetRowColor{white} \seqsplit{genisoimage} & create an ISO 9660 image file \tn % Row Count 10 (+ 2) % Row 8 \SetRowColor{LightBackground} wodim & Write data to optical storage device \tn % Row Count 12 (+ 2) % Row 9 \SetRowColor{white} md5sum & calculate md5sum \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{dd if=/dev/cdrom of=ubuntu.iso (create image file) \newline fsck /dev/sdb1 (check file system) \newline mkfs -t ext3 /dev/sdb1 (create ext3 file system) \newline unmount /dev/sdb1 (unmount the file system, before changing the partition table) \newline fdisk /dev/sdb (create a partition table ) \newline Generate 1GB file using uurandom \newline dd if=/dev/urandom of=sample.txt bs=64M count=16} \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}{POSIX charcter class}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{character class \newline % Row Count 1 (+ 1) alnum, word , alpha blank, cntrl, digit, graph,lowe, punct, print, space, upper, xdigit \newline % Row Count 3 (+ 2) format: {[} :alnum: {]}% Row Count 4 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{echo \$LANG \newline export LANG=POSIX} \tn \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}{grep Options}} \tn % Row 0 \SetRowColor{LightBackground} i & ignore case \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} v & invert match \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} c & print number of matches \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} l & print the name of each file that contain matches \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} L & print only the names of files that don't match \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} n & print match line with the number \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} h & for multiple output supress the output of filename \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{grep {[}options{]} regex {[}file....{]} \newline \newline metacharacters : \textasciicircum{} \$ . {[} {]} \{\} - ? * + ( ) | \textbackslash{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.53827 cm} x{2.43873 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{grep examples}} \tn % Row 0 \SetRowColor{LightBackground} grep -h '.zip' file.list & . is any character \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} grep -h '\textasciicircum{}zip' file.list & starts with zip \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} grep -h 'zip\$' file.list & ends with zip \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} grep -h '\textasciicircum{}zip\$' file.list & containing only zip \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} grep -h '{[}\textasciicircum{}bz{]}zip' file.list & not containing b and z \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} grep -h '\textasciicircum{}{[}A-Za-z0-9{]}' file.list & file containing any valid names \tn % Row Count 12 (+ 2) \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}{grep Quantifiers}} \tn % Row 0 \SetRowColor{LightBackground} ? & match element zero or one time \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} * & match an element zero or more times \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} + & Match an element one or more times \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \{\} & match an element specfic number of times \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{It always match the preceding element \newline \{n\} match the preceding element occurs n times \newline \{n,m\} match the preceding element occurs at least n times, but no more than m times \newline \{n,\} match the preceding element if it occurs n or more times \newline \{,m\} match the preceding element if it occurs no more than m times} \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}{grep hacks}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{grep -E '\textasciicircum{}\textbackslash{}({[}0-9{]}\{3\}\textbackslash{}).{[}0-9{]}\{3\}.{[}0-9{]}\{3\}\$' phone.txt \newline % Row Count 2 (+ 2) locate -{}-regex 'bin/(bz|gz|zip)'% Row Count 3 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{for i in \{1..10\}; do echo "(\$\{RANDOM:0:3\})-\$\{RANDOM:0:3\}-\$\{RANDOM:0:3\}"; done \textgreater{}\textgreater{}phone.txt} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.88666 cm} x{2.09034 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Text Processing Hacks}} \tn % Row 0 \SetRowColor{LightBackground} diff -c & context format \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} diff -u & unified format \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} diff -Naur oldfile newfile \textgreater{} diff\_file & write the diff to diff file \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} patch \textless{} diff\_file & applied to oldfile directly. \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} echo "secret text" | tr a-zA-Z n-za-mN-ZA-M & frperg grkg | ROT13 Encoding \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} echo "frperg grkg" | tr a-zA-Z n-za-mN-ZA-M & secret text | ROT13 Decoding \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-, +, ! : deleted, added, line changes. \newline \newline \$diff -Naur file1.txt file2.txt \textgreater{} diff\_file.txt \newline \$patch \textless{} diff\_file.txt \newline patching file file1.txt \newline \newline rotate by 13 places (ROT13)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}