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.

Summary:

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.

Examples:

$ 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
4096

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

Summary:

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.

Examples:

$ 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

Command : $last

last — Show listing of last logged in users.

Summary:

Last searches back through the file, by default, /var/log/wtmp (or -f
file) and displays a list of all users logged in and out, since that
file was created. It shows User Name, Terminal No, Host IP, Login
Date & Time, Logout Time and Total Time.

Examples:

$ last — List all entries.

$ last tty6 — List, who are all logged thru tty6.

$ last pts/6 — List, who are all logged thru pts/6.

$ last bharathi — List all entries of bharathi (user).

$ last -6 — List only last 6 entries.

$ last -R — Don’t show the Host Name field in output.

$ last -a — Show Host Name field in last column.

$ last -i — Show IP Number for Remote host.

$ last -t 20050818120000 — List all entries upto Aug 18 12:00:00 2005.

Read: man last

apt-cache — Debian APT package handling utility

apt-cache — Debian APT (Advanced Package Tool) package handling utility.

Summary:

apt-cache performs a variety of operations on APT’s package cache.
apt-cache does not manipulate the state of the system, but does
provide operations to search and generate interesting output from
the package meta-data (/var/lib/apt/lists).

Examples:

$ apt-cache search xfree86 — Show package info and descriptions for the search-string (xfree86).

$ apt-cache policy gcc — Show version and priorities of the available Packages.

$ apt-cache show postgresql — Show detailed description of postgresql package.

$ apt-cache showpkg mozilla — Show all kind of dependencies for the Mozilla package.

$ apt-cache depends mozilla — List the packages needed by Mozilla.

$ apt-cache rdepends kde — List all packages that needs KDE.

Read: man apt-cache

Command : $chvt

chvt — CHange foreground Virtual Terminal.

Summary:

In GNU/LINUX OS, be default, 6 virtual text mode console terminals
will be running. User can switch between this terminals using Left
Side Ctrl + Alt + FunKey(1 – 6).

chvt command is also used to switch between this terminals. It can
be used in shell scripts.

Examples:

$ chvt 1 — Switch from current terminal to /dev/tty1.

$ chvt 2 — Switch from current terminal to /dev/tty2.

Read: man chvt

TIP: Screen Dump in Text console.

# sudo cat /dev/vcs2 > scrdump.txt — Take the screen dump of
/dev/tty2 in scrdump.txt file.

Next Page »



Follow

Get every new post delivered to your Inbox.