Working in linux terminal

Virtual terminals
Ctrl + Alt + F1 - Switch to the first virtual terminal. In Linux, you can have several virtual terminals at the same time. The default is 6.
Ctrl + Alt + Fn - Switch to the nth virtual terminal. Because the number of virtual terminals is 6 by default, n = 1...6.
tty - Typing the tty command tells you what virtual terminal you're currently working in.
Ctrl + Alt + F7 - Switch to the GUI. If you have the X Window System running, it runs in the seventh virtual terminal by default in most Linux distros. If X isn't running, this terminal is empty.
Note: in some distros, X runs in a different virtual terminal by default. For example, in Puppy Linux, it's 3.

Command line - input
Home or Ctrl + a Move the cursor to the beginning of the current line.
End or Ctrl + e -  Move the cursor to the end of the current line.
Alt + b         - Move the cursor to the beginning of the current or previous word. Note that while this works in virtual terminals, it may not work in all graphical terminal emulators, because many graphical applications already use this as a menu shortcut by default.
Alt + f         - Move the cursor to the end of the next word. Again, like with all shortcuts that use Alt as the modifier, this may not work in all graphical terminal emulators.
Tab             - Autocomplete commands and file names. Type the first letter(s) of a command, directory or file name, press Tab and the rest is completed automatically! If there are more commands starting with the same letters, the shell completes as much as it can and beeps. If you then press Tab again, it shows you all the alternatives. This shortcut is really helpful and saves a lot of typing! It even works at the lilo prompt and in some X applications.
Ctrl + u        - Erase the current line.
Ctrl + k        - Delete the line from the position of the cursor to the end of the line.
Ctrl + w        - Delete the word before the cursor .
Ctrl + t             -  Switch 2 characters on a command line. If you typed sl, put the cursor on the l and hit ctrl+t to get ls.
Ctrl + b           - Moves to the beginning of the previous or current word

Command line - output
Shift + PageUp - Scroll terminal output up.
Shift + PageDown - Scroll terminal output down.
clear - The clear command clears all previously executed commands and their output from the current terminal.
Ctrl + l - Does exactly the same as typing the clear command.
reset If you mess up your terminal, use the reset command. For example, if you try to cat a binary file, the terminal starts showing weird characters. Note that you may not be able to see the command when you're typing it .
Ctrl+S Ctrl+Q - terminal output lock and unlock. These are simple shortcuts to pause and continue terminal output, works in most terminals and screen multiplexers like screen. You can use it to catch something if things change too fast, and scroll with Shift + PgUp PgDown. On linux console ScrollLock can also be used.

Command line - history
history - When you type the history command, you'll see a list of the commands you executed previously.
ArrowUp or Ctrl + p - Scroll up in the history and edit the previously executed commands. To execute them, press Enter like you normally do.
ArrowDown or Ctrl + n - Scroll down in the history and edit the next commands.
Ctrl + r - Find the last command that contained the letters you're typing. For example, if you want to find out the last action you did to a file called "file42.txt", you'll press Ctrl + r and start typing the file name. Or, if you want to find out the last parameters you gave to the "cp" command, you'll press Ctrl + r and type in "cp".
Sudo !! - Run last command as root

Command line - misc
Ctrl + c - Kill the current process.
Ctrl + z - Send the current process to background. This is useful if you have a program running, and you need the terminal for awhile but don't want to exit the program completely. Then just send it to background with Ctrl+z, do whatever you want, and type the command fg to get the process back. 
Ctrl + d - Log out from the current terminal. If you use this in a terminal emulator under X, this usually shuts down the terminal emulator after logging you out.
Ctrl + Alt + Del - Reboot the system. You can change this behavior by editing /etc/inittab if you want the system to shut down instead of rebooting.

Originals: TuxFiles + Bonuses


Command LOCATE usage and errors fixing

Need to find a file fast on a linux filesystem? Use the linux locate command
[root@localhost /]# locate openssl
Possible error during command initialization:
locate: can not open `/var/lib/mlocate/mlocate.db
Type updatedb to fix this problem
[root@localhost /]#updatedb


VIM commands. Part 2


Search “word” from top to bottom
Search “word” from bottom to top
Search “john” or “joan”
/\< the
Search “the”, “theatre” or “then”
Search “the” or “breathe”
/\< the\>
Search “the”
/\< ….\>
Search all words of 4 letters
Search “fred” but not “alfred” or “frederick”
Search “fred” or “joe”
Search exactly 4 digits
Find 3 empty lines
:bufdo /searchstr/
Search in all open files

VIM Editor Commands, with examples. Part 1

Vim is an editor to create or edit a text file. There are two modes in vim. One is the command mode and another is the insert mode.
In the command mode, user can move around the file, delete text, etc.
In the insert mode, user can insert text.

Changing mode from one to another
From command mode to insert mode type a/A/i/I/o/O ( see details below)
From insert mode to command mode type Esc (escape key)
Some useful commands for VIM
Text Entry Commands (Used to start text entry)
a Append text following current cursor position
A Append text to the end of current line
i Insert text before the current cursor position
I Insert text at the beginning of the cursor line
o Open up a new line following the current line and add text there
O Open up a new line in front of the current line and add text there


Configure network settings in linux via terminal

Applies to (Centos, Fedora, Red Hat Enterprise Linux 5)
Simple method:
# ifconfig eth0 netmask broadcast
Or manually edit configuration files stored in /etc/sysconfig/network-scripts/

You can configure network card by editing text files stored in /etc/sysconfig/network-scripts/ directory. First change directory to /etc/sysconfig/network-scripts/:
# cd /etc/sysconfig/network-scripts/
You need to edit / create files as follows:
  • /etc/sysconfig/network-scripts/ifcfg-eth0 : First Ethernet card configuration file
  • /etc/sysconfig/network-scripts/ifcfg-eth1 : Second Ethernet card configuration file
To edit/create first NIC file, type command:


This site is running TeamViewer.

Instructions on how to disable TeamViewer from listening on Port 80. Instructions are as follows:

1. Open port 5938 (TCP) on your firewall.
2. Change the following registry keys.

TeamViewer\Version4] Key ’GatewayAllowed’ set to 0
[HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version4] Key ’ListenHttp’ set to 0

After you make these changes, you should no longer have TeamViewer listening in on port 80, killing your local web server.


Cisco IOS Packaging Codes

Feature Set
Crypto Incl.
Memory Loc.
Compression Format
Maintenance Release
Individual Release
Numbered Version


Feature Set
No Crypto Incl.
Memory Loc.
Compression Format
Maintenance Release
Individual Release
Numbered Version


How to Enable or Disable Quick Launch in Windows 7

By default Quick Launch is disabled in Windows 7. This will show you how to enable or disable Quick Launch on the taskbar in Windows 7 as a toolbar with small or large icons.

Quick Launch is used to open a program quickly from a shortcut on the taskbar. In this case in a toolbar The Quick Launch folder is located at the hidden system folder location (step 2) of:

C:\Users\(user-name)\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch

Windows Explorer Taskbar Icon - Change Open To Target

1. Right click on the pinned Windows Explorer taskbar icon, then right click on Windows Explorer in the Jump List and click on Properties. (See screenshot below)



Setting UP VNC

What is VNC?
VNC stands for Virtual Network Computing. It is remote control software which allows you to view and interact with one computer (the "server") using a simple program (the "viewer") on another computer anywhere on the Internet. The two computers don't even have to be the same type, so for example you can use VNC to view an office Linux machine on your Windows PC at home. VNC is freely and publicly available and is in widespread active use by millions throughout industry, academia and privately.
For more information, please visit http://www.realvnc.com/
Do I have it in my system?
Type following command to check if you have the client and server installed in your system.
[tchung@tchung101 tchung]$ rpm -q vnc vnc-server
[tchung@tchung101 tchung]$

Meaning of "> /dev/null 2>&1"

You need to understand the theory first and then its upto you how and where you want to apply that theory. I'll try to explain above to you.

The greater-than (>) in commands like these redirect the program’s output somewhere. In this case, something is being redirected into /dev/null, and something is being redirected into &1.

Standard in, out and error:

There are three standard sources of input and output for a program. Standard input usually comes from the keyboard if it’s an interactive program, or from another program if it’s processing the other program’s output. The program usually prints to standard output, and sometimes prints to standard error. These three file descriptors (you can think of them as “data pipes”) are often called STDIN, STDOUT, and STDERR.

Sometimes they’re not named, they’re numbered! The built-in numberings for them are 0, 1, and 2, in that order. By default, if you don’t name or number one explicitly, you’re talking about STDOUT.

That means file descriptor 0 or fd0 denotes STDIN or standard input and file descriptor 1 or fd1 denotes STDOUT or standard output and file descriptor 2 or fd2 denotes STDERR or standard error.

You can see the command above is redirecting standard output into /dev/null, which is a place you can dump anything you don’t want (often called the bit-bucket), then redirecting standard error into standard output (you have to put an & in front of the destination when you do this).

The short explanation, therefore, is “all output from this command should be shoved into a black hole.” That’s one good way to make a program be really quiet!


Manage Network Interfaces in Linux

Show info:
ifconfig -a or -v
ifconfig eth1
Disable/Enable interface:
ifconfig eth1 down or up
ifdown eth1
ifup eth1


YouTube Hidden features

YouTube hidden features


Setup VPN Server/Client in Windows 7

Following are the steps for configuring Incoming VPN Connection in Windows 7

  1. First go to Control Panel and open Network and Sharing Center.
  2. Click on Change adapter settings.
  3. Press Alt+F and select New Incoming connection
  4. Put a check on who you’d like to give access to this computer or you can configure a new account by clicking on Add someone,after that click on Next.
  5. Put a check mark on Through the Internet. Click on Next.
  6. Select the protocols you want to enable for this connection. Click on Allow access.
  7. Make a note of the Computer name as this will be used by the client to connect to this computer and after that Click on Close.

Following are the steps for configuring Outgoing VPN Connection in Windows 7

  1. First go to Control Panel and open Network and Sharing Center.
  2. Click on Set up a new connection or network.
  3. Select Connect to a workplace then click on Next.
  4. Select Use my internet connection (VPN).
  5. Type the IP address or computer name where you wish to connect and your connection name under the Destination name field.
  6. Enter a User name and password that has been granted access to the host computer.
  7. For getting connected through created VPN connection, you can either right-click on the Network icon in the system tray and select Network and Sharing Center or go to Control Panel and open Network and Sharing Center, and click on Connect to a network.
  8. Now connect VPN Connection windows will appears.


Intall not signed packeges with yum

yum --nogpgcheck install "examplePackage"

Same as:

1 rpm -ivh package.rpm

2 yum localinstall package.rpm

3 Edit /etc/yum.conf or repository.repo and change the value of gpgcheck from 1 to 0 (!dangerous)


Add an Additional Disk Drive to Your Linux Computer

First of all check if your Linux can see new device:
sudo fdisk -l
Command and Response Dialog of Adding a New IDE Drive:

As root perform the following: (as highlighted in bold)
[root]# fdisk /dev/hdb Command (m for help): m (Enter the letter "m" to get list of commands) Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)


RPMforge Repository for CentOS

RPM packages for Red Hat, RHEL, CentOS and Fedora

Installation for CentOS 5:

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

Original at dag.wieers.com

Karan Repository for CentOS

Fedora Extras rebuild Repository
Download file : kbsingh-CentOS-Extras.repo and save it in /etc/yum.repos.d/

Misc Packages rebuild Repository

Download file : kbsingh-CentOS-Misc.repo and save it in /etc/yum.repos.d/

Apply GPG key
The GPG key used to sign packages in this repository can installed by running ( as root )
    rpm --import http://centos.karan.org/RPM-GPG-KEY-karan.org.txt

Original: centos.karan.org

If you can't execute commands without full pass to them :

E.g. shutdown, reboot, mtr:
Do next:
Edit your .bash_profile

$ vi .bash_profile

Change PATH line to this:

 There should be export PATH in the end of file

To apply changes you have to do next thing:
. .bash_profile
Or try to logout and log back in.

.bash_profile file example:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc

# User specific environment and startup programs


export PATH

mtr: unable to get raw sockets

Do next as root:

# chmod 4755 /usr/sbin/mtr