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'. 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.


  1. Ctrl-R allows to interactively search in history (bash/zsh)

  2. Thanks Alex, much faster than my grep approach. It is still sometimes nice to see all matches at once with grep, but your is definitely the better approach.


  3. 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


Post a Comment

Popular posts from this blog

DBPedia Natural Language Interface Using Huggingface Transformer

Custom built SBCL and using spaCy and TensorFlow in Common Lisp

I have a new job helping to build a Knowledge Graph at Olive AI