link to content
Essentials at NC State Home
skip header navigation and go to content Help | ResNet | Computing@NC State | For OIT Staff | Publications | Search NC State | Feedback | Site Map
your unity account
antivirus & security
email & messaging
connections & labs
your computer
software@nc state
files
web pages
education & training
publications
other resources
troubleshooting
ITD Sections

Command history

Arrow keys

As you may have already noticed, there are lots of commands to type as you use your account. Because we're not all perfect typists, Unix keeps track of all our commands from the time we log in so that we may quickly use the up and down arrow keys to repeat commands or fix typing errors. This list of commands is called the command history.

For example, suppose that you entered the command

fnger monri@unity.ncsu.edu.

Unix responds with a "command not found" error since what you meant to type was the "finger" command.

To fix your mistake you press the up arrow key once to recall the command. Then you use the left arrow key to position the cursor where the "i" should go. Now type the "i" and press the Return key. Unix will insert the "i" and execute the command.

Repeatedly pressing the up arrow key will take you farther back in the command history, like rewinding a tape. This is extremely useful if you frequently use the same set of commands.

Note that it is not necessary to return to the end of the command before pressing the Return key.

The history command

This command lists previous commands that you have used. It's sometimes useful for finding out how to use a particular command or for determining where you made a mistake in a series of commands.

The syntax for the command is

history n

where n represents the number of commands you wish to have listed.

For example, entering the history command with no n value will list all your previous commands (up to 100). Entering history 15 will list your last 15 commands.

The number in front of each command allows you to access the command via number instead of scrolling through the entire list with the up arrow key.

To recall a command by its number, type an exclamation point and then the number.

For example, if your command history looked like

[sparc03]...kaputnik>history 10
   145  15:40   ls
   146  15:40   man history
   147  15:41   finger pmc@unity.ncsu.edu
   148  15:45   h 15
   149  15:45   elm
   150  15:51   l
   151  15:52   h
   152  15:52   138!
   153  15:52   sort biglist
   154  15:54   h 10
[sparc03]...kaputnik>

you could type !153 to resort your file called "biglist".

 


Last modified July 20, 2004 by cawalker

jump back to content/page ends, begin footer
jump to content
jump to content Go to page top Page Top | Site Map | OIT | Policy Disclaimer | Site Survey