Linux


Linux usefull commands


CPU/ Process


Memory/ Swap


Create 4GB Swap

dd if=/dev/zero of=/mnt/swapfile2 bs=1024 count=4000000
mkswap /mnt/swapfile2
swapon /mnt/swapfile2
swapon -s

Firewall/Ports

Common Commands

firewall-cmd  --list-forward-ports

        --list-services

        --list-all

        --runtime-to-permanent


Configure port listening and forward


firewall-cmd --permanent --add-service=https

firewall-cmd --permanent --remove-forward-port=port=443:proto=tcp:toport=8443

firewall-cmd --reload

firewall-cmd  --list-forward-ports


Disks

Reducing the Volume size

Stop all services on server and unmount disk

swapoff -a
umount /mnt
 
#Run FSCK and reduce
e2fsck -f /dev/mapper/CryptedRAID
resize2fs /dev/mapper/CryptedRAID 49G
 
cryptsetup resize --size 102768112 /dev/mapper/CryptedRAID
lvreduce -L 49G vg0/lv0
 
 vgreduce vg0 /dev/sdg
 pvremove /dev/sdg
 lvresize -l +100%FREE vg0/lv0
 
 cryptsetup resize /dev/mapper/CryptedRAID

Repository/Packages

Configure EPEL Repo
Install Python3

Configure EPL

#yum install  python36

curl -O https://bootstrap.pypa.io/get-pip.py

python3 get-pip.py --user


Download package locally

yum install -y nagios-plugins  --downloadonly --downloaddir=/root


RPM build package
Download Docker image 

#docker pull dennysv/rpmbuilder-fedora
#docker run --name rpmbuilder-fedora dennysv/rpmbuilder-fedora
#dk exec -ti rpmbuilder-fedora /bin/bash


Docker image is built with all necessary software to build RPM package and sample package provided. 
Sample package and configuration file included, also commands necessary to build.