\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{Boulard} \pdfinfo{ /Title (multipass-cli-2022-ubuntu-vms-on-demand-on-any-os.pdf) /Creator (Cheatography) /Author (Boulard) /Subject (Multipass CLI 2022, Ubuntu VMs on demand on any OS 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}{404040} \definecolor{LightBackground}{HTML}{F3F3F3} \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{Multipass CLI 2022, Ubuntu VMs on demand on any OS Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Boulard} via \textcolor{DarkBackground}{\uline{cheatography.com/125912/cs/34234/}}} \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}Boulard \\ \uline{cheatography.com/boulard} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 17th September, 2022.\\ Updated 21st September, 2022.\\ 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{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Create Instances}} \tn % Row 0 \SetRowColor{LightBackground} multipass launch & Creates an instance using a random name \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} multipass info \textless{}instance\textgreater{} & Get info about an instance \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} multipass find & find out what images are available \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} multipass launch \textless{}image\textgreater{} & launch an instance using the specified image \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} multipass launch \textless{}image\textgreater{} {[}-{}-name|-n{]} \textless{}instance\textgreater{} & launch an instance and name it \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} multipass launch {[}-{}-cpus|-c{]} 4 {[}-{}-disk,-d{]} 20G {[}-{}-mem,-m{]} 8G & Create an instance with custom CPU number, disk, and RAM \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} multipass launch \textless{}image\textgreater{} {[}-{}-name,-n{]} primary & An instance can obtain the primary status at creation time if its name is primary. A primary instance is the default argument for several commands, such as shell , start , stop , restart , and suspend and also automatically mounts our \$HOME directory in the instance. \tn % Row Count 29 (+ 14) % Row 7 \SetRowColor{white} multipass launch -{}-network en0 -{}-network name=bridge0,mode=manual & Create an instance specifying NICs. See https://multipass.run/docs/create-an-instance\#heading-{}-create-an-instance-with-multiple-network-interfaces \tn % Row Count 37 (+ 8) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{The -{}-network option can be given multiple times, each one requesting an additional network interface (beyond the default one, which is always present, used to reach the outside world and used by multipass to communicate with the instance). \newline \newline -{}-network takes at most 3 \textless{}key\textgreater{}=\textless{}value\textgreater{}: \newline name — the only required value, it identifies the network, \newline mode that is either manual or auto (try to auto join the net), \newline mac to specify a mac address for the NIC \newline \newline NIC: network interface controller} \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}{Create an instance with a custom DNS}} \tn % Row 0 \SetRowColor{LightBackground} multipass launch -{}-cloud-init \seqsplit{systemd-resolved.yaml} & Creates an instance with a custom DNS \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} after the instance booted use the netplan.io approach & https://multipass.run/docs/create-an-instance\#heading-{}-the-netplanio-approach \tn % Row Count 7 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{In some scenarios the default of using the system-provided DNS will not be sufficient. \newline \newline systemd-resolved.yaml cloud-init snippet: \newline \newline \#cloud-config \newline bootcmd: \newline - printf "{[}Resolve{]}\textbackslash{}nDNS=8.8.8.8" \textgreater{} \seqsplit{/etc/systemd/resolved.conf} \newline - {[}systemctl, restart, systemd-resolved{]} \newline \newline 8.8.8.8 is a Google DNS} \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}{Remove or delete an instance}} \tn % Row 0 \SetRowColor{LightBackground} multipass delete \textless{}instance\textgreater{} & Move an instance to the 'recycle bin' \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} multipass delete -{}-all & Move all instances to the 'recycle bin' \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} multipass recover \textless{}instance\textgreater{} & Recover an instance put to the 'recycle bin' \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} multipass delete -{}-purge \textless{}instance\textgreater{} & Permanently delete an instance \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} multipass purge & Empty the 'recycle bin' \tn % Row Count 12 (+ 2) \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}{Running a container with the Docker workflow}} \tn % Row 0 \SetRowColor{LightBackground} multipass launch docker & Creates a virtual machine running the latest version of Ubuntu, with Docker and Portainer installed. \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} multipass exec docker docker & Executes Docker in the instance \tn % Row Count 7 (+ 2) % Row 2 \SetRowColor{LightBackground} multipass alias docker:docker & Alias the docker command to our host command line. This will let us use the docker command as if Docker were running directly on our host machine.This command will return instructions showing how to add the new alias to our path. Simply copy and paste the command shown. It will likely be of this form: PATH="\$PATH:/home/\textless{}user\textgreater{}/snap/multipass/common/bin" \tn % Row Count 23 (+ 16) % Row 3 \SetRowColor{white} docker run hello-world & Works only if the alias is created. \tn % Row Count 25 (+ 2) % Row 4 \SetRowColor{LightBackground} multipass list & Shows the IP addresses associated with the created Ddocker VM. The Portainer IP should start with a 10. \tn % Row Count 30 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{3.36 cm} x{4.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Running a container with the Docker workflow (cont)}} \tn % Row 5 \SetRowColor{LightBackground} \seqsplit{http://10.portainer-ip:9000} & Shows the Portainer web interface. \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Portainer config \newline 1) Set username and password \newline 2) Select local docker env opt. and click connect \newline 3) Click on the newly created "Local" environment to manage the Docker instance on our local VM. \newline see \seqsplit{https://multipass.run/docs/docker-tutorial}} \tn \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}{Install}} \tn % Row 0 \SetRowColor{LightBackground} brew install bash-completion & install bash completion if not already installed \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} brew install -{}-cask multipass & -{}-cask option may be omitted \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} brew uninstall multipass & uninstall multipass \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} brew uninstall -{}-zap multipass & uninstall multipass and data \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} multipass version & to check the install and get the version \tn % Row Count 11 (+ 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}{Modify an instance}} \tn % Row 0 \SetRowColor{LightBackground} multipass set client.primary-name=\textless{}instance name\textgreater{} & Grant a regular instance the primary status \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} multipass set {[}local.\textless{}instance\textgreater{}.(cpus|disk|memory){]} & Change CPU RAM DISK \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{see \seqsplit{https://multipass.run/docs/modify-an-instance}} \tn \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}{Use an Instance}} \tn % Row 0 \SetRowColor{LightBackground} multipass shell \textless{}instance\textgreater{} & Open a shell prompt inside an instance \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} multipass exec \textless{}instance\textgreater{} -{}- \textless{}cmd\textgreater{} & Execute a command inside an instance \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} multipass start|suspend|stop \textless{}instance\textgreater{}{[} \textless{}instance\textgreater{}{]} & Start, suspend or stop instances \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} multipass start|suspend|stop -all & Start, suspend or stop all instances \tn % Row Count 9 (+ 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}{Aliases on Instances}} \tn % Row 0 \SetRowColor{LightBackground} multipass alias \textless{}instance\textgreater{}:\textless{}cmd\textgreater{} \textless{}alias\textgreater{} & defines an alias executed from the host, into the instance. ex: multipass alias proxy:ls lsproxy \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} multipass alias \textless{}instance\textgreater{}:\textless{}cmd\textgreater{} \textless{}alias\textgreater{} -{}-no-map-working-directory & Do not change the working directory on the instance to the mounted directory (in case the host folder on which executing an alias is mounted on the instance) \tn % Row Count 13 (+ 8) % Row 2 \SetRowColor{LightBackground} multipass aliases & list defined aliases and their instances \tn % Row Count 15 (+ 2) % Row 3 \SetRowColor{white} multipass \textless{}alias\textgreater{} & execute an alias \tn % Row Count 16 (+ 1) % Row 4 \SetRowColor{LightBackground} multipass unalias \textless{}alias\textgreater{}{[} \textless{}alias\textgreater{}{]} & remove aliases \tn % Row Count 18 (+ 2) % Row 5 \SetRowColor{white} multipass unalias -{}-all & remove all aliases \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Add the multipass bin folder to the path to use \textless{}alias\textgreater{} instead of multipass \textless{}alias\textgreater{}. \newline Arguments are also supported \newline \newline nano \textasciitilde{}/.bashrc \#linux \newline nano \textasciitilde{}/.zshhrc \#mac \newline PATH="\$PATH:/home/user/snap/multipass/common/bin"} \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}{Share data with an instance using "mount"}} \tn % Row 0 \SetRowColor{LightBackground} multipass mount \$HOME \textless{}instance\textgreater{} & /home/me will be available inside the instance. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} multipass mount \$HOME \textless{}instance\textgreater{}:\textless{}/instance/path\textgreater{} & Specifies the path inside the instance in which to mount the local path \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} multipass launch -{}-mount \textless{}/local/path\textgreater{}:multipass launch -{}-mount \seqsplit{/some/local/path:/instance/path} & Specifies mount on launch \tn % Row Count 12 (+ 5) % Row 3 \SetRowColor{white} multipass umount \textless{}instance\textgreater{} & Unmount all volumes from an instance \tn % Row Count 14 (+ 2) % Row 4 \SetRowColor{LightBackground} multipass umount \textless{}instance\textgreater{}:\textless{}/instance/path\textgreater{} & Unmount a specific volume from an instance \tn % Row Count 17 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{The recommended way to share data between your host and an instance with Multipass is the mount command} \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}{Share data with an instance using "transfer"}} \tn % Row 0 \SetRowColor{LightBackground} multipass transfer \textless{}instance\textgreater{}:\textless{}/instance/path/file1\textgreater{} \textless{}instance\textgreater{}:\textless{}/instance/path/file2\textgreater{} \textless{}/host/path\textgreater{} & Copy 2 files from the instance to the specified host path \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} multipass transfer \textless{}instance\textgreater{}:\textless{}/instance/path\textgreater{} \textless{}/host/path/file1\textgreater{} \textless{}/host/path/file2\textgreater{}\textless{}instance\textgreater{}:\textless{}/instance/path\textgreater{} & Copy 2 files from the host path to the specified instance path \tn % Row Count 11 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{use transfer to just copy files around. If a file is inside an instance, prefix its path with \textless{}instance name\textgreater{}:.} \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}{Miscellaneous}} \tn % Row 0 \SetRowColor{LightBackground} multipass exec primary -{}- bash -c 'echo "PasSwOrD" | docker secret create secret-pass -' & create a docker secret in the primary node without storing it \tn % Row Count 5 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}