keyboard shortcut tricks within the terminal

Get lightning fast and clever at the command line

You can use keyboard shortcuts and other command line tricks to make entering commands easier and faster. You might already know about the ‘tab’ key which completes partial commands and even file and directory names.

Here are some other keyboard shortcuts you can use within terminal:

Ctrl-a               Move to the start of the line.

Ctrl-e               Move to the end of the line.

Alt-] x             Moves the cursor forward to the next occurrence of x.

Alt-Ctrl-] x    Moves the cursor backwards to the previous occurrence of x.

Ctrl-u               Delete from the cursor to the beginning of the line.

Ctrl-k               Delete from the cursor to the end of the line.

Ctrl-y               Pastes text from the clipboard.

Ctrl-l                Clear the screen leaving the current line at the top of the screen.

Ctrl-xCtrl-u    Undo the last changes. Ctrl-_

Alt-r                  Undo all changes to the line.

Alt- Ctrl-e       Expand command line.

Ctrl-r                 Incremental reverse search of history.

Alt-p                  Non-incremental reverse search of history.

!!                          Execute last command in history

!abc                    Execute last command in history beginning with abc

!n                         Execute nth command in history

^abc^xyz         Replace first occurrence of abc with xyz in last command and execute it

* info taken from KanchiLug



dos2unix — DOS/MAC to UNIX text file format converter.


Each OS will indicate the line end differently using Line Feed (LF,10)
or Carriage Return (CR,13). So when tranfering a file from DOS to
Unix, you have to convert the Line end from DOS format to Unix format.

dos2unix will convert the DOS/MAC Text file to Unix format. Unix or
Linux uses LF as line end, Windows/DOS uses CR/LF and MacOS uses CR.


$ dos2unix dos.txt — Convert and replace dos.txt.

$ dos2unix -n dos.txt gnu.txt — Convert dos.txt and
write into gnu.txt

$ dos2unix -k dos.txt — Convert and replace a.txt while
keeping original date stamp.

Read: man dos2unix

How to view the process activity in ubuntu 9.04?

Top is a command that provides a dynamic real-time view of a running system By default, it

By default – Displays CPU-intensive tasks running on the server

Some Hot keys provided in TOP command

t  – Displays summary information off and on.
m – Displays memory information off and on.
A – Sorts the display by top consumers of various system resources.
f –  Enters an interactive configuration screen for top.
o – Enables you to interactively select the ordering within top.
r – Issues renice command. k Issues kill command.
z – Turn on or off color/mono

How to find Virtual Memory PAGESIZE in Ubuntu 9.04 ?

A page is a fixed length block of main memory, that is contiguous in both physical memory addressing and virtual memory addressing.

Kernel swap and allocates memory using pages

To Know the PAGESIZE

$ getconf PAGESIZE

result :
verman@verman-desktop:~/$ getconf PAGE_SIZE

How to check Linux kernel in your PC?

uname command with the -a option prints all system information, including machine name,kernel name & version, and a few other details.

For Example :

verman@verman-desktop:~$ uname -a
Linux verman-desktop 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686 GNU/Linux

Check here for more info

How to check Linux release in your PC?

lsb_release command with the -a option prints
version information for the Linux release you’re running

For Example :

verman@verman-desktop:~$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 7.10
Release: 7.10
Codename: gutsy

Command : $bg

bg — Place a job in BackGround


Normally user can run a job in background, by adding & at end of the
command (ex: sleep 10 &).

bg is a shell command. It is used to move a job from foreground to the
background, as if it had been started with `&’. If JOB is not present,
the shell’s notion of the current job is used.


$ sleep 100 — Start a dummy job in foreground.
Press Ctrl+z to stop the current job.

$ bg — Move the last stopped job to background.

$ sleep 150 — Dummy job 1
Press Ctrl+z to stop the current job.

$ sleep 140 — Dummy job 2
Press Ctrl+z to stop the current job.

$ sleep 130 — Dummy job 3
Press Ctrl+z to stop the current job.

$ jobs — List all active jobs.

$ bg 2 — Move the 2nd active job to background.

Read: help bg, jobs