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 of a text file:

cat -s file.txt

Find and display the Windows OEM license keys in BIOS:

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

Copy file between two hosts directly without third one:

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 inplace:

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

Show SW/HW information of a host:

neofetch

Display a ‘show’ like the do it in hacker movies:

hollywood

List all block devices (disks), but no loop type:

lsblk -e 7

Convert a filesystem to xfs without dump/restore:

fstransform /dev/sda2 xfs

Show amount of dirty (unwritten) disk cache memory:

grep Dirty /proc/meminfo

List all network interfaces:

lshw -c network -businfo

Show the IPMI/IDRAC/ILO IP address:

ipmitool lan print | grep "^IP Address *:"

Last updated on 2023:06:01 at 14:26 UTC

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.