Debian Apt Cheatsheet


Download and build source package apt-get -b source
Download and install dependencies for source package apt-get build-dep
Download source package apt-get source
Install package "on demand" auto-apt run
List contents of a package apt-file list
List installed packages dpkg -l
Remove package and configuration files apt-get --purge remove
Search for Debian Packages
Search for packages apt-cache search
Show package dependencies apt-cache depends
Show package information apt-cache show
Show package that supplies a given file apt-file search
Show package that supplies a given file COLUMNS=132 dpkg -S
Show source package information apt-cache showsrc
Update `apt-file and auto-apt database apt-file update

Shell cheatsheet


The following may not apply to all shells.

Job control

  • Resume job after suspend: ctrl-q
  • Resume job in background: bg <job number>
  • Resume job in foreground: fg <job number>
  • Suspend delay (suspend at stdin): ctrl-y
  • Suspend: ctrl-z

Command line laziness

  • Recall history line 66: !66
  • Recall last command: !!
  • Recall last arguement from last command: !$
  • Recall all arguements from last command: !*
  • Clear shell history: history -c
  • Delete shell history entry: history -d <number>
  • Rename rpmnew files:
find -type f -name "*.rpmnew" | sed 's/\(^.*\)\(\.rpmnew\)$/mv -f \1\2 \1/' |sh
  • Search and replace files in place:
find /path -name "*.*" -exec | perl -pi -e 's///g' {} \;
  • vi cli editing: set -o vi Now esc to enter command mode where vi keys work. Pressing enter returns to normal mode.

POSIX regular expression cheatsheet


Alphabetic [:alpha:]
Alphanumeric [:alnum:]
Control characters [:cntrl:]
Hex numbers [:xdigit:]
Lowercase [:lower:]
Nonespace characters [:graph:]
Numbers [:digit:]
Printable [:print:]
Punctuation [:punct:]
Tab or space [:blank:]
Uppercase [:upper:]
White space [:space:]

Multipathd testing


  1. Format and mount the SAN LUN.
  2. Start a write to the mounted filesystem cat /dev/zero >> /pathto/mnt/testfile &
  3. Now connect to the multipath daemon in interactive mode multipathd -k
  4. View current paths with show maps topology

    multipathd> show maps topology reload: mpath5 (360060e801045249004f2a5f900000031) dm-7 HITACHI,DF600F [size=128G][features=0][hwhandler=0][rw] _ round-robin 0 [prio=1][active] _ 1:0:0:4 sdb 8:16 [active][ready] _ round-robin 0 [prio=0][enabled] _ 2:0:0:4 sdc 8:32 [active][ready]

  5. There are two paths shown as sdb and sdc. Delete one path. del path sdb

  6. Suspend with ctrl-z and check that the write is still happening. ls -l /pathto/mnt If testfile is still growing then the path sdc is working.
  7. Resume multipath with fg 2. Re-add the path. add path sdb
  8. Now remove the other path. del path sdc
  9. Again suspend iwth ctrl-z and check that the test file is growing. If so then resume multipath and re-add the path. add path sdc
  10. Testing complete. Exit with ctrl-c. Kill the write job with kill %1. Remove the test file.