Difference between revisions of "ESXi, CentOS, Ubuntu, Docker"

From Rhomicom Wiki
Jump to navigation Jump to search
Line 93: Line 93:
 
         - "8000:8080"
 
         - "8000:8080"
 
docker stack deploy -c bb-stack.yaml demo #Deploy Apps to swarm
 
docker stack deploy -c bb-stack.yaml demo #Deploy Apps to swarm
 
+
docker stack rm demo # Tear everything down
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 12:24, 9 February 2022

Useful Commands

hostnamectl set-hostname "aws-webmin.rhomicom.com"
nano /etc/hosts

kill SIGNAL PID
kill -9 2117

sudo netstat -tulpn | grep LISTEN
sudo ss -tulpn | grep LISTEN
fuser -k 25/tcp
fuser -k 80/tcp
fuser -k 443/tcp
su - zimbra -c "zmcontrol start"
systemctl stop named
systemctl disable named
su - zimbra -c "zmcontrol restart"

nc mail.rhomicom.com 25
nc mail.rhomicom.com 587
telnet mail.rhomicom.com 25
telnet mail.rhomicom.com 587

lsblk -o name,rota
fdisk -l
du -s -B1 -h -c --apparent-size *
du -csh *
adduser rhouser
   passwd rhouser
   usermod -aG wheel rhouser
  su - rhouser
userdel rhouser
userdel -r rhouser  #del home dir
chkconfig --add httpd
chkconfig httpd on
chkconfig httpd off
chkconfig --del httpd
 yum -y install which openssh openssh-server openssh-clients openssl-libs nano rsync unzip net-tools NetworkManager-tui sysstat perl-core libaio nmap-ncat libstdc++.so.6 wget tar 
 yum install epel-release
 dnf --enablerepo=epel -y install sshpass
 
 #Compress
 tar -czvf zimbkp23Aug2021.tar.gz /opt/zimbra
 #Extract/Deflate
 tar -xzvf zimbkp23Aug2021.tar.gz
 #Download
 rsync -avH [email protected]:/home/user/ --progress --human-readable /home/user/Downloads/
 #UPLOAD#
 rsync -avH /home/richard/Downloads/ --progress --human-readable [email protected]:/home/user/
 rsync -avHP /home/a_bkps.tar.gz --progress --human-readable -e "ssh -i some-key.pem" [email protected]:/home/user/

Docker Commands

docker ps
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id #GET CONTAINER IP ADDRESS)
docker inspect -f  "{{ .Config.Env }}" <container_id> 
docker commit --change "ENV DEBUG=true" <container_id> rhomicom/testimage:v1.0
docker inspect -f "{{ .Config.Env }}" <container_id>
docker push rhomicom/testimage:v1.0

sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker && sudo systemctl enable docker
sudo docker run hello-world

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version

Docker Swarm

docker system info
docker swarm init
docker swarm join #Join existing Swarm Cluster
nano bb-stack.yaml
  version: '3.7'
  services:
    bb-app:
      image: bulletinboard:1.0
      ports:
        - "8000:8080"
docker stack deploy -c bb-stack.yaml demo #Deploy Apps to swarm
docker stack rm demo # Tear everything down

BackupPC

dnf update
dnf install epel-release
dnf info backuppc
dnf config-manager –set-enabled PowerTools
dnf install -y backuppc

nano /etc/BackupPC/config.pl
nano /etc/httpd/conf.d/BackupPC.conf
htpasswd -c /etc/BackupPC/.backuppc bkpadmin
chmod 666 /etc/BackupPC/.backuppc

yum -y install which openssh openssh-server openssh-clients openssl-libs nano rsync unzip net-tools NetworkManager-tui sysstat perl-core libaio nmap-ncat libstdc++.so.6 wget tar
dnf --enablerepo=epel -y install sshpass

nano /etc/httpd/conf/httpd.conf
mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.old
sed -i 's/Options Indexes FollowSymLinks/Options -Indexes +FollowSymLinks/' /etc/httpd/conf/httpd.conf
httpd -t
systemctl enable --now httpd
systemctl enable --now backuppc
systemctl status backuppc
sudo -u backuppc /usr/share/BackupPC/bin/BackupPC_serverMesg status info
sudo -u backuppc /usr/share/BackupPC/bin/BackupPC_serverMesg status hosts
sudo -u backuppc /usr/share/BackupPC/bin/BackupPC_serverMesg status jobs
firewall-cmd --add-service={http,https} --permanent

systemctl restart httpd
systecmctl restart backuppc
systemctl status backuppc
htpasswd -c /etc/BackupPC/.backuppc bkpadmin
nano /etc/httpd/conf.d/BackupPC.conf

Linux Rescue Mode

mkdir -p /media/sda
mount -o exec,barrier=0 /dev/sda /media/sda
mount -o remount,exec,barrier=0 /dev/sda /media/sda
cd /media/sda
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/
mount -t devpts pts dev/pts/
chroot /media/sda /bin/bash

#NB if /etc/shadow or /etc/passwd files are edited manually, you might need to disable SELINUX or restore their SELINUX settings

CentOS Networking

nano /etc/sysconfig/network

HOSTNAME=mail.bhandari.com
nano /etc/sysconfig/network-scripts/ifcfg-eth0
-----------------------------------------------------------------------
DEVICE="eth0"
IPADDR=192.168.1.221
NETMASK=255.255.255.0
HWADDR="00:16:D4:39:5B:6F"
NM_CONTROLLED="yes"
ONBOOT="yes"
-----------------------------------------------------------------------
#Restart Network Services..
service network restart


Amazon Linux 2

amazon-linux-extras install -y nginx1
yum install -y mod_ssl
amazon-linux-extras install -y epel
sudo systemctl start nginx
 sudo systemctl enable nginx
 yum -y install git which openssh openssh-server openssh-clients openssl-libs nano rsync unzip net-tools NetworkManager-tui sysstat perl-core libaio nmap-ncat libstdc++.so.6 wget tar
 
 sudo yum update -y
 sudo amazon-linux-extras install docker
 sudo service docker start
 sudo systemctl enable docker
 
 sudo usermod -a -G docker ec2-user
 
 sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/bin/docker-compose
 sudo chmod +x /usr/bin/docker-compose
 docker-compose version


iptables-save > IPtablesbackup.txt
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo iptables -L
service iptables save
iptables-restore < IPtablesbackup.txt 


sudo amazon-linux-extras install epel -y
sudo systemctl stop nginx
sudo yum install yum-utils
sudo yum install -y certbot python-certbot-nginx python-certbot-apache
sudo yum remove -y python-certbot-apache
sudo certbot certonly --standalone --debug -d api.example.org

docker pull rhomicom/rho-erp-base:v1.1
docker pull adminer
docker pull mysql:5.7

sudo service docker restart

docker build -t rhomicom/rho-php-base:v1.0 .
mkdir -p /etc/ssl/certs/
mkdir -p /etc/ssl/private
openssl req -newkey rsa:4096 -nodes -keyout /etc/ssl/private/srvr.key -x509 -days 365 -out /etc/ssl/certs/srvr.crt -subj "/C=GH/ST=Greater Accra/L=Accra/O=Rhomicom Demo/OU=IT/CN=*.rhomicom.com/[email protected]"