Linux shell commands

Here are some useful Linux CLI commands, I will do more good examples in the future. For Germans: #maleben


Remove duplicated empty lines:

cat -s file.txt

Find Windows OEM license key in BIOS:

strings /sys/firmware/acpi/tables/MSDM | grep ".*-.*-.*-.*-.*"

Copy file between two hosts directly:

scp -3 host1:/src.file host2:/dst.file

Prepend all lines with timestamp:

ls -la | ts '[%Y-%m-%d %H:%M:%S]'

Resize QEMU disk image:

qemu-img resize image.qcow2 +10G

Rescan disk size without restart:

echo 1 > /sys/block/sda/device/rescan

Reload udev rules without reboot:

udevadm control --reload-rules && udevadm trigger

Reset an USB device via software:

usb_modeswitch -v 3911 -p 7000 -R

Rotate an PDF clockwise:

pdftk input.pdf cat 1-endeast output output.pdf

Replace something in a file:

sed -i 's/ONE/TWO/g' file.txt

Show SW/HW information:

neofetch

Show a ‘show’ like in hacker movies:

hollywood

List block devices, but no loop type:

lsblk -e 7

Convert filesystem to xfs without dump/restore:

fstransform /dev/sda2 xfs

Show amount of dirty disk memory:

grep Dirty /proc/meminfo

Last updated on 2023:01:14 at 00:49 UTC

Leave a Reply

Your email address will not be published. Required fields are marked *