\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{doublehelix} \pdfinfo{ /Title (ubuntu-18-04-server-configuration.pdf) /Creator (Cheatography) /Author (doublehelix) /Subject (Ubuntu 18.04 Server Configuration 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}{E95420} \definecolor{LightBackground}{HTML}{FDF4F1} \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{Ubuntu 18.04 Server Configuration Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{doublehelix} via \textcolor{DarkBackground}{\uline{cheatography.com/27391/cs/19030/}}} \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}doublehelix \\ \uline{cheatography.com/doublehelix} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 13th March, 2019.\\ Updated 9th April, 2019.\\ 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} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Ubuntu Server 18.04}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/doublehelix_1552453703_ubuntu_black-orange_hex.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{5.28 cm} x{2.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{apt - Advanced Packaging Tool}} \tn % Row 0 \SetRowColor{LightBackground} Update available packages & `sudo apt update` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Upgrades all currently installed packages & `sudo apt upgrade` \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Remove packages that are no longer required & `sudo apt autoremove` \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\seqsplit{http://manpages.ubuntu.com/manpages/cosmic/man8/apt.8.html}} \tn \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}{ufw - Uncomplicated Firewall}} \tn % Row 0 \SetRowColor{LightBackground} 1. Install ufw & `sudo apt install ufw` \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 2 Setup default policies & `sudo ufw default deny incoming` \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} & `sudo ufw default allow outgoing` \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} 3. Allow SSH & `sudo ufw allow 22` \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} ...or & `sudo ufw allow ssh` \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} 4. Enable ufw & `sudo ufw enable` \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{5. Allow other connections} \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} ...Apache & `sudo ufw allow 'Apache Full'` \tn % Row Count 11 (+ 2) % Row 8 \SetRowColor{LightBackground} ...Webmin & `sudo ufw allow 10000` \tn % Row Count 12 (+ 1) % Row 9 \SetRowColor{white} View current ufw status & `sudo ufw status verbose` \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\seqsplit{https://help.ubuntu.com/community/UFW} \newline or \newline https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-18-04} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Install Webmin}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{1. Edit the {\bf{sources}} list} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`sudo nano /etc/apt/sources.list`} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Add the following line to your sources file} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`deb \seqsplit{https://download.webmin.com/download/repository} sarge contrib`} \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{2. Download the Webmin PGP key} \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`wget \seqsplit{http://www.webmin.com/jcameron-key.asc} `} \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{3. Install the Webmin PGP key} \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`sudo apt-key add jcameron-key.asc`} \tn % Row Count 9 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{4. Update packages including the Webmin repository} \tn % Row Count 10 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`sudo apt update`} \tn % Row Count 11 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{5. Install Webmin} \tn % Row Count 12 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`sudo apt install webmin`} \tn % Row Count 13 (+ 1) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Once the installation finishes, you'll be presented with the following output:} \tn % Row Count 15 (+ 2) % Row 13 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Webmin install complete. You can now login to \seqsplit{https://your\_server\_ip:10000} as root with your root password, or as any user who can use `sudo`.} \tn % Row Count 18 (+ 3) % Row 14 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Add port 10000 to your firewall} \tn % Row Count 19 (+ 1) % Row 15 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`sudo ufw allow 10000`} \tn % Row Count 20 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\seqsplit{https://www.digitalocean.com/community/tutorials/how-to-install-webmin-on-ubuntu-18-04} \newline or \newline http://www.webmin.com/deb.html} \tn \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}{Install Apache 2.4}} \tn % Row 0 \SetRowColor{LightBackground} Install Apache 2.x & `sudo apt install apache2` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ... or, as a single command & `sudo apt update \&\& apt-get install apache2` \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} Enable ports through `ufw` firewall & `sudo ufw allow http \&\& ufw allow https` \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} ... or, via pre-defined app settings & `sudo ufw allow 'Apache Full'` \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} Start Apache & `sudo apachectl start` \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} Restart Apache after changing settings & `sudo apachectl restart` \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} Where is Apache installed & `which apache2` \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\seqsplit{https://help.ubuntu.com/lts/serverguide/httpd.html} \newline or \newline https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04} \tn \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}{Install PHP}} \tn % Row 0 \SetRowColor{LightBackground} 1. Install PHP & `sudo apt install php libapache2-mod-php` \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} 2. Restart Apache & `sudo systemctl restart apache2` \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} Check where PHP is installed & `which php` \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} Check PHP version & `php -v` \tn % Row Count 8 (+ 1) % Row 4 \SetRowColor{LightBackground} Check INI file configuration & `php -{}-ini` \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} Dump PHP configuration & `php -{}-info` \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} Install optional modules & `apt-get install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php` \tn % Row Count 19 (+ 7) % Row 7 \SetRowColor{white} check all the PHP modules available in Ubuntu & `apt-cache search -{}-names-only \textasciicircum{}php` \tn % Row Count 22 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\seqsplit{https://help.ubuntu.com/lts/serverguide/php.html.en-AU} \newline or \newline https://thishosting.rocks/install-php-on-ubuntu/} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.76 cm} x{4.24 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Install MySQL}} \tn % Row 0 \SetRowColor{LightBackground} Install MySQL & `sudo apt install mysql-server` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{Once the installation is complete, the MySQL server should be started automatically.} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Check the status of MySQL & `sudo netstat -tap | grep mysql` \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Start the service (if not running) & `sudo systemctl restart mysql.service` \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\seqsplit{https://help.ubuntu.com/lts/serverguide/mysql.html.en} \newline or \newline https://www.digitalocean.com/community/tutorials/how-to-install-the-latest-mysql-on-ubuntu-18-04} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.68 cm} x{4.32 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Install MongoDB}} \tn % Row 0 \SetRowColor{LightBackground} Install MongoDB package & `sudo apt install -y mongodb-org` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Check MongoDB service status & `sudo systemctl status mongodb` \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Start MongoDB & `sudo systemctl start mongod.service` \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Stop MongoDB & `sudo systemctl stop mongod.service` \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} Restart the MongoDB service & `sudo systemctl restart mongodb` \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} Enable automatic service startup & `sudo systemctl enable mongod.service` \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} Disable automatic service startup & `sudo systemctl disable mongodb` \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\seqsplit{https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-18-04} \newline or \newline https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ \newline or \newline https://websiteforstudents.com/install-mongodb-on-ubuntu-18-04-lts-beta-server/} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}