What I do with my Shell

Lifehacker suggests the following command to list your most frequently used commands:

history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -r

The idea is to identify your frequent commands and then perhaps alias them to something shorter. Unix being what it is, of course, you’re unlikely to save many keystrokes unless you’re aliasing not just the command but also its arguments. Anyway, on my Mac, I get the following top 10 list:

  • ls: what’s here?
  • cd: go somewhere else.
  • open: Mac-specific; spawns a Finder window if the argument is a directory or spawns the appropriate viewer/editor for a graphics file, Word document, PDF file, etc. I love this command.
  • ssh: connect to another machine (sorry, elysium!).
  • mv: move something to a better place.
  • latex: there can be only one typesetter.
  • less: less is more. No, wait, less isn’t more. Never mind; just display the contents of a text file.
  • df: how much disk space is left? (I was getting close to the limit of my 100 GB!)
  • convert: magical utility that turns any graphics format into any other one.

On my linux machine at work, the same exercise turned up slightly different patterns:

  • ls: or maybe it was the same pattern.
  • cd: like I said…
  • jobs: oh good, something different! I run a lot of jobs on pavonis and often need help remembering what’s still running in which shell.
  • fg: foreground a job, leaving the others to languish in the darkness.
  • screen: oh, the joys of a detachable screen! I want to learn to wield this magic even more.
  • less: less is still more! Or maybe it isn’t.
  • cut: I love cutting and pasting in the shell.
  • bg: dismiss this job into the background wastelands, where it may toil in obscurity!
  • nice: try not to crowd out other users on the same machine.
  • top: find out who is crowding me out on my own machine.

I don’t see myself aliasing any of these in the near future, but it’s a fun self-data-mining exercise. How do you use your shell?

7 Comments
1 of 6 people learned something from this entry.

  1. Judson said,

    July 30, 2008 at 9:37 pm

    (Knew it already.)

    Screen is the light and the truth and the way. Well, Screen and Vim.

    As if you needed them, definite cool points for screen being in your top 10.

  2. Kevin said,

    July 30, 2008 at 10:09 pm

    My bash history only stores 500 entries? Scandalous.

    My screens, once attached, tend to stay attached for too long for screen to make it in to the top ten. At work, my top ten contains darcs, python, grep, and a few other commands related to our version control system. The list at home contains aptitude, sudo, mplayer, ps, killall, and, surprisingly, ./configure.

    ./configure? Really? What have I built from autoconf recently? Weird.

  3. jim said,

    July 31, 2008 at 9:54 am

    (Knew it already.)

    No surprises: ls, cd, vi (blasphemy!), fg, rm, tar, htpasswd (add logins to my secure site), grep, mv, more. I use python a lot, but from within scripts, so it’s underrepresented.

    In the non-typo, least frequently used: S85httpd (restarting the web server after adding mysql), crontab, cat, vipw (add a user account), split, kill, sum, chown, chmod, uptime (which I should note reports: up 305 days, 20:12. Take that, Windows!)

  4. michael said,

    August 26, 2008 at 4:33 pm

    (Knew it already.)

    at the tcsh prompt with autocomplete turned on has the effect of ls.

  5. michael said,

    August 26, 2008 at 4:34 pm

    (Knew it already.)

    computer ate my homework. That would be

    TAB at the tcsh prompt with autocomplete turned on has the effect of ls.

  6. Vince said,

    September 13, 2008 at 5:33 pm

    (Knew it already.)

    I love screen. Absolute greatest tool in the universe.

    One feature that I really like is the shared sessions. I put together shared sessions for jobs that will take a really long time (backups, establishing replication, etc …) so that myself and the other admins can monitor the progress together. Another benefit is that we can see what each other is doing so that we don’t step on each other.

    You can also make the shared sessions read-only. This feature is way more useful than I initially thought it would be.

  7. wkiri said,

    September 14, 2008 at 8:06 pm

    (Learned something new!)

    Cool, I didn’t know that you could do shared sessions with screen. Thanks for the tip!

Post a Comment

I knew this already. I learned something new!