\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{fbottarelli} \pdfinfo{ /Title (linux-for-dba-1.pdf) /Creator (Cheatography) /Author (fbottarelli) /Subject (Linux for DBA - 1 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}{C43939} \definecolor{LightBackground}{HTML}{FBF2F2} \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 for DBA - 1 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{fbottarelli} via \textcolor{DarkBackground}{\uline{cheatography.com/177260/cs/37008/}}} \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}fbottarelli \\ \uline{cheatography.com/fbottarelli} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 7th March, 2023.\\ Updated 7th March, 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*}{2} \begin{tabularx}{8.4cm}{x{3.12 cm} x{4.88 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Basic}} \tn % Row 0 \SetRowColor{LightBackground} man \textless{}command name\textgreater{} & help about the command \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \textless{}command A\textgreater{} | \textless{}command B\textgreater{} & send output of A in input to B \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \textless{}nomecomando\textgreater{} \& & execute in background \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} jobs & show all the background \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} nohub \textless{}comando\textgreater{} \textless{}filename\textgreater{} & launch and protect the process \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} w & show the session \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} fg \%1 & return to foreground \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} cat \textless{}filename\textgreater{} & print the content of file in the terminal \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.2 cm} x{4.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{File navigation and Basic Operations}} \tn % Row 0 \SetRowColor{LightBackground} pwd & print working directory \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} cd \textless{}path\textgreater{} & change driectory to \textless{}path\textgreater{} cd \textasciitilde{} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} ls -lrt & directory file list with details \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} touch & create a file \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} mv \textless{}path1+filename\textgreater{} \textless{}path2\textgreater{} & move the file in path1 to path2, it can used to rename file \tn % Row Count 9 (+ 3) % Row 5 \SetRowColor{white} cp \textless{}path1+filename\textgreater{} \textless{}path2\textgreater{} & copy, same as above \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} file \textless{}filename\textgreater{} & show the file-type \tn % Row Count 12 (+ 1) % Row 7 \SetRowColor{white} ls -lrt \textless{}filename\textgreater{} & details about the file \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{stat \textless{}filename\textgreater{}} \tn % Row Count 15 (+ 1) % Row 9 \SetRowColor{white} tail -f & show last rows of the file and keep update (live mnonitoring) \tn % Row Count 18 (+ 3) % Row 10 \SetRowColor{LightBackground} vi \textless{}filname\textgreater{} & open the file with vi editor \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.72 cm} x{3.28 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{File Permission}} \tn % Row 0 \SetRowColor{LightBackground} chmod \textless{}nmz\textgreater{} \textless{}filename\textgreater{} & update the file permission \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} chown \textless{}new owner username\textgreater{} \textless{}filename\textgreater{} & update file owner \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} umask & show default mask \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.08 cm} x{3.92 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Main Directories}} \tn % Row 0 \SetRowColor{LightBackground} /etc & configuration files \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} /var/log & log files \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} /tmp & temp. files \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} /home/\textless{}user\textgreater{} & home directory \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} which \textless{}command name\textgreater{} & find an executable \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.24 cm} x{3.76 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{PC details and monitoring}} \tn % Row 0 \SetRowColor{LightBackground} cat /proc/meminfo & ram info \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} cat /proc/cpuinfo & cpu info \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} lshw & other info about the PC \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} memstat 1 & real time of values \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} vmstat 1 & Virtual memory stat. \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} iostat 1 & IO metrics, realtime \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} iotop & similar to iostat \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} top or htop (if installed) & show resources \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} ipcs -m & processes shared memory \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.12 cm} x{4.88 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Processes}} \tn % Row 0 \SetRowColor{LightBackground} ps -ef & show processes \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ps aux & alternative version, useful for mem . info \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} top or htop (if installed) & show resources \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} ipcs -m & processes shared memory \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} kill \textless{}PID\textgreater{} & kill a process \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} lsof & tands for LiSt Open Files and shows open files and which process uses them \tn % Row Count 11 (+ 4) % Row 6 \SetRowColor{LightBackground} lsof -Pp \textless{}pid\textgreater{} & file list used by the process \textless{}pid\textgreater{} \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} lsof -Pp \textless{}pid\textgreater{} | grep log & search for the log related to \textless{}pid\textgreater{} \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.92 cm} x{4.08 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Environments}} \tn % Row 0 \SetRowColor{LightBackground} env & display environments variables \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \textless{}variable name\textgreater{} = \textless{}var. content\textgreater{} & set a shell variable \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} export \textless{}variable name\textgreater{} = \textless{}var. content\textgreater{} & create subshell with env variables \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} source \textless{}file name\textgreater{} & akes available the variable in the file for the current shell \tn % Row Count 11 (+ 4) % Row 4 \SetRowColor{LightBackground} echo \$\{\textless{}variable name\textgreater{}\} & display the variables content \tn % Row Count 13 (+ 2) % Row 5 \SetRowColor{white} export \textless{}variable name\textgreater{} & send the variable to the subshells \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}