Show Menu

LFCS_Module6_ServiceConfiguration Cheat Sheet by

linux

Web Services

systemctl start httpd
Start the Apache web service
vim /etc/h­ttp­d/c­onf­/ht­tpd.conf
Main config file for Apache
/etc/h­ttp­d/c­onf.d
Additional config, drop any addtional here
/etc/h­ttp­d/c­onf.mo­dules.d
Addtional config

Squid Proxy

yum install squid
vim /etc/squid/squid.conf
systemctl enable --now squid

#Configure browser
Preferences -> Advanced -> Network -> Settings -> Manual: 192.168.4.240 port 3128

Virtual Hosts

- vim /etc/h­osts; Create name resolution
- cd /etc/h­ttp­d/c­onf.d/; vim accoun­t.e­xam­ple.co­m.conf : Create virtual host w/ content
<Vi­rtu­alHost *:80>
Server­Admin webmas­ter­@ac­cou­nt.e­xa­mpl­e.com
Docume­ntRoot /web/a­ccount
ServerName accoun­t.e­xam­ple.com
</V­irt­ual­Hos­t>
- mkdir /web/a­ccount; cd /web/a­ccount; vim index.html : Create index file
 

FTP Server

yum install vsftpd
Install Very Secure ftp
/etc/v­sftpd
Main config file
yum install lftp
Install ftp client
lftp localhost
Connect to ftp

Configure Postfix

#Email delivery
vim /etc/postfix/main.cf
   relayhost = [192.168.4.200]
   relay_domains = $mydestination

#Email Receiving
vim /etc/postfix/main.cf
   myorigin = $myhostname
   mynetworks = 192.168.0.0/16
   inet_protocols = ipv4
   inet_interfaces = all
   mydestination = ...., hash:/etc/postfix/transport

#setting transport
vim /etc/postfix/transport
  example.com local:
  .example.com local:

#update transport table
postmap /etc/postfix/transport

Configure an IMAP service

yum install dovecot
vim /etc/dovecot.conf
  protocols = imap pop3
vim /etc/dovecot/conf.d/10-mail.conf
  mail_location = mbox:~/mail:INBOX=/var/mail/%u
  mail_privileged_group = mail
vim /etc/dovecot/conf.d/10-ssl.conf
  ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
  ssl_key = </etc/pki/dovecot/private/dovecot.pem
dovecot -n
Message Transport Agent – MTA: mail relay, Postfix
Mail User Agent – MUA: Gmail, Outbook, Thunde­rbird
Mail Delivery Agent - MDA: Dovecot

Setting Up Email Services

#Email aliases
vim /etc/postfix/aliases
  user1: user1, user2
postalias /etc/postfix/aliases reload configuration

#parameters
myorigin
inet_interfaces = yourIP, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

#Send email to test
echo "This is a test" | mail -s "test" root@example.com

#Check
mail

Cache-only DNS Server

yum install unbound
systemctl enable --now unbound
iptables -A INPUT -p udp/tcp -dport 53 -j ACCEPT
vim /etc/unbound/unbound.conf
  # interface: 0.0.0.0
  # access-control: 192.168.0.0/16 allow
  #domain-insecure: "example.com"
  # forward-zone:
                  name: "."
                  forward-addr: 8.8.8.8
systemctl restart unbound
netstat -tulpen (Show listening port)

Database

yum install mariadb
Install Mariadb
mysql_­sec­ure­_in­sta­llation
Intera­ctive setup for Mysql
mysql -u root -p
Login mysql using root
create database dbname
Create database
use people; create table users(­fir­stname varcha­r(2­0),....);
Create table
insert into user(...) values­(...);
Insert values
select * from users
Show table

Configure NFS Server

mkdir /nfsshare (Create folder for NFS)
chown nfsnobody:nfsnobody /nfsshare (Change owner to special nfsnobody user)
chmod 755 /nfsshare

vim /etc/exports
  /share *(rw,no_root_squash)

systemctl enable --now nfs-server
systemctl enable --now rpcbind
systemctl enable --now nfs-idmap

#Mounting NFS Share persistently
ssh into remote client
yum install nfs-utils (install nfs utilities)
mkdir -p /mnt/remote (Create mount point)
mount -t nfs ServerIP:/share /mnt/remote (Mount)
vim /etc/fstab
  #centos:/share /centos/nfs nfs _netdev 0 0\
umount /centos/nfs
mount -a

Configure Samba Server

yum install samba
mv /etc/samb/smb.conf.example /etc/samba/smb.conf (Overwrite)
vim /etc/samba/smb.conf (Create a samba share)
  [share]
            comment = samba share
            path = /samba
            public = yes
mkdir /samba
semanage fcontext -a -t samba_share_t /samba
restorecon -Rv /samba
systemctl start smb

#Create samba user
smbpasswd -a anna

#smb client
yum install smbclient
smbclient -L localhost

#Mount smb persistently
mount -o username=anna //centos/share /mnt
yum install clifs-utils (Install additonal utils)
mkdfir /centos/samba
vim /etc/fstab
  //centos/samba /centos/samba cifs
   _netdev,username=anna,password=password 0 0

KVM

yum group install "Virtualization Host" or yum install qemu-kvm libvirt libvirt-client virt-install virt-viewer virt-manager
systemctl start libvirtd
virt (Start Virtual manger)

#
virsh list (Show available VMs)
virsh list --all (Show all VMs)
virsh start VM name
virsh stop VM name
virsh autostart VM name (Autostart after the host reboot)
virsh autostart --disable VMname (Disable autostart)


virt-install --name=VM1 --vcpus=1 --memory=1024 --cdrom=isoimage
virsh edit VM1 (Edit VM1 virtual machine)
virt-clone --original=VM1 --name=VM2 --file=/var/lib/libviages/VM1.qcow2

Managing Docker containers

# Install packages
yum install -y yum-utils device-mapper-persistent-data lvm2

#Setup stable Docker repo
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

#Install Docker CE
yum install docker-ce

#Start Docker service
systemctl start docker

docker search hello
docker pull hello-world
docker run hello-world

docker images (check available images)
docker ps -a (Check all containers)
docker start id (Start specific container)
docker run -it ubuntu bash (Run bash shell inside container)

docker run -dit --name la-test-web -p 80:80 -v /home/long/webstuff/:/usr/local/apache2/htdocs/httpd:2.4 (Create a container for running web server)
docker rm la-test-web (Remove container la-test-web)

Download the LFCS_Module6_ServiceConfiguration Cheat Sheet

3 Pages
//media.cheatography.com/storage/thumb/nhatlong0605_lfcs-module6-serviceconfiguration.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          mod_rewrite Cheat Sheet
          Vim NERDTree Cheat Sheet

          More Cheat Sheets by nhatlong0605