# UNIX command-line tricks

When you’re typing commands in ROOT, IPython, or UNIX, your two best friends are the TAB key and the up-arrow key.

Try it: On a Nevis system, on the UNIX command line, type (<TAB> means to hit the TAB key):

> cp ~seli<TAB>roo<TAB>Cre<TAB>S<TAB> \$PWD


You’ll see how UNIX does its best to fill in the remainder of a word, up to the point for which there’s a choice.

Now list the contents of files in your current directory:

> ls


Let’s execute that copy command again. You don’t have to type it again, even with the help of tab-completion; just hit the up-arrow key twice and press ENTER.

Note

Did you look at the emacs tutorial I mentioned above? If you did, you saw that it starts with a discussion of using special keypresses for cursor navigation. Perhaps you thought, “Have they never heard of a mouse?” If you did, you were right: the emacs tutorial was written before GUIs and computer mice were known outside of Xerox PARC.

Those same key-based navigation commands work on the UNIX and ROOT command lines. You don’t have to type the long commands in this tutorial, at least not more than once. With the help of tab-completion, the up-arrow key, navigation keypresses, and cut-and-paste, you can edit your previous commands for new tasks.

Tip

If you ask me to help you with a problem during the class and I start typing commands for you, you’re going to see me use the up-arrow key, then Ctrl-A, Ctrl-E, Meta-F, and Meta-B to jump the cursor through the commands you’ve typed and make changes.

I’ve grown so used to those navigation commands that when I edit a file, I use emacs -nw (for “no windows”) and skip the GUI features like menus and mouse-clicks. It’s usually faster for me to keep my hands on the keyboard.