The following is a list of useful commands that I've learned for Linux, but that I use so rarely, I tend to forget until I need them again.
To rip an entire normal data-cd (ISO filesystem) from a CD-ROM:
dd if=/dev/cdrom of=my_cd_image.iso
To create an iso using files in Linux:
mksisofs -o image.iso path/
wodim dev=/dev/cdrw -v -data cd_image.iso
wodim dev=/dev/cdrw -v -audio [wav files...]
To burn a DVD from the filesystem:
growisofs -dvd-compat -input-charset=ISO-8859-1 -Z /dev/cdrom -R -J -pad "/path/to/source/dir/structure"
To create a blank floppy disk image:
mkfs.msdos -C image.flp 1440
To mount a floppy image:
mount -o loop image.flp /media/floppy1/
To take a video file to a format usable by an iPod or an iPhone:
ffmpeg -vcodec xvid -b 300 -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec aac -ab 96 \
-i source_file.avi -s 320x240 -aspect 4:3 target_file.mp4
Take target_file.mp4 and import into iTunes, then sync with your device.
To mount a Windows or Samba SMB fileshare:
mount -t cifs //ntserver/download -o username=user,password=myPassword /mnt/ntserver
Passing *both* stdout and stderr to the pipe.
<command> 2>&1 | <command2>
Passing only stderr to the pipe:
exec 3>&1 <command> 2>&1 >&3 3>&- | <command2> 3>&- exec 3>&-
Use the following command to dump a directory structure to a remote tape drive:
tar cv --rmt-command=/sbin/rmt --rsh-command /usr/bin/ssh -f <remote_host>:/dev/st0 --directory /path/to/source/dir --label "Label for backup" <directory_name>
Use the following command to recover a directory structure from a remote tape drive:
tar xv --rmt-command=/sbin/rmt --rsh-command /usr/bin/ssh -f <remote_host>:/dev/st0
Of course, as always with the tar command, one can specify the files/sub-directories to be recovered if one wishes.
Add the following to /etc/sysctl.conf:
net.ipv4.ip_forward = 1
Run the following command:
# sysctl -p /etc/sysctl.conf
Verify with:
# cat /proc/sys/net/ipv4/ip_forward 1
$ rsync --verbose --stats --progress --compress --rsh=/usr/bin/ssh --recursive --times --perms --links <src> <dst>
Tweak the $8 == 'D' to look at different states of processes.
top -b -n 1 | awk '{if (NR <=7) print; else if ($8 == "D") {print; count++} } END {print "Total status D: "count}'
Example output
top - 11:33:29 up 8 days, 18:00, 2 users, load average: 5.61, 5.35, 7.00 Tasks: 101 total, 1 running, 100 sleeping, 0 stopped, 0 zombie Cpu(s): 2.7%us, 1.9%sy, 0.0%ni, 78.0%id, 16.7%wa, 0.2%hi, 0.5%si, 0.0%st Mem: 1991292k total, 1975248k used, 16044k free, 56836k buffers Swap: 1150724k total, 36k used, 1150688k free, 1652024k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 334 root 20 0 0 0 0 D 0.0 0.0 5:16.26 kdmflush 959 root 20 0 0 0 0 D 0.0 0.0 4:35.89 jbd2/dm-2-8 1080 root 20 0 0 0 0 D 0.0 0.0 1:53.47 nfsd 1081 root 20 0 0 0 0 D 0.0 0.0 1:58.73 nfsd 1082 root 20 0 0 0 0 D 0.0 0.0 1:52.42 nfsd 1083 root 20 0 0 0 0 D 0.0 0.0 1:51.43 nfsd 1084 root 20 0 0 0 0 D 0.0 0.0 1:58.40 nfsd 1085 root 20 0 0 0 0 D 0.0 0.0 1:50.55 nfsd 1086 root 20 0 0 0 0 D 0.0 0.0 1:51.28 nfsd 1087 root 20 0 0 0 0 D 0.0 0.0 1:58.37 nfsd Total status D: 10