\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{zebrahead} \pdfinfo{ /Title (linux.pdf) /Creator (Cheatography) /Author (zebrahead) /Subject (Linux 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}{171717} \definecolor{LightBackground}{HTML}{F7F7F7} \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 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{zebrahead} via \textcolor{DarkBackground}{\uline{cheatography.com/35093/cs/11017/}}} \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}zebrahead \\ \uline{cheatography.com/zebrahead} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 27th February, 2017.\\ Updated 27th February, 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.34379 cm} x{3.63321 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{File commands}} \tn % Row 0 \SetRowColor{LightBackground} ls & Directory listing \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ls -al & Formatted listing with hidden files \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} ls -F & list files in current directory and indicate the file tyoe \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} ls -laC & list all files in current directory in long format and display in columns \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} cd dir & Change directory to dir \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} pwd & Show current directory \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} mkdir dir & Create a directory dir \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} rm file & Delete file \tn % Row Count 12 (+ 1) % Row 8 \SetRowColor{LightBackground} rm -r dir & Delecte directory dir \tn % Row Count 13 (+ 1) % Row 9 \SetRowColor{white} rm -f file & Force remove file \tn % Row Count 14 (+ 1) % Row 10 \SetRowColor{LightBackground} rm -rf dir & For remove directory dir \tn % Row Count 15 (+ 1) % Row 11 \SetRowColor{white} cp file1 file2 & Copy file 1 to file2 \tn % Row Count 17 (+ 2) % Row 12 \SetRowColor{LightBackground} cp -r dir1 dir2 & Copy dir1 to dir2 \tn % Row Count 19 (+ 2) % Row 13 \SetRowColor{white} cp file path & copy the file to the dir \tn % Row Count 21 (+ 2) % Row 14 \SetRowColor{LightBackground} mv file1 file2 & Rename or move file to file2. \tn % Row Count 23 (+ 2) % Row 15 \SetRowColor{white} ln -s file link & Create symbolic link link to file \tn % Row Count 25 (+ 2) % Row 16 \SetRowColor{LightBackground} touch file & Create or update file \tn % Row Count 26 (+ 1) % Row 17 \SetRowColor{white} cat \textgreater{} file & Place standard input into file \tn % Row Count 28 (+ 2) % Row 18 \SetRowColor{LightBackground} more file & Output the contents of file \tn % Row Count 29 (+ 1) % Row 19 \SetRowColor{white} head file & Output the first 10 kines of file \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.34379 cm} x{3.63321 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{File commands (cont)}} \tn % Row 20 \SetRowColor{LightBackground} tail file & output the last 10 lines of file \tn % Row Count 2 (+ 2) % Row 21 \SetRowColor{white} tail -f file & Output the contents of file as it grows, starting with the last 10 lines \tn % Row Count 5 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{File Permissions}} \tn % Row 0 \SetRowColor{LightBackground} chmod octal file & 4 - read(r) 2 - write(w) 1 - execute(x) \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{For more options, see man chmod.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Seacrching}} \tn % Row 0 \SetRowColor{LightBackground} grep pattern files & search for pattern in files \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} grep -r pattern dir & search recursively for pattern in dir \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} command | grep pattern & search for pattern in the output of command \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} locate file & find all instances of file \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.14471 cm} x{3.83229 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Process Managment}} \tn % Row 0 \SetRowColor{LightBackground} ps & display all currently active processes \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} top & display all runing processes \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} kill pid & kill process id pid \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} killall proc & kill all processes named proc * \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} bg & lists stopped or background jobs; resume a stopped job in the background \tn % Row Count 9 (+ 3) % Row 5 \SetRowColor{white} fg & brings the most recent job to the foreground \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} fg a & brings job a to the foreground \tn % Row Count 12 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.4931 cm} x{3.4839 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{System Info}} \tn % Row 0 \SetRowColor{LightBackground} date & show the current date and time \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cal & show this month's calendar \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} uptime & show current uptime \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} w & display who is online \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} whoami & who you are logged in as \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} finger user & display information about user \tn % Row Count 8 (+ 2) % Row 6 \SetRowColor{LightBackground} uname -a & show kernel information \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} \seqsplit{cat/proc/cpuinfo} & cpu information \tn % Row Count 11 (+ 2) % Row 8 \SetRowColor{LightBackground} \seqsplit{cat/proc/meminfo} & memory information \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} man command & show the manual for command \tn % Row Count 14 (+ 1) % Row 10 \SetRowColor{LightBackground} df & show disk usage \tn % Row Count 15 (+ 1) % Row 11 \SetRowColor{white} du & show direcory space usage \tn % Row Count 16 (+ 1) % Row 12 \SetRowColor{LightBackground} free & show memmory and swap usage \tn % Row Count 17 (+ 1) % Row 13 \SetRowColor{white} whereis app & show possible locations of app \tn % Row Count 19 (+ 2) % Row 14 \SetRowColor{LightBackground} which app & show which app will be run by default \tn % Row Count 21 (+ 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}{Compression}} \tn % Row 0 \SetRowColor{LightBackground} tar cf file.tar files & create a tar named file.tar containing files \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} tar xf file.tar & extract the file from file.tar \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} tar czf file.tar.gz files & create a tar with Gzip compression \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} tar xzf file.tar.gz & extract a tar using Gzip \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} tar cjf file.tar.bz2 & create a tar with Bzip2 compression \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} tar xjf file.tar.bz2 & extract a tar using Bzip2 \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} gzip file & compresses file and renames it to file.gz \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} gzip -d file.gz & decompresses file.gz back to file \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{tag flags: \newline c - create archive \newline j - bzip2 compression \newline t - table of contents \newline k - do not overwrite \newline x - extract \newline T - files from file \newline f - specifies filename \newline w - ask for confirmation \newline z - use zip/gzip v - verbose} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.69218 cm} x{3.28482 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{SSH}} \tn % Row 0 \SetRowColor{LightBackground} ssh user@host & connect to host as user \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ssh -p port user@host & connect to host on port port as uset \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} ssh-copy-id user@host & add your key to host for user to enable a keyed or passwordless login \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.34379 cm} x{3.63321 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Network}} \tn % Row 0 \SetRowColor{LightBackground} ping host & ping host and outpt result \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} shois domain & get whois information for domain \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} dig domain & get DNS information for domain \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} dig -x host & reverse lookup host \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} wget file & download file \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} wget -c file & continue a stopped download \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.34379 cm} x{3.63321 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Starting \& Stopping}} \tn % Row 0 \SetRowColor{LightBackground} sd -h no & shutdown system now and do not reboot \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} halt & stop all processes - same as above \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} shutdown -r 5 & shutdown the system in 5 minutes and reboot \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} shutdown -r now & shutdown the system now and reboot \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} rebot & stop all processes and then reboot \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} startx & start the x system \tn % Row Count 11 (+ 1) \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}{Shortcuts}} \tn % Row 0 \SetRowColor{LightBackground} {\emph{Ctrl+C}} & halts the current command \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\emph{Ctrl+Z}} & stops the current command, resume with fg in the foreground or bg in the background \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} {\emph{Ctrl+D}} & log put of current session, similar to exit \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} {\emph{Ctrl+W}} & erases one word in the current lint \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} {\emph{Ctrl+U}} & erases he whole line \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} {\emph{Ctrl+R}} & type to bring up a recent command \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} !! & repats the last command \tn % Row Count 14 (+ 1) % Row 7 \SetRowColor{white} {\emph{exit}} & log ot of current session \tn % Row Count 15 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}