Ad hoc commands

// archive From the original Code Walker docs. Kept for reference, so some versions and commands may be out of date.

This page includes a bunch of useful adhoc commands and tricks.

Create a large file#

dd if=/dev/urandom of=/var/log bs=1M count=2048

Write ISO to device#

dd if=image.iso of=/dev/sda status=progress

Remove Password from protected PDF#

dnf install qpdf
qpdf --password=changeme --decrypt secure.pdf unsecure.pdf

Generate a UUID#

uuidgen

Find files modified in the past X days#

find /dir -mtime -X 

Remove comments and blank lines from a file#

grep -v -e '^#' -e '^$' /etc/sysconfig/sshd > /var/tmp/sshd

Find lines starting with string#

grep -R ^root /etc/ 2> /dev/null > /var/tmp/results.txt

Run in background and redirect the output to file#

nohup command &> output.out &

Wait for all systemd-udevd events to finish#

udevadm settle