Archive for the Linux Category

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)

 

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

Feb 18 2022

Slackware upgrade from 32-bit to 64-bit

  1. If you use 4 as the default runlevel, change it back to the default 3 in /etc/inittab.
  2. installpkg the 64-bit huge kernel and modules, ADD it to lilo.conf, run lilo, reboot. Now you are running the 32-bit system on a 64-bit kernel. ‘uname -m’ prints ‘x86_64’ instead of ‘i686’.
  3. installpkg the 64-bit a/glibc-solibs and a/aaa_elflibs. After that the basic 64-bit binaries would run in addition to the 32-bit ones.
  4. installpkg everything from the 64-bit directories slackware64/*/*.t?z.
  5. reboot. Now you are running a 64-bit system.
  6. get rid of the old 32-bit packages:
    removepkg /var/adm/packages/*-i[456]86-*
  7. check the *.new files

fdisk -l /dev/sda
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000001

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 10487807 10485760 5G fd Linux raid autodetect
/dev/sda2 10487808 16779263 6291456 3G 82 Linux swap
/dev/sda3 16779264 976773167 959993904 457.8G 5 Extended
/dev/sda5 16781312 48238591 31457280 15G fd Linux raid autodetect
/dev/sda6 48240640 69212159 20971520 10G fd Linux raid autodetect
/dev/sda7 69214208 976773167 907558960 432.8G fd Linux raid autodetect

root@dwarf:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md1 4.8G 3.5G 1.2G 76% /
/dev/md5 15G 12G 2.1G 86% /usr
/dev/md6 9.8G 4.6G 4.6G 50% /var
/dev/md7 426G 225G 180G 56% /home

mdadm –assemble –run /dev/md1 /dev/sdb1

mdadm –assemble –run /dev/md5 /dev/sdb5

mdadm –assemble –run /dev/md6 /dev/sdb6

mdadm –assemble –run /dev/md7 /dev/sdb7

setup

liloconfig /mnt /dev/md1


Mounts made by setup:
mount /dev/md1 /mnt
mount /dev/md5 /mnt/usr
mount /dev/md6 /mnt/var
mount /dev/md7 /home
ln -s /var/lib/pkgtools/packages /mnt/var/lib/pkgtools/packages

 

 

 

 

 

Feb 17 2022

Clone whole disk with linux

Clone entire disk to file

dd if=/dev/sda conv=sync,noerror,notrunc bs=16M status=progress | gzip /path/to_image

Restore disk from file

gunzip -c /path/to_image | dd of=/dev/sdc bs=16M status=progress

Copy MBR (identical discs)

dd if=/dev/sda of=/dev/sdb bs=512 count=1

Copy MBR (different disc’s sizes)

dd if=/dev/sda of=/tmp/mbr.img bs=512 count=1

dd if=/tmp/mbr.img of=/dev/sdb bs=446 count=1

The above commands will preserve the partitioning schema.

Feb 13 2022

sudo without password

visudo

add line

rafrom ALL=NOPASSWD: ALL