Rexxer

Some tips for me and other

Linux

Extend LVM partition in CentOS 7/8 under VmWare

Add more space on the disk in VmWare console. Run cfdisk and check that you see free space after /dev/sda5. In my case there are /dev/sda4 as extended partition and /dev/sda5 as LVM2 partition in extended. Remember start sectors for /dev/sda4 and sda5. Delete /dev/sda5. Don’t worry – your data will be OK. Delete /dev/sda4. […]

Centos + No more mirrors to try

yum clean all yum –disablerepo=\* –enablerepo=base,extras,updates update

Replace a line in a file with SED

sed -i ‘Ns/.*/replacement-line/’ file.txt where N should be replaced by your target line number. This replaces the line in the original file. To save the changed text in a different file, drop the -i option: sed ‘Ns/.*/replacement-line/’ file.txt > new_file.txt

BASH

Useful site about bash-scripts: http://tldp.org/LDP/abs/html/

Extract a text between delimiters with sh instead of using regex

Example file: UNKNOWN[123.21.181.4] abts-tn-dynamic-161.155.174.122.airtelbroadband.in[122.174.155.161] fm-dyn-118-137-18-160.fast.net.id[118.137.18.160] UNKNOWN[118.69.71.76] ip-177.71.93.43.juniornet.psi.br[177.71.93.43] UNKNOWN[210.245.34.254] UNKNOWN[185.140.242.41] I want to extract IP-addresses: command shell: cat drop.txt | cut -d'[‘ -f2 | cut -d’]’ -f1 Get data from the file Delete all the text before the delimeter (we choose the text after the delimiter) Delete alle the text after the delimeter ( … before […]

WGET + Measure for web

wget -E -H -p -Q300K –user-agent=Mozilla –no-cache –no-cookies –no-check-certificate –delete-after –timeout=15 –tries=2 yoursite.com 2>&1 | grep Downloaded

Linux + LVM + fsck

# lvm pvscan # lvm vgscan # lvm vgs # lvm vgchange -a y VolGroup00 # lvm vgdisplay -v VolGroup00 | more # fsck /dev/VolGroup00/LogvolX Can’t find a good superblock backup? To display: # mke2fs -n /dev/VolGroup00/LogVolX Other thoughts: 1. Clean bit could be set – to force an fsck: # fsck -f /dev/vgname/lvolname # […]

Grep + Parse IPs

grep -o ‘[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}’ file.txt

DHCPD + Classes e.g. MAC-address

subnet 192.168.30.0 netmask 255.255.255.0 { option routers 192.168.30.1; option domain-name-servers 192.168.30.11, 192.168.30.2; class “Hyper-V” { match if substring(hardware,1,3) = 00:15:5d; } class “VMWare” { match if substring(hardware,1,3) = 00:0c:29; } class “Winemu” { match if substring(hardware,1,3) = 00:03:ff; } pool { range 192.168.30.100 192.168.30.130; allow members of “Hyper-V”; } pool { range 192.168.30.131 192.168.30.160; allow […]

Server reboot + variants

Нормальная работа reboot проблемы с софтом reboot -f проблемы с ядром/маунтами/libc echo b>/proc/sysrq-trigger проблемы с ядром/маунтами/libc и нет открытой консоли ipt_SYSRQ (надо подготовить заранее) проблемы с ядром/железом ipmitool chassis power cycle проблемы с ядром/железом без открытой консоли ipmitool -H ipmi.server.local chassis power cycle проблемы с автономной переферией/БП/ipmi ребут через IP-розетку

Previous Posts