Sam's Long Random List of Unix Notes
     
          
  
          
 
    Unix is one ugly duckling. It's also awesome. I don't care
    what anyone says, maybe it isn't for everyone, but it's hard
    not to admire something about it. I've used Unicies of
    various kinds and I love 'em all. Trouble is my memory's spotty
    as hell. So when I come across something in the Unix world I
    just love, I try and jot it down here. I also jot down other
    notes and craziness regarding things less Unix centric, such as
    Python notes or Firefox notes.
    Organization's not my strong point. Good luck readin' this.
    I hope you find it useful.
    Emacs
    I use GNU emacs where I can get away with it (It's damn hard
    sometimes, it often won't come on small boot-able Linux systems
    of which I surprisingly find myself in from time to time, in
    which case it's often Nano or *GASP* a vi-flavor-of-the-month).
    My problem is I often forget the emacs-lisp incantations I like
    to keep in my .emacs file, so here's my safe,
    simple, emacs file in case I need it, as well as my
    Elisp libraries I use, and here's a list
    of common emacs lisp settings and lore I can't live without and
    can't often remember :-D. I often find I need to spend time
    tweaking gnu emacs when I load it up for the first time on a
    system, so I've set this place up as my cheat sheet, and emacs
    resource page.
    I can't emphasis enough how useful the Emacs Wiki is to us Emacs
    users. It's invaluable and a far cry better than these loose
    notes.
    
      - WHEN IN DOUBT, LAUNCH MR. EMACS WITH "-q" AND
      COMPLETELY DISREGARD A TERRIBLE BROKEN STARTUP FILE, USE
      --no-site TO RUN EMACS WITHOUT CUSTOM SITE-WIDE
      CONFIGURATIONS
- Remember, for Emacs novices, you can use the menu, even
      in a terminal. F10 will get you to the menu, but if the
      terminal emulator you're using doesn't let you send f10, you
      push ESC ` instead. There's lots of useful
      functions you can access easily from the menu, and if one of
      them happens to be bound to a keyboard shortcut, it'll tell
      you what it is after using it.
- (setq backup-directory-alist '(("." .
      "~/.my_backups"))) Helps keep those backup files
      from cluttering your directories. Make sure the directory
      "~/.my_backups" exists!
- M-x normal-erase-is-backspace to fix the
      inevitable backspace problems one faces when jumping between
      Mac PC environments and terminal emulators.
- Saving editing sessions is incredibly useful
      with(desktop-load-default) (desktop-read)in
      the .emacs file. Don't forget to save your session the first
      time with M-x desktop-save and don't forget
      to start Emacs in the same directory as before!
- (setq dired-recursive-copies t) and (setq
      dired-recursive-deletes t) to copy and delete
      recursively in Dired (Emacs' DIRectory EDitor).
- Rings are incredible things in Emacs, never forget about
      them! There's the kill ring, the search ring, and the mark
      ring. To cycle through the kill ring C-y then
      M-y to cycle through the last few things
      killed in the current buffer. They're always there until the
      kill ring runs out of room, and it'll keep looping, so it's a
      great robust way to save text. The mark ring is perhaps the
      most under used and under appreciated feature of Emacs in my
      opinion. You can set the mark with
      C-<SPC> which will also allow you to
      set the region by moving the point, but you can also move
      back to the mark and cycle through all your recent marks in
      the current buffer with C-u
      C-<SPC>
- Macros, Macros, and more Macros. Never forget about
      Macros. C-x ( to start one, and C-x
      ) to finish it off. C-x e to execute
      it. C-u C-x ( to execute and add more to it.
      M-x name-last-kbd-macro to name it for later.
      C-x C-k Edit a previously defined keyboard
      macro, and M-x
      apply-macro-to-region-lines to run it over your
      highlighted region. There's an elisp package "kmacro.el" that
      provides even more macro goodness including a Macro ring. And
      don't forget M-x insert-kbd-macro, I have a
      tendency to write useful macros out to a hidden file in the
      working directory of a project called ".macros.el" so I can
      load 'em later. If you want to make a named keyboard macro
      the current keyboard macro, just define another macro and
      call the macro via M-x
- Dired is awesome once you get used to it. I've heard that
      people who despise Emacs will use it. It's the ultimate tool
      to clean up Emacs' poo (backup files, auto-save files, etc.);
      search the contents of each file in a directory structure for
      a regular expression; copy, compress and make backups; load
      and compile elisp libraries; and batch rename files. Pop into
      a directory with C-x C-f. Use this awesome
      sequence of commands to rename a series of files based on
      regular expressions:
- Emacs is the ultimate BBEdit
      for unix when it comes to converting ascii formats and
      character sets. C-x RET f let's you change
      what format the text you're working on is for writing. A
      super quick way to convert Mac->PC->Unix Ascii.
- Man can type any character in the Emacs world by quoting
      it with C-q. The rest is up to your terminal emulation
      software and its ability to send that character..
- Info-directory-list is a useful variable
      for maintaining locally installed Info documentation. If you
      don't have root on a machine, it's impossible to install Info
      documentation site wide so you'll need to use this variable.
      However, the better mechanism is to set the INFOPATH
      environment variable. This can be tricky, because you need to
      explicitly point INFOPATH to site-wide directories as well.
      Mine looks like this on the SDF:
      INFOPATH="~/.elisp/info/":"/usr/pkg/info/":"/usr/share/info/"
Bash
    Sed, Awk, tr
    I don't normally touch these tools, but here's a few
    invaluble one-liners that have gotten me out of more than a few
    jams.
    Ispell/Aspell
    ssh,scp
    
      - ssh -L <localport>:<tunneled remote
      host>:<port on remote host> user@host --
      The magical incantation for local port forwarding.
- ssh -R <remoteport>:<tunneled local
      host>:<port on local host> user@host --
      Basically the opposite of -L, a great way to get into a
      machine behind a firewall if you have local access. Just ssh
      out from it to your home computer, or a computer with ssh
      access. Leave the connection open and then tunnel right back
      in.
- scp <localfile>
Rsync
    
      - The follow is pretty much how I always use rsync to
      update conf files between machines: rsync -r -tv
      --delete-after -e ssh localdir1 localdir2 ... localdirn
      user@host:.. Turns on recursion, preservation of
      timestamps, verbose output, delete-files not present on the
      local machine, and use ssh.
Wget
    
      - wget --no-host-directories/-nH I think
      this is an annoying default, but I guess it aint all bad, it
      does help keep things a bit safer and accounted for. None the
      less I like to get rid of 'em quick like. In fact I often
      alias wget='wget -nH' in Bash.
- wget -m for mirror mode. If I'm pulling
      down more than one thing off the web I generally use
      this.
- You almost always want to call wget with -np which stands
      for No Parent and means that you don't recurse higher than
      the first directory fed to wget. Trust me on this one, it can
      be very bad.
OpenSSL
    Find
    CVS
     
          
  
         