Jan 31 2023

KVM install VM with vnc server

Install from img file (with disk size 15G and bridge name inner)

virt-install \
--name=bull \
--vcpus=8 \
--memory=24576 \
--disk path=/var/lib/libvirt/images/bull.qcow2,size=15 \
--cdrom /var/lib/libvirt/iso/debian-11.6.0-amd64-netinst.iso \
--network bridge=inner,mac=52:54:00:40:4a:5e \
--boot hd,uefi \
--machine q35 \
--osinfo detect=on,require=off \
--graphics vnc,listen=<IP_HOST_TO_LISTEN_TO>,password=<SECRET>
Install from PXE
virt-install \
--name=rhpxe \
--vcpus=4 \
--memory=2048 \
--network bridge=br0,mac=52:54:00:0e:27:FF \
--pxe \
--disk none \
--boot uefi \
--osinfo detect=on,require=off \
--graphics vnc,listen=<IP_HOST_TO_LISTEN_TO>,password=<SECRET> 

Jan 31 2023

Mikrotik port forward / redirect

/ip firewall nat add chain=dstnat dst-port=1234 action=dst-nat protocol=tcp to-address=192.168.1.1 to-port=1234
Jan 27 2023

Delete old files

Find only executable
find

-executable -type f

Delete old files

find /path/to/dir/ ( ( -type f -daystart -mtime +8 ) -o -type d -empty ) -delete
Jan 7 2023

How to download all files (but not HTML) from a website using wget?

wget -A lst,meta,txt,txz,tgz,asc,md5 -m -p -E -k -K -np <URL>
Oct 14 2022

elilo.conf

chooser=simple
# interactive mode
prompt
# delay when not in interactive mode (0.1 sec)
delay=100
# timeout when in interactive mode (0.1 sec)
timeout=100
default=vmlinuz
#
image=vmlinuz
label=vmlinuz
read-only
append="root=/dev/sdc2 vga=normal ro"

image=vmlinuz-generic
label=vmlinuz-generic
initrd=initrd.gz
read-only
append="root=/dev/sdc2 vga=normal ro"

image=vmlinuz-huge-5.15.27
label=huge-5.15.27
read-only
append="root=/dev/sdc2 vga=normal ro"

image=vmlinuz-generic-5.15.27
label=generic-5.15.27
initrd=initrd-5.15.27.gz
read-only
append="root=/dev/sdc2 vga=normal ro"
Oct 13 2022

Show modules in mkinitrd

mkdir /tmp/initrd
/tmp/initrd
cp /boot/initrd.gz .
gunzip initrd.gz
cpio -id < initrd

# mkinitrd.conf.sample
# See "man mkinitrd.conf" for details on the syntax of this file
#
#SOURCE_TREE="/boot/initrd-tree"
#CLEAR_TREE="0"
#OUTPUT_IMAGE="/boot/initrd.gz"
#KERNEL_VERSION="$(uname -r)"
#KEYMAP="us"
MODULE_LIST="ext4:hv_vmbus:scsi_transport_fc:hv_storvcs:jbd2:mbchache"
#LUKSDEV="/dev/sda2"
#LUKSTRIM="/dev/sda2" # verify support with 'hdparm -I $dev | grep TRIM'
#LUKSKEY="LABEL=TRAVELSTICK:/keys/alienbob.luks"
ROOTDEV="/dev/sda2"
ROOTFS="ext4"
#RESUMEDEV="/dev/sda2"
#RAID="0"
#LVM="0"
#UDEV="1"
#MODCONF="0"
#MICROCODE_ARCH="/boot/intel-ucode.cpio"
#WAIT="1"

mkinitrd -F -k 5.15.63
or
/usr/share/mkinitrd/mkinitrd_command_generator.sh -k 5.15.63
cp /boot/initrd.gz /boot/efi/EFI/Slackware/
cp /boot/vmlinuz-generic-5.15.63 /boot/efi/EFI/Slackware/vmlinuz

cp /boot/initrd.gz /boot/efi/EFI/Slackware/initrd-5.15.63.gz
cp /boot/vmlinuz-generic-5.15.63 /boot/efi/EFI/Slackware/vmlinuz-5.15.63



Jun 5 2022

Linux terminal tricks

cd -
pushd /folder
popd
sudo !! (repeat previous command without sudo)
! number (execute command with number from history command)

 

Jun 2 2022

Convert a drive from MBR to GPT

mbr2gpt /validate /allowFullOS
mbr2gpt /convert /allowfullOS

Mar 24 2022

Check if process is running

PROCESS="netperf"
if pgrep -x "$PROCESS" > /dev/null; then
echo "$PROCESS Running"
else
echo "$PROCESS Not running"
fi

Mar 2 2022

Limiting clamav memory usage

During a database reload clamd will load the new DB first and then drop the old one. This concurrent database reload strategy allows it to keep scanning files while loading the new database. The drawback is that it requires twice as much memory as during normal operations. As a result the clamd process would keep getting killed.

Starting from ClamAV 0.103.0 you can set ConcurrentDatabaseReload no in your /etc/clamav/clamd.conf to disable this behaviour