Wednesday, September 10, 2008

Note To Self: Linux CLI Commands

On Digg today, there's an article with 743 diggs that reads: Explained: 9 useful Linux commands everyone should use! Of all the commands mentioned, this is the only command that I didn't know:
$ free


At the end of that Digged article, there were links to the Ubuntu Community Documentation for the Terminal, which introduces new users to the command line, and a Unix commandline cheat sheet.

The following commands are new to me and will serve me well in the future:

ctrl+a or Home

Moves the cursor to the start of a line.

ctrl+e or End

Moves the cursor to the end of a line.

ctrl+b

Moves to the beginning of the previous or current word.

ctrl+k

Deletes from the current cursor position to the end of the line.

ctrl+u

Deletes the whole of the current line.

ctrl+w

Deletes the word before the cursor.



This one is worth a million dollars:

ctrl+r

Searches for commands you've already typed. When you have entered a very long, complex command and need to repeat it, using this key combination and then typing a portion of the command will search through your command history. When you find it, simply press Enter.

There are so many times when I scroll up looking of a command I used days ago that I used, but can't recall the full syntax. ctrl + r should remdy this problem. Here is another guide to Bash which clarifies how to use the CTRL + R feature:

1. Easily recall previous commands
Bash keeps track of the commands you execute in a history buffer, and allows you to recall previous commands by cycling through them with the Up and Down cursor keys. For even faster recall, "speed search" previously-executed commands by typing the first few letters of the command followed by the key combination Ctrl-R; bash will then scan the command history for matching commands and display them on the console. Type Ctrl-R repeatedly to cycle through the entire list of matching commands.