Command line tips for OS X and Linux

I wrote last year about keeping .ssh, .gpg, and other sensitive information on an encrypted disk and create soft links so when the disk is mounted, sensitive information is available.

I have a few command line tricks that save me a lot of time that are worth sharing:

  • Use a pattern like history | grep rsync to quickly find recent commands. Much better than wading through your history.
  • Make aliases for accessing services on specific servers for example alias kb2_mongo=’mongo xxx.xxx.xxx.xxx:11222′. By having consistent naming aliases for your servers and for running specific services like the mongo console, it is easy to both remember your aliases and use them.
  • Create aliases with consistent naming conventions to ssh to all of your servers. I use different prefixes for my servers and for each of my customers.
  • Create an alias like alias lh=’ls -lth | head’ to quickly see just the most recently modified files in a directory, most recent first.
  • For your working development system create two letter aliases to get to common working directories (most recent projects, writing, top level code experiment directory, etc.). I try to be consistent and use some of the same aliases on my servers.

3 thoughts on “Command line tips for OS X and Linux

  1. Alex Ott

    You can also press Ctrl-R during search, to move to next matching record (Ctrl-s should also work to search to previous matching record) – this is standard readline (emacs) key bindings

    Reply

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>