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

Feb 25 2022

Change from Slackware-14.2 (32-bit) to Slackware64-15.0 (64-bit)

Boot from Slackware-14.2 USB install stick

mkdir /myraid
mount /dev/md1 /myraid
mount /dev/md5 /myraid/usr
mount /dev/md6 /myraid/var
mount /dev/md7 /myraid/home

mount --bind /dev /myraid/dev
mount -t devpts devpts /myraid/dev/pts
mount -t proc proc /myraid/proc
mount -t sysfs sysfs /myraid/sys

mount USB with Slackware64-15.0
mkdir /myraid/usb
mount /dev/sdc1 /myraid/usb

chroot /myraid

cd /usb/slackware64/a
installpkg kernel-huge.t?z installpkg kernel-modules.t?z

reboot

uname -m should prints ‘x86_64
mount usb stick to /mnt/usb

cd /mnt/usb/slackware64/
installpkg a/aaa_glibc-solibs-2.33-x86_64-5.t?z
installpkg a/aaa_libraries-15.0-x86_64-19.t?z
installpkg a/aaa_base-15.0-x86_64-3.t?z
installpkg a/aaa_terminfo-6.3-x86_64-1.t?z

install rest of packages
installpkg */*.t?z

reboot. Now you are running a 64-bit system.
get rid of the old 32-bit packages:
removepkg /var/adm/packages/*-i[456]86-*
check the *.new files