In case of catastrophic data loss or system failure, I've decided that it's safest for me to put a few notes in a public place. Some of these are distro-specific, so know that I use [K]Ubuntu and Fedora.
Ctrl-A Go to the beginning of the line you are currently typing on
Ctrl-E Go to the end of the line you are currently typing on
Ctrl-L Clears the Screen, similar to the clear command
Ctrl-U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl-H Same as backspace
Ctrl-R Search history
Ctrl-C Stop whatever you are running via SIGINT
Ctrl-D Exit the current shell || Send EOF
Ctrl-Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl-W Delete the word before the cursor
Ctrl-K Clear (cut) the line after the cursor
Ctrl-Y Paste the cut from Ctrl-K
Ctrl-T Swap the last two characters before the cursor
Alt-T Swap the last two words before the cursor
Alt-F Move cursor forward one word on the current line
Alt-B Move cursor backward one word on the current line
Alt-. Gives you the last argument of the last command (pressing again goes further back)
Esc Last object. For example: cat /etc/fstab -> vi <Esc> -> vi /etc/fstab
Clear screen: $ clear
Show end of file: $ tail
Display routing table: $ netstat -rn
Add user to sudo: $ username -S sudo
Zip directory with password: $ zip -e -r myzipfile.zip dir/
Have Firestarter (or other service) start in runlevels 3, 4, and 5: $ chkconfig --levels 345 firestarter on
Check swap: # cat /proc/swaps
Check processors: # cat /proc/cpuinfo
Switch to English temporarily: $ export LANG=C
Symlinkng: $ ln -s /path/to/existing/file /path/to/new/link
Changing file time: $ touch -d '3 Jan 2007 15:47:00' file.jpg
Find out top 10 directories eating up your disk space: # du -csh * –max-depth=0 | sort -rn | head -10
Find Harddisk Capacity on the box: # fdisk -l | grep -iE ‘mb|gb|tb’
Find out performance of hard disk: # hdparm -t -T /dev/hda
Tunnel GUI through ssh: $ ssh -X xxx.xxx.xxx.xx
Hardware Information: # dmidecode
Dell Fan Contro: # i8kctl
Find what version (and other info) of package is installed: $ dpkg -s packageName
ls in reverse-time order: $ ls -lrt
Change default web browser: $ sudo update-alternatives --config x-www-browser
Add "rw init=/bin/bash" to the kernel line in grub.
# passwd username
# mount
# umount /dev/cdrom
# dd if=/dev/cdrom of=/home/user/cdimg.iso
$ tar -zcvf - folder/ | openssl des3 -salt -k PASSWORD | dd of=mybackup.tbz $ dd if=mybackup.tbz | openssl des3 -d -k PASSWORD | tar zvxf -
Advantages: No need to make / deflate tarball when encrypting / decrypting.
Disadvantages: Password is part of the commands to make and deflate encrypted file. Therefore, it is visible on the screen and added to History. Note that upon decrypt both the original folder and an unencrypted tarball will be created (verify this).
$ openssl enc -aes-256-cbc -salt -in stuff.tar.gz -out stuff.tar.gz.enc -pass pass:PassWordHere $ openssl enc -d -aes-256-cbc -in stuff.tar.gz.enc -out stuff.tar.gz
Advantages: Password is not part of the command to deflate.
Disadvantages: Password is part of the command to make encrypted file. Therefore, it is visible on the screen and added to History. Additionally, this method adds an extra step (making / deflating tarball) to the encrypt / decrypt process.
$ tar -xzf file.tar.gz $ tar -xjf file.bz2
# mkdir /media/iso # modprobe loop # mount filename.iso /media/iso -t iso9660 -o loop
# fuser -km /dev/cdrom
$ shred -n 200 -z -u filename $ srm filename $ wipe filename
# ifconfig eth0 down # ifconfig eth0 hw ether 00:00:00:00:00:00
$ ps ux (processes owned by current user) $ ps -e (all processes on machine) $ kill 1234 (kill process #1234) $ pkill firefox
$ cat /proc/acpi/thermal_zone/THM/temperature $ acpi -V $ sudo sensors
$ find . -exec grep -q "search" '{}' \; -print // print path of files that contain the text "search" recursively $ grep "search" * // print lines of files in pwd that contains the text "search" $ grep -i "search" `find . -name "*" -print` // print lines of files that contain the text "search" recursively and case insensitive $ grep -i -n 'searchTerm' * // Find files containing search terms
Date Published: 2008-05-08
Date Revised: 2008-07-17