Cheatography
https://cheatography.com
Web Services
systemctl start httpd |
Start the Apache web service |
vim /etc/httpd/conf/httpd.conf |
Main config file for Apache |
/etc/httpd/conf.d |
Additional config, drop any addtional here |
/etc/httpd/conf.modules.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/hosts; Create name resolution
- cd /etc/httpd/conf.d/; vim account.example.com.conf : Create virtual host w/ content
<VirtualHost *:80>
ServerAdmin webmaster@account.example.com
DocumentRoot /web/account
ServerName account.example.com
</VirtualHost>
- mkdir /web/account; cd /web/account; vim index.html : Create index file |
|
|
FTP Server
yum install vsftpd |
Install Very Secure ftp |
/etc/vsftpd |
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, Thunderbird
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_secure_installation |
Interactive setup for Mysql |
mysql -u root -p |
Login mysql using root |
create database dbname |
Create database |
use people; create table users(firstname varchar(20),....); |
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)
|
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by nhatlong0605