Saturday, July 12, 2008

Essenstial skills:navigating the terminal

The standard terminal on Ubuntu is Gnome Terminal which can be found in Applications → Accessories → Terminal. A terminal is in a way very similar to a file manager in that it's always inside a specific folder and is able to navigate to other folders and do regular file management. By default it will be inside your home folder when you run it. To confirm that your terminal is indeed browsing your home folder, type pwd ending with a press on enter. The pwd command will output the path to the current folder.

To see a list of files and directories inside the current directory, run the command ls. If you want to navigate up the directory tree run cd ... If you want to navigate down the directory tree run cd NAME where NAME is the name of the folder you want to navigate to. Example: if Tom is inside his home folder and there's a directory called test inside it, he will run cd test to change directory. If he wants to go back he can run cd ... If he ever gets lost he can run cd by itself; this will take him back to his home folder.

--------------------------------------

Cursor Movement

You can navigate with the cursor using the same keystrokes as you would use in Emacs. A few examples:

C means the "Ctrl" key. M means the "Alt" key (meta key). Often the Ctrl key will act on one character (or smaller unit) and the Meta key (Alt) will act on one word (or larger unit).

  • C-f — Forward one character.
  • C-b — Backwards one character.
  • M-f — Forward one word.
  • M-b — Backwards one word.
  • C-a — Move to the beginning of the line.
  • C-e — Move to the end of the line.
  • C-d — Delete one character.
  • M-d — Delete one word.

You can also highlight text and use Ctrl-Shift-c to copy, and Ctrl-Shift v to paste (at least in GNOME Terminal in Ubuntu).

Scrolling the Terminal

To scroll the terminal text, use Shift-PageUp and Shift-PageDown. In GNOME terminal you can also use the mouse wheel to scroll.

Terminal History

Your computer stores a history of commands that you type. You can use the up arrow key or down arrow key to navigate through your history.

You can view your history by typing history in the terminal.

You can search for a previously typed command by using the key combination C-r (which means "reverse search" in Emacs).

You can also use grep to find previously typed commands like this: history | grep "search words here"


Excellent tutorial here:

http://ubuntuforums.org/showthread.php?t=73885

No comments:

Blog Archive