Merge Two or More PDFs into a New Document
pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf
CHROOT from Live CD
mount /dev/ /mnt mount -t proc none /mnt/proc mount -o bind /dev /mnt/dev chroot /mnt /bin/bash mount -a
Share an X11 Session via VNC
x11vnc -display :0
Show Firewire Devices
plugreport
Sort groups by GID
cat /etc/group | sort -t : -k 3 -n
Get next local UID
cat /etc/passwd | grep -v nobody | awk -F : '{print $3}' | sort -n | tail -n 1 | awk '{print $1+1}'
Get next local GID
cat /etc/group | grep -v nogroup | awk -F : '{print $3}' | sort -n | tail -n 1 | awk '{print $1+1}'
Send Gratuitous ARP Packet
arping -c 1 ip-address
Time Lapse Picures
motion.config:
snapshot_interval 60 output_normal discrete off height 1024 width 1280
motion -c motion.config
Entropy
If entropy_avail is consistently low, install rng-tools. This is designed to use a hardware random number generator, but in the absence of that, it can "fake" it by using /dev/urandom to generate entropy with the following command.
/usr/sbin/rngd -s 64 -t 60 -b -r /dev/urandom
Escape spaces in a variable
"$(echo "$VAR" | sed 's/[ ]/\\\ /g')"
Convert lower case to upper case
echo $1 | tr "[:lower:]" "[:upper:]"
Convert upper case to lower case
echo $1 | tr "[:upper:]" "[:lower:]"
Recursively rename all files in a directory to all lowercase
IFS=" "; for x in `find /path/to/directory`; do mv "$x" "`echo $x | tr \"[:upper:]\" \"[:lower:]\"`"; done
Force script to run as root
if [ `whoami` != "root" ]; then sudo $0 $* exit fi
Convert hex to decimal
echo $((0x15a))
SELinux
Disable SELinux in grub by appending the following to the kernel line
selinux=0
Create pcap file
tcpdump -nn -w tcpdump.pcap -s0 *rules*
Create AVI from JPG files
mencoder "mf://*.jpg" -mf fps=4 -ovc lavc -o movie.avi
mencoder "mf://*.jpg" -mf fps=30 -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=4900 -o movie.avi