Linux Unix help !!

"Give respect to Time, One day at right Time, Time will respect You"

Sunday, November 28, 2010

Power of vi editor Linux

Power of vi Editor
=========
# vim /home/shirish/myscripts/scratcher.sh <-- colorfull look
# vi  /home/shirish/myscripts/scratcher.sh  <-- simple
Moving through the text is usually possible with the arrow keys. If not, try:

h -> move Left
l  -> move Right
k -> move up
j -> move down

shift+H : top of file  (or :1 similarly you can go to any line by line number(n) :n)
shift+G : end of file (or :$)

dd       --> delete current line
5+dd   -> delete 5 line from current line (similarly n line)
5+dw   -> delete 5 words from current word
x         -> delete single character from current position
cc        -->cut all current line  content & leave the editor in insert mode
C         --> delete all words from current position to end of line.
s         -->cur the current character and leave te curser in insert mode

yy       -->copy line
n+yy   --> copy n lines
pp       -->paste copied line etc..
n+pp   -->paste n times

Insert Mode:
1> i   or I (cpas i)
2> Insert button
3> a (+move curser to 1 position right)
4> A (+ move the curser at end of line)
5> o  (+ a blank line below current)
6> O (+ a blank line above current)

Command mode:  ESC button

:w   -> Save
ESC+z+z --> Save & exit
:wq  -> Save & Exit
:q    -> Exit
:q!   -> Exit without Save
:w file2 will save the text to file2.
:wq! overrides read-only permission
/find  -->Search string "find"  use "n" to search new location
? find --> same as above but search in opposite dir
:1, $s/shirish/shukla/g  -->replace shirish by shukla throught file

undo & redo:
esc+u --> undo
ctl+r   --> redo
esc .  --> repeate the previous change

Bookmark

step 1> Go to the required word (type ESC+ma) you can use any lowercase  a - z, A - Z, [  ect,..   note that a & A store diff bookmarks etc..
step  2>To go to bookmarked location (type ESC+ `+a  ) note ` is above TAB button, similarly you can give various bookmarkes
* You can go to yu last edited line by -->  ESC+`+ .

:marks   --> Will show  your bookmarks in current file.

Quick Summary of Vim Bookmark Commands

    * ma –> Creates a bookmark called a
    * `a   –> Jump to the exact location (line and column) of the bookmark a
    * ‘a   –> Jump to the beginning of the line of the bookmark a
    * :marks –> Display all the bookmarks
    * :marks a –> Display the details of the bookmark with name a
      `. –> Jump to the exact location (line and column) where the last change was performed
    * ‘. –> Jump to the beginning of the line where the last change was performed

Advanced:

K --> Go to the man page of the word currently under the curser.

How to schedule cron job Linux

Schedule Crontab jobs

Crontab
It's a unix solaris utility that tasks to be run automatically in background at regular interval.
Daemon: crond

Accessibality:
/usr/lib/cron/cron.allow -> Use can use if your name exist in this file
In absence of this file it's necessary that your name does not exist in
/usr/lib/cron/cron.deny.
And If only cron.deny exist but empty then all users can use crontab.
But if neither exists only root can use crontab.

Commnad:
crontab -l ->List crontab file
crontab -e ->Edit crontab file
crontab -r ->Remove crontab file

====Crontab file fields

* * * * * command to be executed

|  |  |  |  |
|  |  |  | +----- day of week (0 - 6) (Sunday=0)
|  |  | +------- month (1 - 12)
|  | +--------- day of month (1 - 31)
|  +----------- hour (0 - 23)
+------------- min (0 - 59)

Example:
0> Edit crontab for root 
# Login as root
# crontab -e


1>Edit crontab for user shukla
# crontab -u shukla -e

2>Display crontab defined by user shukla
# crontab -u shukla -l

3>Delete shukla's tmp file /home/shukla/dumps/*.* every day at 3:30pm
# crontab -u shukla -e
30 15 * * * * rm /home/shukla/dumps/*

4>Do above every monday-wednesday at 3pm but only in mnth of august
# crontab -u shukla -e
* 15 * * 8 1-3 rm /home/shukla/dumps/*

5>Do above on 1,23 of aug
* 15 1,23 * 8 1-3 rm /home/shukla/dumps/*

6>Do Above at 10:10AM and 6:20pm everyday...
10,20 10,18 * * * rm /home/shukla/dumps/*

7> Sample tricky examples
>Run Every hour
0 * * * * ....
>Run every min
* * * * * * ....

 >Run every 5 min
*/5 * * * *  .....

>Run ever 2 hour interval eg:00:05, 02:05
5 */2 * * *

>Ever month except april
* * * jan-mar,5-12 * * OR
* * * 1-3,5-12 * *

>On every reboot display msg alert
@reboot wall "PC is going to REBOOT"

>Ever hour same above --->this will run 1st sec of every hr equivalent to (0 * * * *)
@hourly wall "PC is going to REBOOT"

Some similar too:
@yearly --> (0 0 1 1 *)
@annually --> (0 0 1 1 *)
@monthly --> (0 0 1 * *)
@weekly --> (0 0 * * 0)
@daily --> (0 0 * * *)
@midnight --> (0 0 * * *)

--Shirish Shukla

Thursday, November 18, 2010

Linux History command tips & Tricks

History Command Tips:

1>Generally # history displays only commands you tiped last Suppose you want time too then...?

# export HISTTIMEFORMAT='%F %T '
# history | more
1  2010-11-11 15:05:20 top
2  2010-11-11 15:05:25 man top
3  2010-11-11 15:05:29 free -m
4  2010-11-11 15:10:05 cat /proc/mdstat

2>Search last hosory by ctl+r and type command you typed in last
when comes just press enter or use arrow to edit and fire you command

#Press Ctrl+R from the command prompt,
(reverse-i-search)`man ': man Top
[Note: Press enter or edit as per your requirement]

3>#Repeat you previou command quick
way 1> use up arroy once
way 2> !!   <- Enter
way 3> !-1  <- Enter
way 4> ctl+p <-Enter

4> quick sortcut
#!5  <- 5th commnds you used from history to check use #history |less
#!man <- latest commnad you used that started with man...
#export HISTCONTROL=ignoredups (ignore duplicates commnds from history)
#export HISTCONTROL=erasedups  (remove duplicates commnds from history)
#export HISTCONTROL=ignorespace (ignore to add cmnds starting with space in history)
eg:
#export HISTCONTROL=ignorespace
#  man dig
#history
1 pwd
2 man top
3 ...
but history does not store any command you start with space

5> Clear your history
# history -c

6> Disable to use of history
# export HISTSIZE=0
# history
no o/p

7> Enable history to not record specifics commnands
# export HISTIGNORE="man:ll:pwd:password:alias amgreat=clear:amgreat"
Now use above commands but history dosent save it.
   
8> control you history size ..
# vi /home/yourhome_dir/.bash_profile
HISTSIZE=450
HISTFILESIZE=450

Thursday, October 28, 2010

my scripts

==========> Backup Script
#!/bin/bash
# Shirish Shukla backup script
# source-> /usr/rnd/*
# target-> /shirishva/backup/abcd-...
#
#------------ Backup string create: abcd-Wed-Oct-27-22:31 format

create=$(echo abcd-`date +%a-%b-%d-%H:%M`)

tar -jcf /shirishva/backup/$create.bz2 /usr/rnd/*

#------------------- delete 3 Hour old backup data del->string

t1=$(date --date='3 hour ago')

t2=$(echo $t1 | sed -e "s/[:]/ /g")

array=( `echo $t2` )

del=$(echo abcd-${array[0]}-${array[1]}-${array[2]}-${array[3]}:${array[4]})

rm -fr /shirishva/backup/$del.bz2

#---------------------------------

Tuesday, October 26, 2010

Software Raid

xxxxxxxxxxxxxxxxxx Raid using mdadm --By Shirish Shukla xxxxxxxxxxxxxxxxxxxx

### Configure raid0 of 700mb and mount it on /common2
        # fdisk  -l   <<---  verify raid partition
        # fdisk /dev/sda
            create 2 raid partition (type  fd) of 350mb each  say /dev/sda11 & /dev/sda12
        # partprobe  -s
        # fdisk  -l   <<---- confirm
        # mdadm     << just check is command appearing using tab.. if no install it from yum server
        # yum   –y   install mdadm*
        # mdadm  --create  /dev/md0  --level=0  --raid-devices=2  /dev/sda11  /dev/sda12
        # mkfs.ext3   /dev/md0    ß-format  md0
        # echo “DEVICE   /dev/sda11  /dev/sda12 “  > /etc/mdadm.conf
        # mdadm   --examine   --scan  --config=/etc/mdadm.conf   > > /etc/mdadm.conf
                    OR
        # mdadm –detail –scan >> /etc/mdadm.conf
        # cat /proc/mdstat     ß verify
        # vi /etc/fstab
            /dev/md0       /common2    ext3    defaults    0   0
        # mount –a
        # mount    or   # df   -h     ß----varify  /common to be have near about 700mb mounted.
         If above question will asked for RAID1, just change a single command:
        # mdadm  --create  /dev/md0  --level=1  --raid-devices=2  /dev/sda11  /dev/sda12
        all other same as above
RAID-1:
      # fdisk /dev/sdb
            ##create 2 raid partition (type  fd) of 350mb each  say /dev/sdb8 & /dev/sdb9
      # partprobe  -s
      # fdisk  -l   <<---- confirm
      ## Create Raid -1
      # mdadm  --create  /dev/md1  --level=1  --raid-devices=2  /dev/sdb8  /dev/sdb9
      # mkfs.ext3   /dev/md1    ß-format  md1
      # mdadm   --examine   --scan  --config=/etc/mdadm.conf   > > /etc/mdadm.conf
                    OR
     # mdadm –detail –scan >> /etc/mdadm.conf
     # cat /proc/mdstat     <<- verify
     ##Mount it on /EXTRA/RAID-1
    # mount /dev/md1  /EXTRA/RAID-1
   ###Recovery -- Suppose my raid partition 8 has been crashed Or have created it for 2 diff disks and my 1  st disk has crashed
  ## So how to recover data as have craeted mirror RAID, In our case /dev/sd9 conyain mirror data
  REcovery on Raid 1:
  # umount    /dec/mb1
  # mdadm --stop  /dev/md1
  # mount  -t  ext3   /dev/sdb9   /EXTRA/TEST   <-- Have a fun :)
 # Remount the RAID
 # mdadm --assemble /dev/md1
 # mount /dev/md1 /EXTRA/RAID-1

#Simulation
# cat /proc/mdstat
Personalities : [raid0] [raid1]
md1 : active raid1 sdb8[0] sdb9[1]
      200704 blocks [2/2] [UU]

md0 : active raid0 sdb7[1] sdb6[0]
      305024 blocks 64k chunks

unused devices: <none>

## mdadm --detail /dev/md1
/dev/md1:
        Version : 00.90.03
  Creation Time : Wed Apr 13 09:58:15 2011
     Raid Level : raid1
     Array Size : 200704 (196.03 MiB 205.52 MB)
  Used Dev Size : 200704 (196.03 MiB 205.52 MB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 1
    Persistence : Superblock is persistent

    Update Time : Wed Apr 13 10:18:37 2011
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 44493b73:98b654f0:a313390c:1000baf6
         Events : 0.2

    Number   Major   Minor   RaidDevice State
       0       8       24        0      active sync   /dev/sdb8
       1       8       25        1      active sync   /dev/sdb9

##add the new replacement partition to the RAID. It will be resynchronized to the original partition
# mdadm --add /dev/md0 /dev/sda15
# mdadm --detail /dev/md0



# Faced any problem Feedback in above contact me
#===============================Scratch===============================#
# AND Many More .....................Linux is Endless                                                                          #
#========================== Hope you Liked IT ===========================#
#                                                                                                   RAID  -- BY Shirish Shukla #
#                                                                                                               RHC Engineer 2010 #
#                                                                                                          shirish.linux@gmail.com #
#                                                                                                          shirishlinux.blogspot.com #
#                            "Give Respect To Time One Day At Right Time, Time Will Respect You" #
#=====================================================================#
# TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk                                   #
#=====================================================================#
Implement s/w raid linux, mdadm, raid0, raid 1, raid1, raid0, linux raid, how to configure raid on linux, linux raid configuration ....

Tuesday, October 12, 2010

Yum Server

XX Yum Server Client Configuration By - Shirish Shukla XX


1> yum server Setup :
==================

>> Install Linux with > 6+ gb of /var partition

# lokkit and do the following
Security level : Disabled
SElinux : Disabled
Reboot the system (To Avoide any obstacle)
# mount /dev/dvd /mnt    (mount your Linux dvd )
# cd /mnt
# You will see dir called “Server”
# Go to “Server” dir
# You will see all RPMs (3842)
# rpm -ivh vsftpd* (Do this in “Server” Dir)
# cp -r /mnt/* /var/ftp/pub/ (Do this outside the “Server” Dir)
# rpm -ivh createrepo* (Do this in “Server” Dir)
# createrepo -v /var/ftp/pub/Server (Will show lots of files)
# service vsftpd restart
# chkconfig vsftpd on
# iptables -F
# service iptables save


2> Server yum-client :
===================


On Server side it’s optional, but in future it’ s good for you to install any package on server

# cd /etc/yum.repos.d/
# cp rhel-debuginfo.repo vadapav1.repo
# Now open vadapav1.repo and you will see this :

[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch – Debug baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Change the above to the following or make a copy of above and do below changes
[vadapav1]
name=Red hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://192.168.0.2>>>/pub/Server
enabled=1 ----> by default it is 0 --set to 1
gpgcheck=0 ----> by default it is 1 --set to 0
[Delete or comment last line gpgkey=file…… ]

# yum update list
# yum info gftp*

(If above two commands don't work, it means you have done something wrong in above two setups.)




3> Yum Client :
=============


Finally, configure yum server for the CLIENT.

>>>a. Go to this dir:

# cd /etc/yum.repos.d/

>>>b. Make a copy of this only file in this dir:

# cp rhel-debuginfo.repo station11.repo (any filename with .repo extention)

>>>c. Open that file:

# vi station11.repo

>>>d. Do the following changes so finally station11.repo file looks like this:

[rhel-debuginfo] change to [station11]
name=Red hat Enterprise Linux $releasever - $basearch - Debug---> Given DNT
Change this line to the following:
baseurl=ftp://192.168.0.2>>>/pub/Server
enabled=0----> change to 1
gpgcheck=1---> change to 0
[Delete or comment gpgkey(i.e, delete the last line)]

>>>e. To Check whether the yum server for the Client is OK, Do the follow command:

# yum update list
# yum info gftp*




4> Yum important Commands :
===========================


>> install packages:

# yum -y install dhcpd*

>> Remove packages:

# yum remove dhcpd*

>> Package info:

# yum info dhcpd*

>> To know whether package installed or not:

# yum list dhcpd*

>> To clean yum server catch:

# yum clean all

>> Patch up system by applying all updates
# yum update
>> To update yum server list
# yum update list

>>Check for and update specified packages
# yum update  package-name

>>Search for packages by name
# yum list  package-name*

>>Display the list of available packages
# yum list all

>>Check for and update specified packages
# yum update  package-name

>>Search for packages by name
# yum list  package-name*

>>Search for packages by name
# yum list  package-name*

>>Lists all the packages available to be installed
# yum list installed

>>yum check-update yum list updates but returns an exit code of 100 if there are updates available
# yum check-update

>>Display what package provides the file
# yum whatprovides Filename

-->You can use same command to list packages that satisfy dependencies:
# yum whatprovides  dep-1  dep-1

.... See man yum for more info
# man yum



x x x x xx x x x xx x x x xx x x x xx x x x xx x x x xx x x x xx x x x xx x x
hOW YUM SERVER WORK LINUX, LINUX, YUM sERVER, SERVER YUM, YUM CONFIGURATION, MAN YUM, YUM COMMANDS,CONFIGURE LOCAL YUM SERVER, CONFIGURE LIVE YUM SERVER, HOW TO CONFIGURE YUM SERVER, MY YUM SERVER, YUM SERVER CONFIG LINUX, LOVE YUM SERVER, YUM, YUM YUM YUM ,LINUX+YUM

Thursday, September 9, 2010

Sys Admin L1, L2, and L3 ?

What is the definition of L1, L2 and L3 UNIX / Linux / IT support?
Generally L1, L2, and L3 support apply to any form of technical support such as mobile phones, electronics devices, computers, servers, and networking devices. All levels have different meanings and differ slightly from company to company and IT support groups. Basically, each person working at each level must have more experience and education in the field of support than its previous level.
L1 is nothing but Level 1 support which is provided by a call center support person or engineer. L1 tech usually follows certain steps to solve the problem. In other words L1 will ask you various questions and some sort of software will be used to map your answers to further questions. L1 support takes your requests using the telephone, email or chat sessions. This kind of support engineers are are trained on the product with limited experience. They should able to resolve 50%-60% of all problems. For example, restart failed httpd service can be handled by L1.
If L1 support failed to solve your problem than it is escalated to L2 (Level 2) support engineer. L2 support will try to find out exact causes of the problems. Almost all L2 engineers are a subject matter expert with 3-5 years rocks solid experience. For example, if httpd can not be started after server reboot than L2 tech who is httpd and UNIX subject matter expert can try to resolve the problem using various debugging methods.
If L2 support failed to resolve your problem than it is escalated to L3 (Level 3) support professional. Usually, L3 support works closely with product engineering team or with source code itself with various debugging tools. L3 support only handles very difficult support cases.
Please note that some companies offer certain levels of support such as L3 only on a fee basis.

Wednesday, September 1, 2010

How to monitor server load on GNU/Linux


How to monitor server load on GNU/Linux
========================================

Gkrellm
==========
Gkrellm is the choice of the “g33k” types. It’s a graphical program that monitors all

sorts of statistics and displays them as numbers and charts. You can see examples of it

in use on nearly every GNU/Linux screenshot website. It is very flexible and capable,

and can monitor useful as well as ridiculous things via plugins. It can monitor the

status of a remote system, since it’s a client/server system.


“Task Manager” clones
=====================
gnome-system-monitor is a graphical program installed as part of the base Gnome system.

It is somewhat similar to the Task Manager in Microsoft Windows. It isn’t very

full-featured, with only three tabs (Processes, Resources, Devices). The Devices tab

just shows devices, Resources shows the history of CPU, memory, swap and network usage,

and the Processes tab shows the processes. The Processes tab is the only one that really

lets the user “do” anything, such as killing or re-nicing processes, or showing their

memory maps.

Of course, this tool is only available on systems with Gnome installed, and requires an

X server to be running. This makes it impractical for use on a server.

vmstat and related tools
=========================
vmstat is part of the base installation on most GNU/Linux systems. By default, it

displays information about virtual memory, CPU usage, I/O, processes, and swap, and can

print information about disks and more. It runs in a console. I find the command vmstat

-n 5 very helpful for printing a running status display in a tabular format.

It’s great for figuring out how heavily loaded a system truly is, and what the problem

(if any) is. For example, when I see a high number in the rightmost column (percent of

CPU time spent waiting for I/O) on a database server, I know the system is I/O-bound.

iostat
======
iostat is part of the sysstat package on Gentoo, as are mpstat and sar. iostat prints

similar statistics as vmstat, but gives more detail on specific devices and is geared

toward understanding I/O usage in more detail than vmstat is. mpstat is a similar tool

that prints processor statistics, and is multi-processor aware. sar collects, reports,

and saves system activity information (for example, for later analysis).

sysreport : A detail info about your system hw setup etc.. (Take a min to completed)
will create a bzip2 compressed file with all curretn deatil about ypur system

=========

All of these tools are very flexible and customizable. The user can choose what

information to see and what format to see it in. These tools are not usually installed

by default, except for vmstat.

top
======
top is the classic tool for monitoring any UNIX-like system. It runs in a terminal and

refreshes at intervals, displaying a list of processes in a tabular format. Each column

is something like virtual memory size, processor usage, and so forth. It is highly

customizable and has some interactive features, such as re-nicing or killing processes.

Since it’s the most widely known of the tools in this article, I won’t go into much

detail, other than to say there’s a lot to know about it — read the man page.

top is one of the programs in the procps package, along with:

ps, vmstat, w, kill, free, slabtop, and skill.

All these tools are in a default installation on most distributions.

htop
=====
is similar to top, except it is mouse-aware, has a color display, and displays little

charts to help see statistics at a glance. It also has some features top doesn’t have.

mytop :is a handy monitor for MySQL servers
======

tload
=========
tload runs in a terminal and displays a text-only “graph” of current system load

averages, garnered from /proc/loadavg. It is part of the base installation on most

GNU/Linux systems. I find it extremely useful for watching a system’s performance over

SSH, often within a GNU Screen session.

My favorite technique is to start a terminal, connect over SSH, resize the terminal to

150×80 or so, then start tload and shrink the window by CTRL-right-clicking and

selecting “Unreadable” as the font size. The result looks like the following:

watch
=========
watch isn’t really a load-monitoring tool, but it’s beastly handy because it takes any

command as input and monitors the result of running that command. For example, if I

wanted to monitor when the “foozle” program is executing, I could run


watch --interval=5 "ps aux | grep foozle | grep -v xaprb"

=========
running tload over SSH to monitor systems, and use vmstat, iostat and friends to

troubleshoot specific problems
========

lsof
=====
which lists open files. Don’t be fooled by how simple that sounds! It’s tremendously

powerful.

uptime
=======
System load averages is the average number of processes that are either in a runnable or

uninterruptable state. A process in a runnable state
is either using the CPU or waiting to use the CPU


How to create system report:
======================
# sysreport
<-- press Enter
Please enter your first initial and last name [server]: shirish
please neter case number that you are generating this report for: 1
<-- press Enter
now wait for few minutes it will create a biz2 compressed file in /tmp/sysreport-shirish.1-3-----.bz2
copy it and sent where yor require this file conatin all your sytem info capturede from /proc kernel...

---> Bow on some version it has been replace by command # sosreport but working is alomost same

# sosreport
==========
Display Memory status:
# free <--memory status on system
# free -t <--Total amt of memory available in system
# free -m <-- Display Memory used and free memory in MB

Disply information:
# dmidecode --type bios <--retrive bios info
# dmidecode --type system <--system hw info
# dmidecode --type processor <-- sys processor info
# dmidecode --type memory <--sys memory info
# dmidecode --type cache <--sys cahce info
# dmidecode -- connector <-- sys connector info
# dmidecode --type slot <--sys slots info

Imp Port NumberS


Question: What Is a Port Number?
Answer: In computer networking, a port number is part of the addressing information used to identify the senders and receivers of messages. Port numbers are most commonly used with TCP/IP connections. Home network routers and computer software work with ports and sometimes allow you to configure port number settings. These port numbers allow different applications on the same computer to share network resources simultaneously.
 
How Port Numbers Work:
Port numbers are associated with network addresses. For example, in TCP/IP networking, both TCP and UDP utilize their own set of ports that work together with IP addresses.
Port numbers work like telephone extensions. Just as a business telephone switchboard can use a main phone number and assign each employee an extension number (like x100, x101, etc.), so a computer has a main address and a set of port numbers to handle incoming and outgoing connections.
In both TCP and UDP, port numbers start at 0 and go up to 65535. Numbers in the lower ranges are dedicated to common Internet protocols (like 21 for FTP, 80 for HTTP, etc.).

?: why we r useing port numbers pls reply me
A: Ports are used to identify the type of service out of junk traffic

==================================
Some important port numbers

There are huge number of ports which are reserved. But the ports mentioned below are more important.
IMPORTANT PORTS:
=============================
Important Linux Port Numbers
15 – Netstat
20 --FTP Data
21 => FTP
22 => SSH
23 => Telnet
25 => SMTP Mail Transfer
37 – Time
42 – WINS
43 => WHOIS service
53 => name server (DNS)
67 – DHCP SERVER
68 – DHCP CLIENT
69 --TFTP
80 => HTTP (Web server)
443 -- HTTPS(SSL (https) (http protocol over TLS/SSL)
88 – Kerberos
101 – HOSTNAME
109 -- POP2
110 => POP protocol (for email)
123 – NTP (Network time protocol)
137-NetBIOS
161 – SNMP
143 -- IMAP
220 – IMAP3
995 => POP over SSL/TLS
9999 => Urchin
111 => rpcbind
953 => rndc
143 => IMAP Protocol (for email)
993 => IMAP Secure
443 => HTTP Secure (SSL for https:// )
500 – Internet Key Exchange, IKE (IPSec) (UDP 500
546-DHCPv6 client
547-DHCPv6 serveR
3306 = > MysQL Server
4643 => Virtuosso Power Panel
2082 => CPANEL
2083 => CPANEL - Secure/SSL
2086 => CPANEL WHM
2087 => CPANEL WHM - Secure/SSL
2095 => cpanel webmail
2096 => cpanel webmail - secure/SSL
3306 => SQL
Plesk Control Panel => 8443
DirectAdmin Control Panel => 2222
Webmin Control Panel => 10000

FAQs
1. How to find which ports are open?
You can find the ports in your linux server with the nmap command
netstat -nap --tcp

2. How to investigate a port and kill suspicious process?
A good tutorial is here

3. Where do i find a complete list of linux ports for reference?
You can find the ports list: here

4. Which firewall is best for linux servers?
I would recommend to install APF firewall. You can find a good tutorial here: http://www.mysql-apache-php.com/apf-firewall.htm
Warning: Make sure that you dont block the important ports with the firewall.

A port is a communication point where one or more computers in a network communicate with each other through a program or software

Difference TCP vs UDP Protocol

 
TCP/IP Protocol:
It is a connection oriented protocol
It has flow control and error correction
It is not fast and primarily used for data transmission like (http,ssh,smtp,ftp, mail etc.) 
Most common services requiring confirmation of delivery like http,ssh,smtp,ftp, mail etc. use TCP ports
Asked for authentication like user name and password

UDP Protocol:
It is connectionless protocol which means it can send packets without establishing connection with the receiver at first. 
It is error prone during transmission.
It is fast and used mostly for audio and video streaming.
UDP ports are commonly used by services or programs that dont require the confirmation of delivery of packets. Most commonly used is DNS queries using UDP port 53.
no

Sunday, August 29, 2010

Text Editors

Text editors

In this chapter, we will discuss the importance of mastering an editor. We will focus mainly on the Improved vi editor.
After finishing this chapter, you will be able to:
  • Open and close files in text mode
  • Edit files
  • Search text
  • Undo errors
  • Merge files
  • Recover lost files
  • Find a program or suite for office use

Vi(m)

Vim stands for "Vi IMproved". It used to be "Vi IMitation", but there are so many improvements that a name change was appropriate. Vim is a text editor which includes almost all the commands from the UNIX program vi and a lot of new ones.
Commands in the vi editor are entered using only the keyboard, which has the advantage that you can keep your fingers on the keyboard and your eyes on the screen, rather than moving your arm repeatedly to the mouse. For those who want it, mouse support and a GUI version with scrollbars and menus can be activated.
We will refer to vi or vim throughout this book for editing files, while you are of course free to use the editor of your choice. However, we recommend to at least get the vi basics in the fingers, because it is the standard text editor on almost all UNIX systems, while emacs can be an optional package. There may be small differences between different computers and terminals, but the main point is that if you can work with vi, you can survive on any UNIX system.
Apart from the vim command, the vIm packages may also provide gvim, the Gnome version of vim. Beginning users might find this easier to use, because the menus offer help when you forgot or don't know how to perform a particular editing task using the standard vim commands.

Using the Vim editor

Two modes

The vi editor is a very powerful tool and has a very extensive built-in manual, which you can activate using the :help command when the program is started (instead of using man or info, which don't contain nearly as much information). We will only discuss the very basics here to get you started.
What makes vi confusing to the beginner is that it can operate in two modes: command mode and insert mode. The editor always starts in command mode. Commands move you through the text, search, replace, mark blocks and perform other editing tasks, and some of them switch the editor to insert mode.
This means that each key has not one, but likely two meanings: it can either represent a command for the editor when in command mode, or a character that you want in a text when in insert mode.
Note Pronunciation
  It's pronounced "vee-eye".


Commands that switch the editor to insert mode:
  • a will append: it moves the cursor one position to the right before switching to insert mode
  • i will insert
  • o will insert a blank line under the current cursor position and move the cursor to that line.
Pressing the Esc key switches back to command mode. If you're not sure what mode you're in because you use a really old version of vi that doesn't display an "INSERT" message, type Esc and you'll be sure to return to command mode. It is possible that the system gives a little alert when you are already in command mode when hitting Esc, by beeping or giving a visual bell (a flash on the screen). This is normal behavior.

Basic commands

 Moving through the text is usually possible with the arrow keys. If not, try:
  • h to move the cursor to the left
  • l to move it to the right
  • k to move up
  • j to move down
SHIFT-G will put the prompt at the end of the document.
ctl+s -- stop   ctl+q --resume

Basic operations
These are some popular vi commands:
  • n dd will delete n lines starting from the current cursor position.
  • n dw will delete n words at the right side of the cursor.
  • x will delete the character on which the cursor is positioned
  • :n moves to line n of the file.
  • :w will save (write) the file
  • :q will exit the editor.
  • :q! forces the exit when you want to quit a file containing unsaved changes.
  • :wq will save and exit
  • :w newfile will save the text to newfile.
  • :wq! overrides read-only permission (if you have the permission to override permissions, for instance when you are using the root account.
  • /astring will search the string in the file and position the cursor on the first match below its position.
  • / will perform the same search again, moving the cursor to the next match.
  • :1, $s/word/anotherword/g will replace word with anotherword throughout the file.
  • yy will copy a block of text.
  • n p will paste it n times.
  • :recover will recover a file after an unexpected interruption.

Hope you Like it:        

  
                                                                                   29 aug 2010
                                                                              --Shirish Shukla

Followers

Pls LIKE my Story !!!