configure tmpwatch on cron in centos

On boot clean all files in /tmp created,modificated or changed more than 1 min

@reboot tmpwatch -umc 1m /tmp
Advertisements

send e-mail from linux with telnet

#!/bin/bash
(
echo 'HELO' 
sleep 1
echo 'mail from: insertSourceMailHere@gmail.com' 
sleep 1
echo 'rcpt to: insertDestinationMailHere@gmail.com' 
echo 'rcpt to: insertDestinationMail2Here@gmail.com'
sleep 1
echo 'data' 
sleep 1
echo "Subject: message from server: $(hostname)

Content of file: /etc/passwd 

$(cat /etc/passwd)
"
echo '.' 
sleep 1
echo 'quit'
) | telnet localhost smtp

compile kernel source on centos 7

Install necessary packages to compiling a new kernel

yum install ncurses-devel make gcc openssl-devel elfutils-libelf-devel bison flex rpm-build

Download the kernel source code

wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.16.13.tar.xz -O /usr/src/kernels/

Decompress the kernel source code

cd /usr/src/kernels; tar xvf linux-4.16.13.tar.xz

Create a symbolic link to directory of kernel compilation

ln -sf /usr/src/kernels/linux-4.16.13 /usr/src/linux
cd /usr/src/linux

Copy the configuration of your current kernel for a new kernel

cp /boot/config-$(uname -r) /usr/src/linux/.config

Choose modules for your new kernel if you want and save the configuration

make menuconfig

Compile the kernel

make rpm-pkg

Install the new kernel

rpm -Uvh ~/rpmbuild/RPMS/x86_64/kernel-*

Reboot the machine and boot with the new kernel

init 6

configure wifi network using network manager command line on centos

To list network devices

nmcli device

To list visible wifi networks

nmcli device wifi

To scan and list wifi networks

nmcli device wifi rescan; nmcli device wifi

To add and connect on a network

nmcli device wifi connect wifiNameHere password wifiPasswdHere

To add and connect on a hidden network

nmcli device wifi connect wifiNameHere password wifiPasswdHere hidden yes

To list registered networks

nmcli connection

To delete a registered network

nmcli connection delete wifiNameHere

To connect on a registered network

nmcli connection up wifiNameHere

To view network configuration IP,DNS

nmcli

install geoip iptables module centos 7

1 – Install packages

yum install gcc gcc-c++ make automake unzip zip xz kernel-devel-`uname -r` wget unzip iptables-devel perl-Text-CSV_XS

2 – Download and decompress xtables-addons

wget http://ufpr.dl.sourceforge.net/project/xtables-addons/Xtables-addons/xtables-addons-2.14.tar.xz
tar -xvf xtables-addons-2.14.tar.xz
cd xtables-addons-2.14

3 – Compile xtables-addons

./configure
sed -i '/xt_TARPIT.o$/s/^/#/' extensions/Kbuild
make && make install

4 – Download and install geoip database

cd geoip
./xt_geoip_dl
./xt_geoip_build GeoIPCountryWhois.csv
mkdir -p /usr/share/xt_geoip
cp -r {BE,LE} /usr/share/xt_geoip
modprobe xt_geoip

5 – Insert a firewall rule to test

iptables -A FORWARD -m geoip --src-cc BR,JP,FR -j DROP