vmstat 1 | awk ‘{now=strftime(“%Y-%m-%d %T “); print now $0}’
iostat -x 1 | awk ‘{now=strftime(“%Y-%m-%d %T “); print now $0}’
Archive for the ‘Linux’ Category
Adding Timestamp in vmstat / iostat CLI output
Friday, June 12th, 2020TCPDUMP request and response Header
Thursday, February 6th, 2020tcpdump -A -s 10240 ‘tcp port 80 and (((ip[2:2] – ((ip[0]&0xf)<<2)) – ((tcp[12]&0xf0)>>2)) != 0)’ | egrep –line-buffered “^……..(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: ” | sed -r ‘s/^……..(GET |HTTP\/|POST |HEAD )/\n\1/g’
CentOS 8 firewall command equivalent
Tuesday, January 14th, 2020iptables -nL = nft list ruleset
service iptables restart = /bin/firewall-cmd –reload
blocking hacker scanning your website using various type of extension that is not running on your webserver
Wednesday, April 10th, 2019If you are running WordPress on Linux, most likely you won’t expect user hitting your website with .asp / .cfm / .jsp extension. When some hackers are trying to scan your site with all these non-sense requests, your webserver will be overloaded due to the 404 page is generated from wordpress.
RewriteCond %{REQUEST_URI} !^/index.php$
RewriteCond %{REQUEST_URI} !robots.txt$
RewriteCond %{REQUEST_URI} !wp-.*.php$ RewriteCond %{REQUEST_URI} !healthcheck.php$RewriteRule .*\.(asp|aspx|ashx|asa|jsp|cfm|do|action|cer|exe|txt|htm|html|rar|zip|php)$ – [F,L,NC]
fpm-status and restart
Tuesday, April 17th, 2018http://x.x.x.x/fpmstatus.php?full
systemctl restart php-fpm
Managing CentOS 7 firewall with firewall-cmd
Monday, March 6th, 2017firewall-cmd --state
firewall-cmd --zone=public --permanent --add-port=2812/tcp
firewall-cmd --permanent --add-rich-rule 'rule family="ipv4" source address="x.x.x.x" log reject'
firewall-cmd --reload
firewall-cmd --list-all
Adding a Unix with Access Rights for FTP
Friday, May 30th, 2014- useradd hcp_ftp -d /home/www/www.xxx.com/htdocs -s /bin/false
- usermod -a -G ftpdata xxx_ftp
- usermod -a -G daemon xxx_ftp
- passwd xxx_ftp
- vi /etc/proftpd.groupowner
<Directory /home/www/www.xxx.com/htdocs>
UserOwner daemon
GroupOwner daemon
</Directory>
- service proftpd restart
REHL file system become read only in VMWare
Saturday, March 29th, 2014This become a known issue for RHEL if you are on a busy I/O storage.
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=51306
Work around is to remount the filesystem using the following command.
mount -o remount /
Advance Routing for Multi-homed Linux
Saturday, March 1st, 2014This page shows you how to configure a Multi-homed Linux Box with 2 Network Interfaces to connect to the internet properly.
Step 1 – Update /etc/iproute2/rt_tables
echo 1 NET100 >> /etc/iproute2/rt_tables
echo 2 NET200 >> /etc/iproute2/rt_tables
Step 2 – Update the Routing Table
ip route add default via 192.168.100.1 dev eth1 table NET100
ip rule add from 192.168.100.0/24 table NET100
ip route add default via 192.168.200.1 dev eth0 table NET200
ip rule add from 192.168.200.0/24 table NET200
Recursively FTP all sub folders in Linux with wget
Saturday, November 9th, 2013wget -r ftp://user:pass@server.com/