Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Command History and Editing the
Command Line

Whatever you type after the shell prompt and before pressing Enter is called a command line. It's a line of text that commands the computer to do something. The Debian default shell offers several features to make entering command lines easy.

You can scroll up to previous commands to run them again, or you can modify them slightly and then run them again. Try this: Enter any command, such as whoami; then press the Up Arrow key. The whoami command will reappear at the prompt. You can then press Enter to run whoami a second time.

If you've entered several commands, you can keep pressing the Up Arrow key to go back through them. This feature is handy if you're doing the same thing several times, or if you type a command incorrectly and want to go back to fix it. You can press the Down Arrow key to move in the other direction, toward your more recent commands. If there are no more commands to move to, the computer will beep.

You can also move around on the command line to make changes. The easiest way is with the Left and Right Arrow keys. Try typing whoasmi instead of whoami, and then use the Left Arrow key to move back to the s. You can erase the s with the Backspace or Delete keys.

There are more advanced features as well (no need to memorize them all now, though). Try pressing Ctrl-a. This moves you to the beginning of the line. Ctrl-k (the k stands for ``kill'') deletes all characters until the end of the line; try it from the middle of the command line. Using Ctrl-a followed by Ctrl-k, you can delete the entire command line. Ctrl-y pastes the last thing you killed, reinserting it at the current cursor position (y stands for ``yank,'' as in ``yank it back''). Ctrl-e will move the cursor to the end of the command line.

Go ahead and play around with command-line editing to get a feel for it. Experiment.

John Goerzen / Ossama Othman

  Published under the terms of the GNU General Public License Design by Interspire