Linux: all 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 *:"

Re-read the partition table:

partprobe /dev/sda

Resize a partition:

parted

-or-

resizepart

-or-

growpart

Disable cloud-init:

touch /etc/cloud/cloud-init.disabled

-or-

echo 'GRUB_CMDLINE_LINUX="cloud-init=disabled"' >> /etc/default/grub
grub-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg

-or-

echo "DefaultEnvironment=KERNEL_CMDLINE=cloud-init=disabled" >> /etc/systemd/system.conf

Show disk space usage:

ncdu /home

Watch kernel messages in a human way:

dmesg -Hw

-or- (on systems with systemd, alternatively)

journalctl -kf

Remove the first line of a text file:

sed '1d' file.txt

-or-

awk 'NR>1' file.txt

-or-

tail -n +2 file.txt

Show all local MAC addresses:

ip addr show | grep -B1 ether

Receive missing keys in Ubuntu:

apt-key adv --keyserver keyserver.ubuntu.com --recv XXX

Last updated on 2025-03-23 at 18:03 UTC

Leave a Reply

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

Filtered by Akismet. (privacy info).