Networking | Programming | Security | Linux | Computer Science | About

Access Command History

It’s nice of the shell to remember what you have done, for better or worse. Having the shell keep track of the commands you enter makes it easy to return to those gawd-awfully long commands you pecked at a while ago — even days ago! Let me give you an example. Suppose that yesterday you managed to issue a command to find all the core dump files in your system (core dump files are massive files containing debugging data that only an expert programmer or your computer can understand) and delete them. The command looked something like this:

find / -name core -exec rm {} \;

To re-execute the command, all you need to do is fish it out of your shell his- tory and rerun it. The simplest way to read through your command history line by line is to press the up-arrow key repeatedly until you locate the command you want to re-execute. Then just press the Enter key to run the command again. That’s all there is to it!

You can access your command history in two ways:

Published on Fri 02 March 2001 by Lai Yahui in Linux with tag(s): history