\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{idan\_shm} \pdfinfo{ /Title (linux-cheat-sheet-centos-fedora-based.pdf) /Creator (Cheatography) /Author (idan\_shm) /Subject (Linux \textless{}CentOS/Fedora based\textgreater{} 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}{9393A3} \definecolor{LightBackground}{HTML}{F8F8F9} \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 \textless{}CentOS/Fedora based\textgreater{} Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{idan\_shm} via \textcolor{DarkBackground}{\uline{cheatography.com/39583/cs/12287/}}} \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}idan\_shm \\ \uline{cheatography.com/idan-shm} \\ \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 17th July, 2017.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{x{3.2 cm} x{4.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Built-in manuals and info}} \tn % Row 0 \SetRowColor{LightBackground} man \textless{}Command\textgreater{}\{\{nobreak\}\} & Show manual for the command \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} info \textless{}Command\textgreater{}\{\{nobreak\}\} & Show wide info about the command (Can be secondary to man) \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \textless{}Command\textgreater{} -{}-help\{\{nobreak\}\} & Short command/tool usage \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.44 cm} x{4.56 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{System info}} \tn % Row 0 \SetRowColor{LightBackground} uname -a\{\{nobreak\}\} & Show system and kernel version \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} history\{\{nobreak\}\} & Show current user bash commands history \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} date\{\{nobreak\}\} & Show current date and time \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} cal\{\{nobreak\}\} & Show calendar \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} uptime\{\{nobreak\}\} & Show system uptime \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} df -h\{\{nobreak\}\} & Show all mounted file systems \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} du -h \textless{}Path\textgreater{}\{\{nobreak\}\} & Show disk usage, to get better understanding what is taking all the disk space \tn % Row Count 14 (+ 4) % Row 7 \SetRowColor{white} free -h\{\{nobreak\}\} & Show available memory and usage \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} which \textless{}Command\textgreater{}\{\{nobreak\}\} & Show the binary/script location if it is under the \$PATH \tn % Row Count 19 (+ 3) % Row 9 \SetRowColor{white} top\{\{nobreak\}\} & Show running processes on realtime \tn % Row Count 21 (+ 2) % Row 10 \SetRowColor{LightBackground} ps -aux\{\{nobreak\}\} & Capture all running processes and print in terminal \tn % Row Count 24 (+ 3) % Row 11 \SetRowColor{white} dmesg\{\{nobreak\}\} & Print or control the kernel ring buffer \tn % Row Count 26 (+ 2) % Row 12 \SetRowColor{LightBackground} cat /var/log/syslog\{\{nobreak\}\} & Show system logs \tn % Row Count 28 (+ 2) % Row 13 \SetRowColor{white} journalctl\{\{nobreak\}\} & Query the systemd journal \tn % Row Count 30 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.24 cm} x{5.76 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Bash Variables}} \tn % Row 0 \SetRowColor{LightBackground} env & Show environment variables \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} echo \$HOME & Home directory \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} echo \$PATH & Executable search path \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} echo \$SHELL & Current shell \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Navigation}} \tn % Row 0 \SetRowColor{LightBackground} cd \textless{}Path\textgreater{}\{\{nobreak\}\} & Change directory\{\{nobreak\}\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} pwd\{\{nobreak\}\} & Present/print working directory\{\{nobreak\}\} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} ls\{\{nobreak\}\} & List directory contents\{\{nobreak\}\} \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} ls -la\{\{nobreak\}\} & Long list directory contents \{\{nl\}\}and hidden files and wide info\{\{nobreak\}\} \tn % Row Count 11 (+ 4) % Row 4 \SetRowColor{LightBackground} find /home/user -name '*.txt'\{\{nobreak\}\} & Search and print\{\{nl\}\} all the .txt files \{\{nl\}\}under the user directory\{\{nobreak\}\} \tn % Row Count 16 (+ 5) % Row 5 \SetRowColor{white} mount & show or mount filesystems \tn % Row Count 18 (+ 2) % Row 6 \SetRowColor{LightBackground} umount & unmount file systems \tn % Row Count 19 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.44 cm} x{4.56 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{File manipulation}} \tn % Row 0 \SetRowColor{LightBackground} touch\{\{nobreak\}\} & Update the file last modification date, if the file does not exist, touch will create a new file \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} cp\{\{nobreak\}\} & Copy files \tn % Row Count 6 (+ 1) % Row 2 \SetRowColor{LightBackground} mv\{\{nobreak\}\} & Move files, also used to rename a file \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} rm\{\{nobreak\}\} & Delete files or directories ( can be used with -r for recursive) \tn % Row Count 11 (+ 3) % Row 4 \SetRowColor{LightBackground} mkdir\{\{nobreak\}\} & Create new directory \tn % Row Count 12 (+ 1) % Row 5 \SetRowColor{white} rmdir\{\{nobreak\}\} & Delete directory (Only if empty) \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} chmod\{\{nobreak\}\} & Change file mode/permissions r=4 w=2 x=1 \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} chown \textless{}owner:group\textgreater{}\{\{nobreak\}\} & Change file ownership \tn % Row Count 18 (+ 2) % Row 8 \SetRowColor{LightBackground} cat\{\{nobreak\}\} & Print file content \tn % Row Count 19 (+ 1) % Row 9 \SetRowColor{white} head\{\{nobreak\}\} & Show first 10 lines of a file \tn % Row Count 21 (+ 2) % Row 10 \SetRowColor{LightBackground} tail\{\{nobreak\}\} & Show last 10 lines of a file \tn % Row Count 23 (+ 2) % Row 11 \SetRowColor{white} tail -F\{\{nobreak\}\} & Output last lines of the file as it changes \tn % Row Count 25 (+ 2) % Row 12 \SetRowColor{LightBackground} file\{\{nobreak\}\} & Show info about the file such as file type \tn % Row Count 27 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Users and groups management}} \tn % Row 0 \SetRowColor{LightBackground} whoami\{\{nobreak\}\} & Show current user \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} sudo adduser \textless{}Username\textgreater{}\{\{nobreak\}\} & Create a new user \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} sudo userdel -rf \textless{}Username\textgreater{}\{\{nobreak\}\} & Delete user ( Including the home directory ) \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} sudo passwd \textless{}Username\textgreater{}\{\{nobreak\}\} & Change user password \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} id\{\{nobreak\}\} & Show user uid, groups and info \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} who\{\{nobreak\}\} & Show current logged in users \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} sudo usermod -aG \textless{}Group\textgreater{} \textless{}User\textgreater{}\{\{nobreak\}\} & Add user to group \tn % Row Count 15 (+ 3) % Row 7 \SetRowColor{white} sudo groupdel \textless{}Group\textgreater{}\{\{nobreak\}\} & Delete group \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} cat /etc/group\{\{nobreak\}\} & List all groups \tn % Row Count 19 (+ 2) % Row 9 \SetRowColor{white} cat /etc/passwd\{\{nobreak\}\} & List all users \tn % Row Count 21 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} p{0.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Disk utils}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.32 cm} x{5.68 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{IO Redirection}} \tn % Row 0 \SetRowColor{LightBackground} cmd \textless{} file & Input to cmd from file \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} cmd1 \textless{}(cmd2) & Output of cmd2 as file input to cmd1 \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} cmd \textgreater{} file & stdout of cmd to file \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} cmd \textgreater{} /dev/null & Discard stdout of cmd \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} cmd \textgreater{}\textgreater{} file & Append stdout to file \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} cmd 2\textgreater{} file & stderr of cmd to file \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} cmd 1\textgreater{}\&2 & stdout to same place as stderr \tn % Row Count 10 (+ 2) % Row 7 \SetRowColor{white} cmd 2\textgreater{}\&1 & stderr to same place as stdout \tn % Row Count 12 (+ 2) % Row 8 \SetRowColor{LightBackground} cmd \&\textgreater{} file & Every output of cmd to file \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{cmd = Command \newline stdout = Standard output \newline stderr = Error output} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.52 cm} x{4.48 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Package management}} \tn % Row 0 \SetRowColor{LightBackground} dnf upgrade\{\{nobreak\}\} & Upgrade a package or packages on your system \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} dnf search \textless{}Package\textgreater{}\{\{nobreak\}\} & Search package details for the given string \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} dnf remove \textless{}Package\textgreater{}\{\{nobreak\}\} & Remove a package or packages from your system \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} dnf repolist\{\{nobreak\}\} & Display the configured software repositories \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} rpm -i \textless{}Package\textgreater{}\{\{nobreak\}\} & Install rpm package \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} rpm -e \textless{}Package\textgreater{}\{\{nobreak\}\} & Uninstall rpm package \tn % Row Count 13 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Networking}} \tn % Row 0 \SetRowColor{LightBackground} ifconfig -a\{\{nobreak\}\} & Show all network interfaces and more \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} netstat\{\{nobreak\}\} & Print network connections, routing tables, interface statistics, masquerade connections, and multi-cast memberships \tn % Row Count 7 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} x{7.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{VIM Editor}} \tn % Row 0 \SetRowColor{LightBackground} & Delete character \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.36 cm} x{4.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{VIM Editor}} \tn % Row 0 \SetRowColor{LightBackground} :x + enter\{\{nobreak\}\} & Save and quit \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} :q! + enter\{\{nobreak\}\} & exit, discard changes \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} x\{\{nobreak\}\} & Delete character \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} i\{\{nobreak\}\} & Insert text \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} a\{\{nobreak\}\} & append text \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} dw\{\{nobreak\}\} & Delete word \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} d\$\{\{nobreak\}\} & Delete to the end of the line \tn % Row Count 10 (+ 2) % Row 7 \SetRowColor{white} 0 (Zero) & Move to the start of the line \tn % Row Count 12 (+ 2) % Row 8 \SetRowColor{LightBackground} 2w & Jump 2 words \tn % Row Count 13 (+ 1) % Row 9 \SetRowColor{white} d2w & Delete 2 words \tn % Row Count 14 (+ 1) % Row 10 \SetRowColor{LightBackground} dd & Delete a whole line \tn % Row Count 15 (+ 1) % Row 11 \SetRowColor{white} 2dd & Delete 2 whole lines \tn % Row Count 16 (+ 1) % Row 12 \SetRowColor{LightBackground} u & Undo previous actions \tn % Row Count 17 (+ 1) % Row 13 \SetRowColor{white} U & Undo all the changes on a line \tn % Row Count 19 (+ 2) % Row 14 \SetRowColor{LightBackground} CTRL-R & Undo the undo's \tn % Row Count 20 (+ 1) % Row 15 \SetRowColor{white} r & Replace character \tn % Row Count 21 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}