\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{nhatlong0605} \pdfinfo{ /Title (lfcs-module6-serviceconfiguration.pdf) /Creator (Cheatography) /Author (nhatlong0605) /Subject (LFCS\_Module6\_ServiceConfiguration 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}{1D41A3} \definecolor{LightBackground}{HTML}{F0F3F9} \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{LFCS\_Module6\_ServiceConfiguration Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{nhatlong0605} via \textcolor{DarkBackground}{\uline{cheatography.com/68292/cs/17258/}}} \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}nhatlong0605 \\ \uline{cheatography.com/nhatlong0605} \\ \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 September, 2018.\\ Updated 16th November, 2018.\\ 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.44 cm} x{4.56 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Web Services}} \tn % Row 0 \SetRowColor{LightBackground} systemctl start httpd & Start the Apache web service \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} vim \seqsplit{/etc/httpd/conf/httpd}.conf & Main config file for Apache \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{/etc/httpd/conf.d} & Additional config, drop any addtional here \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{/etc/httpd/conf.modules.d} & Addtional config \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Squid Proxy}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{yum install squid \newline vim /etc/squid/squid.conf \newline systemctl enable -{}-now squid \newline \newline \#Configure browser \newline Preferences -\textgreater{} Advanced -\textgreater{} Network -\textgreater{} Settings -\textgreater{} Manual: 192.168.4.240 port 3128} \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}{Virtual Hosts}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{- vim /etc/hosts; Create name resolution \newline % Row Count 1 (+ 1) - cd /etc/httpd/conf.d/; vim account.example.com.conf : Create virtual host w/ content \newline % Row Count 3 (+ 2) \textless{}VirtualHost *:80\textgreater{} \newline % Row Count 4 (+ 1) ServerAdmin \seqsplit{webmaster@account.example.com} \newline % Row Count 5 (+ 1) DocumentRoot /web/account \newline % Row Count 6 (+ 1) ServerName account.example.com \newline % Row Count 7 (+ 1) \textless{}/VirtualHost\textgreater{} \newline % Row Count 8 (+ 1) - mkdir /web/account; cd /web/account; vim index.html : Create index file% Row Count 10 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.52 cm} x{4.48 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{FTP Server}} \tn % Row 0 \SetRowColor{LightBackground} yum install vsftpd & Install Very Secure ftp \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} /etc/vsftpd & Main config file \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} yum install lftp & Install ftp client \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} lftp localhost & Connect to ftp \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Configure Postfix}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\#Email delivery \newline vim /etc/postfix/main.cf \newline relayhost = {[}192.168.4.200{]} \newline relay\_domains = \$mydestination \newline \newline \#Email Receiving \newline vim /etc/postfix/main.cf \newline myorigin = \$myhostname \newline mynetworks = 192.168.0.0/16 \newline inet\_protocols = ipv4 \newline inet\_interfaces = all \newline mydestination = ...., \seqsplit{hash:/etc/postfix/transport} \newline \newline \#setting transport \newline vim /etc/postfix/transport \newline example.com local: \newline .example.com local: \newline \newline \#update transport table \newline postmap /etc/postfix/transport} \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}{Configure an IMAP service}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{yum install dovecot \newline vim /etc/dovecot.conf \newline protocols = imap pop3 \newline vim \seqsplit{/etc/dovecot/conf.d/10-mail.conf} \newline mail\_location = mbox:\textasciitilde{}/mail:INBOX=/var/mail/\%u \newline mail\_privileged\_group = mail \newline vim \seqsplit{/etc/dovecot/conf.d/10-ssl.conf} \newline ssl\_cert = \textless{}/etc/pki/dovecot/certs/dovecot.pem \newline ssl\_key = \textless{}/etc/pki/dovecot/private/dovecot.pem \newline dovecot -n} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Message Transport Agent – MTA: mail relay, Postfix \newline Mail User Agent – MUA: Gmail, Outbook, Thunderbird \newline Mail Delivery Agent - MDA: Dovecot} \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}{Setting Up Email Services}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\#Email aliases \newline vim /etc/postfix/aliases \newline user1: user1, user2 \newline postalias /etc/postfix/aliases reload configuration \newline \newline \#parameters \newline myorigin \newline inet\_interfaces = yourIP, localhost \newline mydestination = \$myhostname, localhost.\$mydomain, localhost, \$mydomain \newline \newline \#Send email to test \newline echo "This is a test" | mail -s "test" root@example.com \newline \newline \#Check \newline mail} \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}{Cache-only DNS Server}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{yum install unbound \newline systemctl enable -{}-now unbound \newline iptables -A INPUT -p udp/tcp -dport 53 -j ACCEPT \newline vim \seqsplit{/etc/unbound/unbound.conf} \newline \# interface: 0.0.0.0 \newline \# access-control: 192.168.0.0/16 allow \newline \#domain-insecure: "example.com" \newline \# forward-zone: \newline name: "." \newline forward-addr: 8.8.8.8 \newline systemctl restart unbound \newline netstat -tulpen (Show listening port)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.8 cm} x{3.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Database}} \tn % Row 0 \SetRowColor{LightBackground} yum install mariadb & Install Mariadb \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{mysql\_secure\_installation} & Interactive setup for Mysql \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} mysql -u root -p & Login mysql using root \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} create database {\emph{dbname}} & Create database \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} use people; create table users(firstname varchar(20),....); & Create table \tn % Row Count 9 (+ 3) % Row 5 \SetRowColor{white} insert into user(...) values(...); & Insert values \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} select * from users & Show table \tn % Row Count 12 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Configure NFS Server}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{mkdir /nfsshare (Create folder for NFS) \newline chown nfsnobody:nfsnobody /nfsshare (Change owner to special nfsnobody user) \newline chmod 755 /nfsshare \newline \newline vim /etc/exports \newline /share *(rw,no\_root\_squash) \newline \newline systemctl enable -{}-now nfs-server \newline systemctl enable -{}-now rpcbind \newline systemctl enable -{}-now nfs-idmap \newline \newline \#Mounting NFS Share persistently \newline ssh into remote client \newline yum install nfs-utils (install nfs utilities) \newline mkdir -p /mnt/remote (Create mount point) \newline mount -t nfs ServerIP:/share /mnt/remote (Mount) \newline vim /etc/fstab \newline \#centos:/share /centos/nfs nfs \_netdev 0 0\textbackslash{} \newline umount /centos/nfs \newline mount -a} \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}{Configure Samba Server}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{yum install samba \newline mv \seqsplit{/etc/samb/smb.conf.example} /etc/samba/smb.conf (Overwrite) \newline vim /etc/samba/smb.conf (Create a samba share) \newline {[}share{]} \newline comment = samba share \newline path = /samba \newline public = yes \newline mkdir /samba \newline semanage fcontext -a -t samba\_share\_t /samba \newline restorecon -Rv /samba \newline systemctl start smb \newline \newline \#Create samba user \newline smbpasswd -a anna \newline \newline \#smb client \newline yum install smbclient \newline smbclient -L localhost \newline \newline \#Mount smb persistently \newline mount -o username=anna //centos/share /mnt \newline yum install clifs-utils (Install additonal utils) \newline mkdfir /centos/samba \newline vim /etc/fstab \newline //centos/samba /centos/samba cifs \newline \_netdev,username=anna,password=password 0 0} \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}{KVM}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{yum group install "Virtualization Host" or yum install qemu-kvm libvirt libvirt-client virt-install virt-viewer virt-manager \newline systemctl start libvirtd \newline virt (Start Virtual manger) \newline \newline \# \newline virsh list (Show available VMs) \newline virsh list -{}-all (Show all VMs) \newline virsh start {\emph{VM name}} \newline virsh stop {\emph{VM name}} \newline virsh autostart {\emph{VM name}} (Autostart after the host reboot) \newline virsh autostart -{}-disable {\emph{VMname}} (Disable autostart) \newline \newline \newline virt-install -{}-name=VM1 -{}-vcpus=1 -{}-memory=1024 -{}-cdrom=isoimage \newline virsh edit VM1 (Edit VM1 virtual machine) \newline virt-clone -{}-original=VM1 -{}-name=VM2 -{}-file=/var/lib/libviages/VM1.qcow2} \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}{Managing Docker containers}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\# Install packages \newline yum install -y yum-utils \seqsplit{device-mapper-persistent-data} lvm2 \newline \newline \#Setup stable Docker repo \newline yum-config-manager -{}-add-repo \seqsplit{https://download.docker.com/linux/centos/docker-ce.repo} \newline \newline \#Install Docker CE \newline yum install docker-ce \newline \newline \#Start Docker service \newline systemctl start docker \newline \newline docker search hello \newline docker pull hello-world \newline docker run hello-world \newline \newline docker images (check available images) \newline docker ps -a (Check all containers) \newline docker start {\emph{id}} (Start specific container) \newline docker run -it ubuntu bash (Run bash shell inside container) \newline \newline docker run -dit -{}-name la-test-web -p 80:80 -v \seqsplit{/home/long/webstuff/:/usr/local/apache2/htdocs/httpd:2}.4 (Create a container for running web server) \newline docker rm la-test-web (Remove container la-test-web)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}