Terminals Shouldn't Be Scary!
Terminals are crucial to mastering computers and are super fun to play with. But you don’t need to be a gray beard to master the terminal! You can learn it bit by bit and have fun too. And this isn’t some kind tongue-in-cheek expression. Try to remember the last thing your learned that made some drudgery less drudgeful (like finding out that adding
site:blah.com in Google will limit results to just those from that site.) Wasn’t that fun? This is the same kind of idea.
As a beginner, I wish I had a high level outline of terminal skills that I could then refer back to and incrementally improve over time, because I wanted to be able to spend a bit of time and gain a bit of skill immediately. Like a personal syllabus informed by practicing programmers that you follow every week. But really, incrementally making lists and personal notes is what I ended up doing and that worked very well. So actually, I’d recommend keeping a text file or Evernote note or something about your own terminal skills and simply updating it now and then. Bonus points if you edit that file in a terminal!
Terminal Crash Course is useful and has a lot of introductory material. It’s a full course, though. Here’s a shorter but much denser resource: Terminal Cheat Sheet.
Note: If you’re on OS X, go ahead and install Homebrew. It allows you to install commands you don’t already have access to. If you’re on other operating systems, google for
package manager [operating system] (if you squint, Google looks like a terminal too).
What should be in your list of things to remember? I’ll compile my own list (tested only on OSX):
Things to Remember:
- Built in commands:
- Search for commands even if you don’t know the name:
apropos(searches the short descriptions available in the
whatisdatabase on your system). Related:
- Know about piping inputs, redirection, and background jobs. Useful:
- Know your shell environment. Useful:
env. If you use
zshalong with oh-my-zsh, you have superpowers by default. Like auto-completing switches for commands or env variables or remote host names or using
popdeven when you
chsh -s $(which zsh)to install, and then install oh-my-zsh.
- Manage processes:
- Manage disks:
- Check if commands exist:
- Check the status of a file:
- Find things:
- Edit files:
emacs(it’s a Text Editor/Notepad, except you save things using
Ctrl-X Ctrl-S, quit using
Ctrl-X Ctrl-C, and use arrow keys and the enter key as normal; eg:
emacs file.txt) or
vimor [insert editor here]
- Download things:
- Access other computers:
- Command multiple terminals:
- Munge text:
getswill grab a line for you in Ruby),
sed. Or just write a Ruby script :)
- Snooping around (amazing post about dtrace scripts and basic tools):
- Profiling programs:
dtracescripts (it has a language like
awk’s), language specific tools
I anticipate updating this post in the future, but I think I covered the basics. It’s a hard thing to compress years of habit into one post, but thoroughly refreshing to do too. Hope it helps!
While I listed
man builtin, I should have called out attention to the ever useful
type typetells you
type is a shell builtin. You can use it to find out more about a semi-known or unknown shell invocation of any kind, like
type some_alias(which prints out what
some_aliasis an alias of). Try it on files or environment variables or other commands! It’s in the category of useful meta invocations like
Also, remember that for most commands,
--helpis invariably useful
Here’s a resource with a good mix of beginner-accessibility, shortness of length, and denseness of content (except it’s Linux focused and not OS X focused):
UPDATE 2 from 2015-10-20:
This is an amazing list of links about how to make good use of the command line on OS X machines.