Tag Archives: bash

grep IP subnet


starting with 192.x.x.x
cat ip_list.txt | grep -E "(192)(\.[0-9]{1,3}){3}"

starting with 192.168.x.x
cat ip_list.txt | grep -E "(192.168)(\.[0-9]{1,3}){2}"

starting with 192.168.10.x
cat ip_list.txt | grep -E "(192.168.10.)[0-9]{1,3}"

linux add hostname to stdout

base64 /dev/urandom | head -c 1000 | sed "1 i\\`hostname`" | head -n 5

localhost.localdomain
brXE3yBW/afyXoZXigNc+bTaw71rW7Ykz9xFD01ZeXeglA/vubg9eJPmldDN3qQEOZongJbjSIEl
D6tu8lfhoYboc8eJTPPPasoQP1RcbdX/kVRbrxV2cLTaKVik2o3sywpjLZl+0Dow/9Of8iToahOw
JdWXPrkmsZZ9le4uN+qGU55Z2TO2Mc/baY0UUmBXaWX9NsNTsO4HwfqnT62Gs0BVtbMaWw0vWf3n
4QxJGcNl/gi5WUM/aamcUFe5exb8YlEk6Nj3szqf3b4DQE4XODe46W/4qCzg/UFzCb5SOC0YBnEa

monitor process io

ps -eo state,pid,cmd | awk '/^D/ { print "proccess: " $3 ; system("cat /proc/"$2"/io") }'

proccess: [md1_raid10]
rchar: 0
wchar: 0
syscr: 0
syscw: 0
read_bytes: 0
write_bytes: 0
cancelled_write_bytes: 0
proccess :/opt/cpanel/ea-php56/root/usr/bin/php-cgi
rchar: 334932
wchar: 3941
syscr: 177
syscw: 26
read_bytes: 4096
write_bytes: 8192
cancelled_write_bytes: 4096

check ip by country linux

yum install geoip
geoipupdate
geoiplookup 1.1.1.1

GeoIP Country Edition: AU, Australia
ipaddr: 1.1.1.1
range_by_ip: 1.1.1.0 – 1.1.1.255
network: 1.1.1.0 – 1.1.1.255 ::24
ipnum: 16843009
range_by_num: 16843008 – 16843263
network num: 16843008 – 16843263 ::24