\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{TME520 (TME520)} \pdfinfo{ /Title (systemd.pdf) /Creator (Cheatography) /Author (TME520 (TME520)) /Subject (systemd 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}{A31A83} \definecolor{LightBackground}{HTML}{F9F0F7} \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{systemd Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{TME520 (TME520)} via \textcolor{DarkBackground}{\uline{cheatography.com/20978/cs/3849/}}} \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}TME520 (TME520) \\ \uline{cheatography.com/tme520} \\ \uline{\seqsplit{tme520}.com} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 8th April, 2015.\\ Updated 12th May, 2016.\\ 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{tabularx}{17.67cm}{x{3.8801 cm} x{5.061 cm} x{7.9289 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{System state}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Old command}} & {\bf{Systemd command}} & {\bf{Description}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} halt & systemctl halt & Halts the system. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} poweroff & systemctl poweroff & Powers off the system. \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} reboot & systemctl reboot & Restarts the system. \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{pm-suspend} & systemctl suspend & Suspends the system. \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{pm-hibernate} & systemctl hibernate & Hibernates the system. \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} \seqsplit{pm-suspend-hybrid} & systemctl \seqsplit{hybrid-sleep} & Hibernates and suspend the system. \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.0488 cm} x{6.4106 cm} x{6.4106 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Services management}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{SysVinit command}} & {\bf{Systemd command}} & {\bf{Notes}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} service httpd start & systemctl start httpd.service & Start a service (not reboot persistent). \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} service httpd stop & systemctl stop httpd.service & Stop a service (not reboot persistent). \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} service httpd restart & systemctl restart httpd.service & Restart a service. \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} service httpd reload & systemctl reload httpd.service & Reloads the configuration files without interrupting pending operations. \tn % Row Count 17 (+ 5) % Row 5 \SetRowColor{white} service httpd \seqsplit{condrestart} & systemctl condrestart httpd.service & Restarts if the service is already running. \tn % Row Count 20 (+ 3) % Row 6 \SetRowColor{LightBackground} service httpd status & systemctl status httpd.service & Shows the status of a service. \tn % Row Count 23 (+ 3) % Row 7 \SetRowColor{white} service -{}-status-all & systemctl list-units -{}-type=service & Displays the status of all services. \tn % Row Count 26 (+ 3) % Row 8 \SetRowColor{LightBackground} ls \seqsplit{/etc/rc.d/init.d/} & systemctl \seqsplit{list-unit-files} -{}-type=service & List the services that can be started or stopped. \tn % Row Count 30 (+ 4) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.0488 cm} x{6.4106 cm} x{6.4106 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Services management (cont)}} \tn % Row 9 \SetRowColor{LightBackground} \seqsplit{chkconfig} httpd on & systemctl enable httpd.service & Start service at next boot. \tn % Row Count 2 (+ 2) % Row 10 \SetRowColor{white} \seqsplit{chkconfig} httpd off & systemctl disable httpd.service & Service won't be started on next boot. \tn % Row Count 5 (+ 3) % Row 11 \SetRowColor{LightBackground} \seqsplit{chkconfig} httpd & systemctl is-enabled httpd.service & Check if a service is configured to start in the current environment. \tn % Row Count 10 (+ 5) % Row 12 \SetRowColor{white} \seqsplit{chkconfig} -{}-list & systemctl \seqsplit{list-unit-files} -{}-type=service {\emph{or}} ls \seqsplit{/etc/systemd/system/*}.wants/ & Print a list of services showing which runlevels they are configured for. \tn % Row Count 16 (+ 6) % Row 13 \SetRowColor{LightBackground} \seqsplit{chkconfig} httpd -{}-list & ls \seqsplit{/etc/systemd/system/*}.wants/httpd.service & Show which runlevels a service is configured for. \tn % Row Count 20 (+ 4) % Row 14 \SetRowColor{white} \seqsplit{chkconfig} httpd -{}-add & systemctl daemon-reload & Run this command after a change in any configuration file (old or new). \tn % Row Count 25 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Investigate}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Command}} & {\bf{Notes}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} systemctl get-default & Determine which target unit is used by default. \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} systemctl set-default multi-user.target & Change default boot target to multi-user.target. \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} journalctl -b & Show all messages from last boot. \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} journalctl -b -p err & Show all messages of priority level {\emph{ERROR}} and more from last boot. \tn % Row Count 13 (+ 4) % Row 5 \SetRowColor{white} journalctl -p warning -{}-since="2015-07-31 12:34:56" -{}-until="2015-09-19 23:59:59" & View the messages of priority level {\emph{WARNING}} or more from a certain date and time. \tn % Row Count 18 (+ 5) % Row 6 \SetRowColor{LightBackground} journalctl -f & Follow new messages {\emph{a la}} tail -f. \tn % Row Count 20 (+ 2) % Row 7 \SetRowColor{white} journalctl -u SERVICE & Show logs for SERVICE. \tn % Row Count 22 (+ 2) % Row 8 \SetRowColor{LightBackground} journalctl /usr/sbin/httpd & Show all messages related to a specific executable. \tn % Row Count 25 (+ 3) % Row 9 \SetRowColor{white} journalctl -{}-full & Display all messages without truncating any. \tn % Row Count 28 (+ 3) % Row 10 \SetRowColor{LightBackground} systemctl -{}-state=failed & Display the services that failed to start. \tn % Row Count 31 (+ 3) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Investigate (cont)}} \tn % Row 11 \SetRowColor{LightBackground} systemctl list-units -{}-type=target & Show current runlevel. \tn % Row Count 2 (+ 2) % Row 12 \SetRowColor{white} systemctl isolate graphical.target & Change the current runlevel (target). \tn % Row Count 4 (+ 2) % Row 13 \SetRowColor{LightBackground} systemctl rescue/emergency & Switch to Rescue (single user)/Emergency mode. \tn % Row Count 7 (+ 3) % Row 14 \SetRowColor{white} systemctl kill SERVICE.service & Gently kill SERVICE ({\emph{SIGTERM}}, 15). \tn % Row Count 9 (+ 2) % Row 15 \SetRowColor{LightBackground} systemd-cgls & Show the full systemd control group ({\emph{cgroup}}) hierarchy as a tree. \tn % Row Count 13 (+ 4) % Row 16 \SetRowColor{white} systemctl show -p "Wants" multi-user.target & Find out what other units does a unit depend on. \tn % Row Count 16 (+ 3) % Row 17 \SetRowColor{LightBackground} systemctl list-jobs & Show jobs. \tn % Row Count 17 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{3.5427 cm} x{6.5793 cm} x{6.748 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Runlevels}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{SysVinit runlevel}} & {\bf{Systemd target}} & {\bf{Notes}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} 0 & \seqsplit{runlevel0.target}, \seqsplit{poweroff.target} & Halt the system. \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} 1, s, single & \seqsplit{runlevel1.target}, rescue.target & Single user mode. \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} 2, 4 & \seqsplit{runlevel2.target}, \seqsplit{runlevel4.target}, \seqsplit{multi-user.target} & User-defined runlevels (identical to 3). \tn % Row Count 13 (+ 4) % Row 4 \SetRowColor{LightBackground} 3 & \seqsplit{runlevel3.target}, \seqsplit{multi-user.target} & Multi-user, non-graphical. \tn % Row Count 16 (+ 3) % Row 5 \SetRowColor{white} 5 & \seqsplit{runlevel5.target}, \seqsplit{graphical.target} & Multi-user, graphical. \tn % Row Count 19 (+ 3) % Row 6 \SetRowColor{LightBackground} 6 & \seqsplit{runlevel6.target}, reboot.target & Rebbot. \tn % Row Count 22 (+ 3) % Row 7 \SetRowColor{white} \seqsplit{emergency} & \seqsplit{emergency.target} & Emergency shell. \tn % Row Count 24 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \end{document}