Frequent Commands

For those of you who are relatively new at the UNIX command line, I thought I would show you which commands I use the most often. As you may know, you have a builtin command called ``history,'' which returns the last 500 commands you executed at the command line. You can usually find a list of commands that are built in to your shell by typing man builtin. You'll find commands like alias, alloc, bg, bindkey, break, and so on. Some you'll use a lot, some I don't think I've ever used.

I derive my list from the following command:

history | cut -d' ' -f5 | sort | uniq -c | sort -r | less

This command takes your command line history, cuts each line to just the first word (the command itself), sorts those commands to be fed to uniq, which will remove all duplicate entries and count each instance of each command, and the list is sorted by the number of instances of each command. The output is piped to ``less'', my favorite pager, for easier viewing. For me, this command produced the following output:

  89 ls
  59 history
  38 
  37 mv
  30 cd
  26 locate
  25 mkdir
  20 ssh
  19 man
  17 ps
  13 vim
  11 which
  11 grep
  10 rm
   9 mpg123
   8 sudo
   8 less
   8 gabber
   7 kill
   5 xv
   5 scp
   5 exit
   3 whois
   3 top
   3 killall
   2 whereis
   2 uniq
   2 latex
   2 his
   2 everybuddy
   2 echo
   2 du
   2 df
   1 xine
   1 w3m
   1 updatedb
   1 su
   1 sh
   1 screen
   1 netscape
   1 mysql
   1 latex2html
   1 gaim
   1 gabber\&
   1 file
   1 aterm

You'll notice I have a lot of empty lines (38 of them) and that ls and history are the two commands I use the most. Actually, I was recently experimenting with the ``cut'' command in order to produce this list, so I normally don't use history that much. The empty lines are normally where I type return or type CTRL-C to stop a command in progress. You'll see that I call a number of X applications from the command line on occasion, such as gabber, gaim, netscape, everybuddy. This indicates that I've probably been experimenting with these applications in recent days.

To really see what I use the most, exclude the abberations. Just stick to the commonplace builtin commands or executables normally found in /bin or /usr/bin. When we stick to those, here's the following list:

  89 ls
  37 mv
  30 cd
  26 locate
  25 mkdir
  20 ssh
  19 man
  17 ps
  13 vim
  11 which
  11 grep
  10 rm
   9 mpg123
   8 sudo
   8 less
   7 kill
   5 scp
   5 exit
   3 whois
   3 top
   3 killall
   2 whereis
   2 uniq
   2 latex
   2 his
   2 echo
   2 du
   2 df
   1 w3m
   1 updatedb
   1 su
   1 sh
   1 screen
   1 latex2html
   1 file

As you can see, ls is the most frequent command. Once you know how to use this command, and perhaps a few others, you don't really ever need a file manager again.

There's not enough room for me to explain each and every command here. But, some of the everyday commands you'll use most often are ls, cd, mkdir, mv, cp, ssh, scp, df, du, locate, kill, killall, vi or vim (or whatever text editor you favor), whereis, and whatever aliases you use most.

Aliases are your own key combinations that perform commands as you wish them performed. You can alias ls to ls -a for example, or you might alias ps to ps ax. I have his aliased to history ${1:-22}, which means show the last 22 lines of history (normal length of an xterm window) or whatever argument I supply if any.

Sometimes I use a tty multiplexer called screen. Screen lets you run several virtual windows in a single xterm or tty and allows you to switch between them. For example, I normally have a single xterm running screen with a secure shell connection to each of several hosts on my network. Thus, I don't need to clutter my display with all those extra xterms.

A good text browser will serve you well; I like w3m, but others like lynx. Ssh and scp are commands for secure shell and are secure replacements for rsh and rcp. They are ``musthaves'' as far as I'm concerned.

Du and df are vital commands for checking disk space. Locate is an extremely easy way to find files; it requires that you keep a locate database up to date. On my system, that resides in /var/db/locate.database; on your system it's probably different. If you don't have these, you should know how to use find.

In short, if your command line confidence isn't what you think it should be, ask your resident geek for his or her output from the history command above. See which commands you're overlooking and which command line switches you're neglecting.



David S. Jackson dsj@dsj.net