October 2025
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

October 2025
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Network Attacks

 Network Attacks

Your networks and data are vulnerable to any of the following types of attacks if you do not have a security plan in place.

Eavesdropping
In general, the majority of network communications occur in an unsecured or “cleartext” format, which allows an attacker who has gained access to data paths in your network to “listen in” or interpret (read) the traffic. When an attacker is eavesdropping on your communications, it is referred to as sniffing or snooping. The ability of an eavesdropper to monitor the network is generally the biggest security problem that administrators face in an enterprise. Without strong encryption services that are based on cryptography, your data can be read by others as it traverses the network.
Data Modification
After an attacker has read your data, the next logical step is to alter it. An attacker can modify the data in the packet without the knowledge of the sender or receiver. Even if you do not require confidentiality for all communications, you do not want any of your messages to be modified in transit. For example, if you are exchanging purchase requisitions, you do not want the items, amounts, or billing information to be modified.
Identity Spoofing (IP Address Spoofing)
Most networks and operating systems use the IP address of a computer to identify a valid entity. In certain cases, it is possible for an IP address to be falsely assumed— identity spoofing. An attacker might also use special programs to construct IP packets that appear to originate from valid addresses inside the corporate intranet.
After gaining access to the network with a valid IP address, the attacker can modify, reroute, or delete your data. The attacker can also conduct other types of attacks, as described in the following sections.
Password-Based Attacks
A common denominator of most operating system and network security plans is password-based access control. This means your access rights to a computer and network resources are determined by who you are, that is, your user name and your password.
Older applications do not always protect identity information as it is passed through the network for validation. This might allow an eavesdropper to gain access to the network by posing as a valid user.
When an attacker finds a valid user account, the attacker has the same rights as the real user. Therefore, if the user has administrator-level rights, the attacker also can create accounts for subsequent access at a later time.
After gaining access to your network with a valid account, an attacker can do any of the following:
·         Obtain lists of valid user and computer names and network information.
·         Modify server and network configurations, including access controls and routing tables.
·         Modify, reroute, or delete your data.
Denial-of-Service Attack
Unlike a password-based attack, the denial-of-service attack prevents normal use of your computer or network by valid users.
After gaining access to your network, the attacker can do any of the following:
·         Randomize the attention of your internal Information Systems staff so that they do not see the intrusion immediately, which allows the attacker to make more attacks during the diversion.
·         Send invalid data to applications or network services, which causes abnormal termination or behavior of the applications or services.
·         A multitude of compromised systems attack a single target, thereby causing denial of service for users of the targeted system. The flood of incoming messages to the target system essentially forces it to shut down because of the overload, thereby denying service to the system to leg — Distributed Denial-of-Service(DDOS)
·         Block traffic, which results in a loss of access to network resources by authorized users.
Man-in-the-Middle Attack
As the name indicates, a man-in-the-middle attack occurs when someone between you and the person with whom you are communicating is actively monitoring, capturing, and controlling your communication transparently. For example, the attacker can re-route a data exchange. When computers are communicating at low levels of the network layer, the computers might not be able to determine with whom they are exchanging data.
Man-in-the-middle attacks are like someone assuming your identity in order to read your message. The person on the other end might believe it is you because the attacker might be actively replying as you to keep the exchange going and gain more information. This attack is capable of the same damage as an application-layer attack, described later in this section.
Compromised-Key Attack
A key is a secret code or number necessary to interpret secured information. Although obtaining a key is a difficult and resource-intensive process for an attacker, it is possible. After an attacker obtains a key, that key is referred to as a compromised key.
An attacker uses the compromised key to gain access to a secured communication without the sender or receiver being aware of the attack.With the compromised key, the attacker can decrypt or modify data, and try to use the compromised key to compute additional keys, which might allow the attacker access to other secured communications.
Sniffer Attack
sniffer is an application or device that can read, monitor, and capture network data exchanges and read network packets. If the packets are not encrypted, a sniffer provides a full view of the data inside the packet. Even encapsulated (tunneled) packets can be broken open and read unless they are encrypted and the attacker does not have access to the key.
Using a sniffer, an attacker can do any of the following:
·         Analyze your network and gain information to eventually cause your network to crash or to become corrupted.
·         Read your communications.
Application-Layer Attack
An application-layer attack targets application servers by deliberately causing a fault in a server’s operating system or applications. This results in the attacker gaining the ability to bypass normal access controls. The attacker takes advantage of this situation, gaining control of your application, system, or network, and can do any of the following:
·         Read, add, delete, or modify your data or operating system.
·         Introduce a virus program that uses your computers and software applications to copy viruses throughout your network.
·         Introduce a sniffer program to analyze your network and gain information that can eventually be used to crash or to corrupt your systems and network.
·         Abnormally terminate your data applications or operating systems.

Disable other security controls to enable future attacks.

Mod Proxy Security to protect the page

Mod Proxy Security to protect the page 

<IfModule mod_proxy.c>

ServerName   rmohan.com

ProxyRequests On

SSLProxyEngine on

ProxyVia On

<Proxy https://dev.rmohan.com/web/app/app1*>

  Order deny,allow

  Allow from all

</Proxy>

ProxyPass web/app/app1      https://dev.rmohan.com/web/app/app1

ProxyPassReverse web/app/app1  https://dev.rmohan.com/web/app/app1

<Proxy https://dev.rmohan.com/web/CVS*>

  Order deny,allow

  Deny from all

</Proxy>

<Proxy https://dev.rmohan.com/web/app/app1/CVS*>

  Order deny,allow

  Deny from all

</Proxy>

</IfModule>

LVM in linux

LVM in linux

Logical Volume Management[LVM]

LVM is a logical volume manager for the Linux kernel; it manages disk drives and similar mass-storage devices, in particular large ones. The term “volume” refers to a disk drive or partition.
Every system contains Physical Volums[PV]. Such as hard disks, partitions or external storages. Volume management treats PVs as sequences of chunks called Physical Extents (PEs). There is an another concept also. Logical Extents(LE). Each LE maps one-to-one PE. The system pools LEs into a Volume Group (VG). We can extend this VG by adding a group of Logical extents to it from anywhere at anytime.
Uses of LVM:

  1. Extending the partitions online
  2. Grouping of hard disks
  3. Reducing the partitions / hard dsik size (offline)
  4. Increasing the performance
  5. Taking Backup (SNAPSHOT)
Example:
Here we are going to discuss a Volume Group(VG) created from 3Physical Voumes(PV). And in that VG we’ll create two Logival Volumes(LV) And mount it to /linux1 and /linux2 respectively.
Now first of all in our example, we have 3 partitions. In real industry it may be 3 different hard disks.
Let it be (1) /dev/sda5 (2) /dev/sda6 (3) /dev/sda7 each of size300Mb.
[root@vm4 ~]# fdisk -l
/dev/sda5 429 465 297171 8e Linux LVM
/dev/sda6 466 502 297171 8e Linux LVM
/dev/sda7 503 539 297171 8e Linux LVM


Steps:
First we will convert this partions(hard disks) into Physical Volumes(PV).Then we’ll create a Volume Group (VG) from those PV s. Then inside that VG, We’ll create two Logical Volumes (LV) and we’ll mount those for use.
Step1: Creating Physical Volume(PV)s.
Partitions or disks can be converted into PV s using the following Command.
#pvcreate PARTITION_NAMES
#pvcreate /dev/sda5 /dev/sda6 /dev/sda7
or as below
#pvcreate /dev/sda{5,6,7}
[root@vm4 ~]# pvcreate /dev/sda5 /dev/sda6 /dev/sda7
Physical volume “/dev/sda5” successfully created
Physical volume “/dev/sda6” successfully created
Physical volume “/dev/sda7” successfully created
 
Monitoring or verifying the PV s:
You can verify the PV s using following commands,
#pvscan
#pvdisplay
#pvs
[root@vm4 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 lvm2 — 290.21M 290.21M
/dev/sda6 lvm2 — 290.21M 290.21M
/dev/sda7 lvm2 — 290.21M 290.21M
Step2: Creating Volume Group(VG):
The Physical Volumes are grouped into one to make it a Volume Group(VG). It can be done using the following command.
#vgcreate VG_NAME PV_NAMES
#vgcreate oracle /dev/sda5 /dev/sda6 /dev/sda7
or as below
#vgcreate oracle /dev/sda{5,6,7}
It will have a appoximate size of 900(300+300+300). Some part will for writing headers LE and making LE-PE mapping.
[root@vm4 ~]# vgcreate oracle /dev/sda5 /dev/sda6 /dev/sda7
Volume group “oracle” successfully created
[root@vm4 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
oracle 3 0 0 wz–n- 864.00M 864.00M
 
Monitoring or verifying the VG s:
You can verify the VG s using following commands,
#vgscan
#vgdisplay
#vgs
Output of #vgs is shown above the picture.
Step3: Creating Logical Volumes In Volume Group:
Now we got a volume group “Oracle” of size as the total size of all individual disks/partitions. Now we can create Logical Volumes or usable partitions inside it. We will create two logical Volumes lvm1 and lvm2 of size 100Mb each.
The lvm1 and lvm2 can be created using the following commands.
#lvcreate -L SIZE -n LV_NAME VG_NAME
#lvcreate -L 100M -n lvm1 oracle
#lvcreate -L 100M -n lvm1 oracle
[root@vm4 ~]# lvcreate -L 100M -n lvm1 oracle
Logical volume “lvm1” created
[root@vm4 ~]# lvcreate -L 100M -n lvm2 oracle
Logical volume “lvm2” created
 
Monitoring or verifying the LV s:
You can verify the LV s using following commands,
#lvscan
#lvdisplay
#lvs
[root@vm4 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvm1 oracle -wi-a- 100.00M
lvm2 oracle -wi-a- 100.00M
The Logical Voumes lvm1 and lvm2 should be formatted(making filesystem in those) before mounting it. Then only you can use those partitions.
Here formatting in ext3:
#mkfs.ext3 /dev/oracle/lvm1
#mkfs.ext3 /dev/oracle/lvm2
Making Mount Points:
#mkdir /linux1
#mkdir /linux2
Mounting (Temporary):
#mount /dev/oracle/lvm1 /linux1
#mount /dev/oracle/lvm2 /linux2
  
[root@vm4 ~]# mount
[Output truncated]
/dev/mapper/oracle-lvm1 on /linux1 type ext3 (rw)
/dev/mapper/oracle-lvm2 on /linux2 type ext3 (rw)
Extending a Logical Volume (Online):
Now We have a Volume group “oracle” of size about 900Mb. And two Logical vloumes lvm1 and lvm2 mounted on /linux1 and /linux2 respectively. Each having 100Mb size. Now we’ll extend the size of lvm1 by 100Mb.
Extending size of a LV can be done online, That is by keeping them mounted. It can be achived by executing following command.
#lvextend -L +SIZE THE_PATH_OF_LV
#lvextend -L +100M /dev/oracle/lvm1
Before:
[root@vm4 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvm1 oracle -wi-ao 100.00M
lvm2 oracle -wi-ao 100.00M
Executing:
[root@vm4 ~]# lvextend -L +100M /dev/oracle/lvm1
Extending logical volume lvm1 to 200.00 MB
Logical volume lvm1 successfully resized
After:
[root@vm4 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvm1 oracle -wi-ao 200.00M
lvm2 oracle -wi-ao 100.00M
After executing above commands you can verify the changed size by any of following commands
#lvs, #lvdisplay, #lvscan
But if you check
#df -hT
it will be showing the old size only. Because the filesystem is updated the changed in Logical Volume. It can be updated by following command.
#resize2fs /dev/oracle/lvm1
NOTE: In case of extending the LV is resized first and the filesystem after that. But in case of shrinking a LV, filesystem is shrinked first followed by the shrink in LV.
Before:
[root@vm4 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/oracle-lvm1
ext3 97M 5.6M 87M 7% /linux1
/dev/mapper/oracle-lvm2
ext3 97M 5.6M 87M 7% /linux2
Executing:
[root@vm4 ~]# resize2fs /dev/oracle/lvm1
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/oracle/lvm1 is mounted on /linux1; on-line resizing required
Performing an on-line resize of /dev/oracle/lvm1 to 204800 (1k) blocks.
The filesystem on /dev/oracle/lvm1 is now 204800 blocks long.
After:
[root@vm4 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/oracle-lvm1
ext3 194M 5.6M 179M 4% /linux1
/dev/mapper/oracle-lvm2
ext3 97M 5.6M 87M 7% /linux2
Shrinking a Logical Volume (Offline):
As we extended the size of Logical Volume, we can reduce the size also. But in later case, it can be done only offline. That is the LV should be unmounted for reducing its size.
For Shrinking a Volume:

  1. Filesystem must be reduced first
  2. Requires a filesystem check and cannot be performed online
  3. #lvreduce can then reduce the volume
Now We have a Volume group “oracle” of size about 900Mb. And two Logical vloumes lvm1 and lvm2 mounted on /linux1 and /linux2 respectively. Size of lvm1 is 200Mb and size of lvm2 is 100Mb. Now we’ll reduce the size of lvm2 by 40Mb.
Current status:
[root@vm4 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvm1 oracle -wi-ao 200.00M
lvm2 oracle -wi-ao 100.00M
Step1: Unmont the volume:
#umount /linux2
Step2: Checking the filesystem:
#e2fsck -f LV_Path
#fsck -f /dev/oracle/lvm2
[root@vm4 ~]# e2fsck -f /dev/oracle/lvm2
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/oracle/lvm2: 11/25688 files (9.1% non-contiguous), 8914/102400 blocks
This is to make sure that the filesystem is in a consistent state.
Step3: Resizing the filesystem:
#resize2fs LV_Path Final_size
#resize2fs /dev/oracle/lvm2 60M
[Total size was 100Mb. Reduction 40Mb. So final size is 100-40=60]
[root@vm4 ~]# resize2fs /dev/oracle/lvm2 60M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/oracle/lvm2 to 61440 (1k) blocks.
The filesystem on /dev/oracle/lvm2 is now 61440 blocks long.
Step4: Now reduce the LV using #lvreduce
#lvreduce -L Size LV_Path
#lvreduce -L 60M /dev/oracle/lvm2
[root@vm4 ~]# lvreduce -L 60M /dev/oracle/lvm2
WARNING: Reducing active logical volume to 60.00 MB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvm2? [y/n]: y
Reducing logical volume lvm2 to 60.00 MB
Logical volume lvm2 successfully resized
Before Reducing:
root@vm4 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvm1 oracle -wi-ao 200.00M
lvm2 oracle -wi-ao 100.00M
After Reducing:
[root@vm4 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvm1 oracle -wi-ao 200.00M
lvm2 oracle -wi-a- 60.00M
After mounting:
[root@vm4 ~]# df -hT
/dev/mapper/oracle-lvm1 ext3 194M 5.6M 179M 4% /linux1
/dev/mapper/oracle-lvm2 ext3 59M 5.3M 50M 10% /linux2
Adding a Pysical Volume to a VG:
Now we have a Volume Group “oracle” of size 900Mb. Suppose we used upto the maximum usable size. So we need to extend the size of the VG.
In this case we will create a new partition/a new hard disk, and will make it a Physical Volume and add it to the Volume group.
Current status:
[root@vm4 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
oracle 3 2 0 wz–n- 864.00M 624.00M
Now we created one more partition with id LVM.
/dev/sda5 429 465 297171 8e Linux LVM
/dev/sda6 466 502 297171 8e Linux LVM
/dev/sda7 503 539 297171 8e Linux LVM
/dev/sda8 540 576 297171 8e Linux LVM
Step1:
First we have to convert it to physical volume.
#pvcreate /dev/sda8
[root@vm4 ~]# pvcreate /dev/sda8
Physical volume “/dev/sda8” successfully created
Current status of all Physical Volumes:
[root@vm4 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 oracle lvm2 a- 288.00M 88.00M
/dev/sda6 oracle lvm2 a- 288.00M 248.00M
/dev/sda7 oracle lvm2 a- 288.00M 288.00M
/dev/sda8 lvm2 — 290.21M 290.21M
See /dev/sda8 is not the part of the VG oracle
Step2:
Now we will add the PV /dev/sda8 to Volume Group “oracle”
#vgextend -v oracle /dev/sda8
[ -v is for verbose. To see what is happening]
[root@vm4 ~]# vgextend -v oracle /dev/sda8
Checking for volume group “oracle”
Archiving volume group “oracle” metadata (seqno 5).
Wiping cache of LVM-capable devices
Adding physical volume ‘/dev/sda8’ to volume group ‘oracle’
Volume group “oracle” will be extended by 1 new physical volumes
Creating volume group backup “/etc/lvm/backup/oracle” (seqno 6).
Volume group “oracle” successfully extended
After extending the VG with new Physical Volume:
[root@vm4 ~]# vgs
VG #PV #LV #SN Attr Vsize VFree
oracle 4 2 0 wz–n- 1.12G 912.00M
[root@vm4 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 oracle lvm2 a- 288.00M 88.00M
/dev/sda6 oracle lvm2 a- 288.00M 248.00M
/dev/sda7 oracle lvm2 a- 288.00M 288.00M
/dev/sda8 oracle lvm2 a- 288.00M 288.00M
Now /dev/sda8 became a part of VG oracle.
Removing a Pysical volume form a VG:
Before removing a physical volume from a volume group, you can make sure that the physical volume is not used by any logical volumes by using the #pvdisplay command. If the physical volume is still being used you will have to migrate the data to another physical volume using the#pvmove command. Then use the vgreduce command to remove the physical volume.
Current status of Pysical Volumes:
[root@vm4 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 oracle lvm2 a- 288.00M 88.00M
/dev/sda6 oracle lvm2 a- 288.00M 248.00M
/dev/sda7 oracle lvm2 a- 288.00M 288.00M
/dev/sda8 oracle lvm2 a- 288.00M 288.00M
In this example we will remove the Pysical Volume /dev/sda5 in which some Physical Extents are already used by some LV. So They need to be migrated.
The status of /dev/sds5 is
[root@vm4 ~]# pvdisplay /dev/sda5
— Physical volume —
PV Name /dev/sda5
VG Name oracle
PV Size 290.21 MB / not usable 2.21 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 72
Free PE 22
Allocated PE 50
PV UUID 9l5HlF-h8Of-2J6D-TDr4-BY34-cREh-7U5zxm
Step1:
Migrate the used Pes using #pvmove command
[root@vm4 ~]# pvmove -v /dev/sda5
Finding volume group “oracle”
Archiving volume group “oracle” metadata (seqno 6).
[output truncated]
Creating volume group backup “/etc/lvm/backup/oracle” (seqno 9).
Step2:
Now reduce the Volume Group size by command #vgreduce
#vgreduce VG_name Removing_PV_Path
#vgreduce oracle /dev/sda5
[root@vm4 ~]# vgreduce oracle /dev/sda5
Removed “/dev/sda5” from volume group “oracle”
After Remvoing PV:
[root@vm4 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
oracle 3 2 0 wz–n- 864.00M 624.00M
[root@vm4 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 lvm2 — 290.21M 290.21M /Now not part of oracle VG
/dev/sda6 oracle lvm2 a- 288.00M 248.00M
/dev/sda7 oracle lvm2 a- 288.00M 88.00M
/dev/sda8 oracle lvm2 a- 288.00M 288.00M
Merging two Volume Groups:
Two different Volume Groups can be merged to a single Volume Group.
Suppose we have two VGs “oracle” and “linux”.
Current status of VGs are:
VG #PV #LV #SN Attr VSize VFree
linux 1 0 0 wz–n- 288.00M 288.00M
oracle 3 2 0 wz—n- 864.00M 624.00M
Now we are going to merge “oracle” and “linux” to get a single VG linux.
We are using the command #vgmerge for this.
#vgmerge merges two existing volume groups. The inactive SourceVolumeGroupName will be merged into the DestinationVolumeGroupName if physical extent sizes are equal and physical and logical volume summaries of both volume groups fit into DestinationVolumeGroupName’s limits.
#vgmerge -v databases my_vg
merges the inactive volume group named “my_vg” into the active or inactive volume group named “databases” giving verbose runtime information.
Step1:
we are going to merge “oracle” and “linux” to get a single VG linux.
Make the source Volume Group inactive. In this case source is oracle.
#vgchange -a n oracle
umount the LV which uses the oracle VG then only u can inactivate it.
[root@vm4 ~]# umount /linux1
[root@vm4 ~]# umount /linux2
[root@vm4 ~]# vgchange -a n oracle
0 logical volume(s) in volume group “oracle” now active
#vgmerge Destination Source
we are going to merge “oracle” and “linux” to get a single VG linux. So
#vgmaerge -v linux oracle
[root@vm4 ~]# vgmerge -v linux oracle
Checking for volume group “linux”
Checking for volume group “oracle”
Archiving volume group “oracle” metadata (seqno 10).
Archiving volume group “linux” metadata (seqno 1).
Writing out updated volume group
Creating volume group backup “/etc/lvm/backup/linux” (seqno 2).
Volume group “oracle” successfully merged into “linux”
[root@vm4 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
linux 4 2 0 wz–n- 1.12G 912.00M
[root@vm4 ~]# vgchange -a y linux
2 logical volume(s) in volume group “linux” now active
[root@vm4 ~]# mount /dev/linux/lvm1 /linux1
[root@vm4 ~]# mount /dev/linux/lvm2 /linux2
[root@vm4 ~]# mount
[output truncated]
/dev/mapper/linux-lvm1 on /linux1 type ext3 (rw)
/dev/mapper/linux-lvm2 on /linux2 type ext3 (rw)
[root@vm4 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 lvm2 — 290.21M 290.21M
/dev/sda6 linux lvm2 a- 288.00M 248.00M
/dev/sda7 linux lvm2 a- 288.00M 88.00M
/dev/sda8 linux lvm2 a- 288.00M 288.00M
/dev/sda9 linux lvm2 a- 288.00M 288.00M
Spliting a Volume Group into two:
We can split a Volume Group into two Volume Groups using the command #vgsplit
We have one VG oracle with 4 PVs. We will split that VG oracle to oracle and another VG redhat. The PVs /dev/sda8 and /dev/sda9 will be moved to redhat.
The syntax is as follows:
#vgsplit EXISTING_VG NEW_VG PATH OF PVs_TO _BE_MOVED
#vgsplit oracle redhat /dev/sda8 /dev/sda9
[root@vm4 ~]# vgsplit linux redhat /dev/sda8 /dev/sda9
New volume group “redhat” successfully split from “linux”
Before:
[root@vm4 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
linux 4 2 0 wz–n- 1.12G 912.00M
[root@vm4 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 lvm2 — 290.21M 290.21M
/dev/sda6 linux lvm2 a- 288.00M 248.00M
/dev/sda7 linux lvm2 a- 288.00M 88.00M
/dev/sda8 linux lvm2 a- 288.00M 288.00M
/dev/sda9 linux lvm2 a- 288.00M 288.00M
After:
[root@vm4 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
linux 2 2 0 wz–n- 576.00M 336.00M
redhat 2 0 0 wz–n- 576.00M 576.00M
[root@vm4 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 lvm2 — 290.21M 290.21M
/dev/sda6 linux lvm2 a- 288.00M 248.00M
/dev/sda7 linux lvm2 a- 288.00M 88.00M
/dev/sda8 redhat lvm2 a- 288.00M 288.00M
/dev/sda9 redhat lvm2 a- 288.00M 288.00M
[root@vm4 ~]# vgchange -a y linux
2 logical volume(s) in volume group “linux” now active
[root@vm4 ~]# vgchange -a y redhat
0 logical volume(s) in volume group “redhat” now active

Creating SNAPSHOT (Backup):

We can take the back up of any particular Logical Volumes. Snapshot will be stored in the Same
volume group. Snapshot will take only 3-5% of the original size of Logical Volume.
This is the current status of our machine:

[root@vm4 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvm1 linux -wi-a- 200.00M
lvm2 linux -wi-a- 40.00M
[root@vm4 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
linux 2 2 0 wz–n- 576.00M 336.00M
redhat 2 0 0 wz–n- 576.00M 576.00M
[root@vm4 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 lvm2 — 290.21M 290.21M
/dev/sda6 linux lvm2 a- 288.00M 248.00M
/dev/sda7 linux lvm2 a- 288.00M 88.00M
/dev/sda8 redhat lvm2 a- 288.00M 288.00M
/dev/sda9 redhat lvm2 a- 288.00M 288.00M

We have two Logical Volumes lvm1 and lvm2 mounted on /linux1 and /linux2 respectively.
We’ll take the SNAPSHOT of the LV lvm1 which is mounted on /linux1
currently there are following files in /linux1 [ie in lvm1]
[root@vm4 ~]# cd /linux1
[root@vm4 linux1]# ls
a b c lost+found
Step1:
Snapshot is actually a Logical Volume only. It will be saved in the same VG. We can create lvm
snapshot using command #lvcreate with options for snapshot.
The syntax is as follows
#lvcreate –size SIZE –snapshot –name Name_Of_Snapshot Path_of_the_LV
[root@vm4 linux1]# lvcreate –size 10M –snapshot –name snap /dev/linux/lvm1
Rounding up size to full physical

Logical volume “snap” created


[root@vm4 linux1]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvm1 linux owi-ao 200.00M
lvm2 linux -wi-ao 40.00M
snap linux swi-a- 12.00M lvm1 0.10


[root@vm4 linux1]# vgs
VG #PV #LV #SN Attr VSize VFree
linux 2 3 1 wz–n- 576.00M 324.00M
redhat 2 0 0 wz–n- 576.00M 576.00M

Now lets mount the Snapshpot and check whether it has everything from lvm1.
Mounting snap to /snapshot
[root@vm4 linux1]# mkdir /snapshot
[root@vm4 linux1]# mount /dev/linux/snap /snapshot
[root@vm4 linux1]# cd /snapshot
[root@vm4 snapshot]# ls
a b c lost+found
It has the same and all the contents of lvm1

How to create mirrored lvm volumes:
We can create mirrored lvm using the command #lvcreate with -m option.
The syntax is as follows:
#lvcreate -L Size -m1 -n Name_LV Name_VG Mirror_1st_leg   Mirror_2nd_leg   Log_Device
-m1 means its a mirrored one type. So it will have one original[1st leg] one mirror[2nd leg] and a
logging device for sync.
#lvcreate -L 100M -m1 -n mlvm redhat  /dev/sda5  /dev/sda6  /dev/sda7
[root@vm4 ~]# lvcreate -L 100M -m1 -n mlvm redhat /dev/sda5 /dev/sda6 /dev/sda7
/dev/cdrom: open failed: Read-only file system
Logical volume “mlvm” created
[root@vm4 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
mlvm redhat mwi-a- 100.00M mlvm_mlog 100.00

How to create stripped lvm volumes:
We can create lvms in stripped manner so that it will increase the performance. It can be done
using the commad #lvcreate with -i option.

The syntax is as follows:
#lvcreate -L Size -i2 -n Name_LV Name_VG 1st _LV 2nd _LV
[root@vm4 ~]# lvcreate -L 100M -i2 -n slvm redhat /dev/sda8 /dev/sda9
Using default stripesize 64.00 KB
/dev/cdrom: open failed: Read-only file system
Rounding size (25 extents) up to stripe boundary size (26 extents)
Logical volume “slvm” created
[root@vm4 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
slvm redhat -wi-a- 104.00M

For extending a stripped lvm u need to extend the VG with two different PVs . Else it wont
work.

Recovery of deleted /etc/passwd File in Linux

Recovery of deleted /etc/passwd File in Linux

In that case you need to recover /etc/passwd file first.
For this you have to following steps,

-Start GRUB on boot (press ESC while booting)
-Press e over (recovery mode)
-Press e over the line beginning with kernel
-Press Space bar and enter "init=/bin/bash"
-Press enter
-Press b
-At command prompt type: "cp /etc/passwd- /etc/passwd"
-reboot to GRUB again
-Press e over (recovery mode)
-Press e over the line beginning with kernel
-Press Space bar and enter "init=/bin/bash"
-Press enter
-Press b
-At command prompt type "mount -o remount,rw /"
-Type "passwd YOURUSERNAMEHERE" (IF you don't know your user 
name type "ls /home" (that is a Lower case L and lower case 
S) for a list of users)
-Enter new password at prompt
-reboot to normal boot.

Hope that helps others like it did me!

### Then to recover /etc/shadow file, Use following command
pwconf

This command will generate /etc/shadow file from /etc/passwd

How to secure reverse proxy or Forward proxy

How to secure reverse proxy or Forward proxy

 

ProxyPreserveHost On

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass        /gonvaled/examples/jsonrpc/output/services/ http://localhost:8000/services/
ProxyPassReverse /gonvaled/examples/jsonrpc/output/services/ http://localhost:8000/services/

<IfModule mod_proxy.c>
#turning ProxyRequests on and allowing proxying from all may allow
#spammers to use your proxy to send email.

ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order Allow,Deny
Allow from all
</Proxy>

ProxyPass /transmission http://localhost:9091/transmission
ProxyPassReverse /transmission http://localhost:9091/transmission
# Line below is optional
Redirect permanent /transmission https://myserver.com/transmission/web/

# Enable/disable the handling of HTTP/1.1 “Via:” headers.
# (“Full” adds the server version; “Block” removes all outgoing Via: headers)
# Set to one of: Off | On | Full | Block

ProxyVia On
</IfModule>

ifmodule mod_proxy.c=””>
# set ProxyRequests off since we’re only using the ProxyPass and ProxyPassReverse
# directives. this keeps the server secure from
# spammers trying to use your proxy to send email.

ProxyRequests Off

<proxy *=””>
AddDefaultCharset off
Order deny,allow
Allow from all
#Allow from .example.com
</proxy>

# Enable/disable the handling of HTTP/1.1 “Via:” headers.
# (“Full” adds the server version; “Block” removes all outgoing Via: headers)
# Set to one of: Off | On | Full | Block

ProxyVia On</ifmodule>

# Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
ProxyRequests Off
ProxyPreserveHost On

<proxy *=””>
Order deny,allow
Allow from all
</proxy>

Linux Commands

To view System Resource Information
uname –help
uname -r
grep model /proc/cpuinfo
grep MemFree /proc/meminfo
sudo -u root lastcomm -f /var/account/pacct
cat /proc/version
# cat /proc/cpuinfo
# cat /proc/meminfo
# cat /proc/zoneinfo
# cat /proc/mounts
cat /etc/redhat-release
grep MemTotal /proc/meminfo
grep SwapTotal /proc/meminfo
df -k /tmp
grep “model name” /proc/cpuinfo
ifconfig (/sbin/ifconfig)
uaname -r
lshal:detected hardware
rpm -qa:  display pakage
rpm -qa | less
Linux Kernel Information:
cat /etc/sysctl.conf
cat /etc/hosts
/sbin/ifconfig
Uname -r
cat /etc/security/limits.conf
cat /proc/sys/kernel/sem
cat /proc/sys/kernel/shmmax
cat /proc/sys/kernel/shmall
cat /proc/sys/kernel/shmmni
cat /proc/sys/fs/file-max
cat /proc/sys/net/ipv4/ip_local_port_range
/sbin/lsmod
cat /etc/issue
sysctl -a | grep shm
sysctl -a | grep ip_local_port_range
/etc/inittab:  init process determines which runlevel it should be
w, ps -a, ps -Alf, ps -AlFH, ps -AlLm
ps -u oracle, ps -u anguyen
Commands to monitor bottlenecks such as Disk, Memory / CPU/Network, or System Activity:
top ? t, m, A: top consumer, r: renice, o: interactively select
vmstat 3, vmstat -m:memority slab info, vmstat -a
w, ps -a, ps -Alf, ps -AlFH, ps -AlLm
ps -u oracle, ps -u attunity
uptime
free
fee -s 2
watch -n 3 -d free
watch -d cat /proc/meminfo
sar -B -f /var/log/sa/sa14
sar -W -f /var/log/sa/sa14
vmstat -m
vmstat -a
ipcs -sm
ipcs -lms
sar -n DEV | more
sar 4 5
mpstat -P ALL
MEMORY intensive process:
ps -e -o pmem,pid,user,tty,args | grep -i oracle | sort -n -k 1 -r | head
watch -n 3 -d free
watch -d cat /proc/meminfo
CPU intensive process
top
ps -e -o pcpu,pid,user,tty,args | sort -n -k 1 -r | head
mpstat -P 0 2 20 (processor 0
mpstat -P ALL
sar -u -fDisk Storage
************************************
iostat -d 3, iostat 2 15
iostat -xd 10sorting files by size
***********************
ls -alS | head -5
mpstat -P ALL
sar 4 5
****************************************************
Network
**************************************************
lsmod | grep -i bonding
cat /etc/sysconfig/network-scripts/ifcfg-eth0 (check bonding)..the difference NETWORK, IPADDRESS, NETMASK
netstat -s | less
netstat –interfaces eth0
netstat -ptc
sar -n DEV
netstat -nat | awk ‘{ print $5}’ | cut -d: -f1 | sed -e ‘/^$/d’ | uniq
tcpdump -n -i eth1 -s 0 -w output.txt src or dst port 80
iptraf – Real-time Network Statistics
Network traffic
netstat -ptc
sar -n DEV
sar – Collect and Report System Activity
*************************************************
Oracle
***************************************************
cpio -idmv < 10201_database_linux_x86_64.cpio
id oracle
id nobody
pgrep sshd
env | grep PATH

detected hardware lshal:
init process determines which runlevel it should be /etc/inittab
shutdown
shutdown -t3 -r now
mount /dev/hda4 /data/oracle/bkup1:
grep ‘Ashley Nguyen’ /etc/passwd
find / -name install.log
sed ‘s/anguyen/lvu/’ /etc/passwd > /tmp/test
ps aux | grep nfs
free:
Ifconfig -a
To determine the amount of shared memory available, enter the following command:automatic memory management
# df -k /dev/shm/
To determine the distribution and version of Linux installed, enter the following command:
# cat /proc/version
To determine whether the required packages are installed, enter commands similar to the following:
# rpm -q package_name
Add group
# /usr/sbin/groupadd oper
Modify user:  usermod -g oinstall -G dba oracle
Create disks:
fdisk -l
give password to oracle user
passwd oracle
change ownership in linux
chown
clear screen
clear
TAR – backup / restore
tar -cf myfiles.tar *.trc (create)
tar xvf myfiles.tar (extract)

To create new directory

mkdir target_director

To copy an entire folder (directory tree) in Linux

1
cp -ap /var/lib/mysql /mnt/mysql -ap for same permission as source

For checking the size of current folder

du -ch | grep total

To find the size of the hdd

1
just enter df

To find out the size of the folder in the folder

du
du -a to show all the file's size

See all files and their size

du -s * -h

To output the number of files in the current directory

1
ls | wc -l

See all the jobs

ps -aux

To find out RAM size on Linux machine

free

Rename folder/filename

mv test hope
mv *.rtf *.txt

To find which process is consuming how much RAM?

top

To see the free ram memory

free -m

To update yum using corn

 21 *** usr/bin/yum -y update

Create tar.gz file

tar czvf myfolder.tar.gz abcfolder/

Untar a tar file
tar czvf myfolder.tar.gz abcfolder/
[/sourcecode]

Delete bash History
Try to delete the content of ~/.bash_history

To add new user
* Adding a new user (useradd)
* Modifying an existing user (usermod)

Options:
* -d home directory
* -s starting program (shell)
* -p password
* -g (primary group assigned to the users)
* -G (Other groups the user belongs to)
* -m (Create the user’s home directory

useradd -gusers -Gmgmt -s/bin/shell -pass -d/home/jambura -m jambura

User’s home directory should be 700. If you are operating a ~username type server, the public_html directory should be 777. You may also need to open up the home directory to 755.

useradd -s/bin/bash -pass -d/imp/sysbsd -m sysbsd

For allowing sudo

sudo adduser jambura admin

To delete user

userdel user

To display your crontab file

crontab -l

root can view any users crontab file by adding “-u username”

crontab -u bappy -l  # List bappy's crontab file.

tar tvf myfiles.tar (show the details)

Mount Points and /etc/fstab

Mount Points and /etc/fstab

/etc/fstab is referenced each time the system boots.  It consists fields like device name, mount point, file system type, fsck order like 0 = ignore, 1=fist, 2-9 = second, and third, etc.  After the filesystem is created in /etc/fstab, it’s important to use the mount-a to mount the filesystem just created to check for errors.
umount /apps:  To unmount the file system
fuser -v /apps:  For some reasons you cannot mount a filesystem that has open files, you can display
information  about the processes using a filesystem.
fuser -km /apps:  To kill all actions on a filesystem
mount -o remount,rw / :  To mount in a single operation.  This is common during recovery operation

Monitor Your System Performance

Monitor Your System Performance in Linux

 

@server ~]# uptime
13:14:02 up  1:30,  2 users,  load average: 0.04, 0.26, 0.27

[root@server ~]# ps -eo %u | sort | uniq -c | sort -rn

[root@server ~]# sar -c           ## Process/sec
Linux 2.6.18-164.el5 (server.scratch.com)       08/24/2011

11:50:01 AM    proc/s
12:00:01 PM      6.87
12:10:01 PM      6.90
12:20:01 PM      7.10
12:30:01 PM      6.77
12:40:01 PM      6.99
12:50:01 PM      6.85
01:00:01 PM      6.83
01:10:01 PM      6.92
Average:         6.90

[root@server ~]# sar -b   ## Data r/wr ps
Linux 2.6.18-164.el5 (server.scratch.com)       08/24/2011

11:50:01 AM       tps      rtps      wtps   bread/s   bwrtn/s
12:00:01 PM     24.81      0.18     24.63      6.37    376.94
12:10:01 PM     26.14      0.33     25.81     10.68    388.21
12:20:01 PM     57.68     28.05     29.63    620.21    466.02
12:30:01 PM     24.16      0.13     24.03      1.92    369.00
12:40:01 PM     24.55      0.10     24.44      1.70    374.73
12:50:01 PM     25.07      0.14     24.93      4.31    380.10
01:00:01 PM     24.95      0.58     24.37      6.20    377.88
01:10:01 PM     24.57      0.01     24.56      0.04    376.16
Average:        28.98      3.68     25.30     81.17    388.59

[root@server ~]# iostat -k
Linux 2.6.18-164.el5 (server.scratch.com)       08/24/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
0.40    0.00    3.84    0.44    0.00   95.32

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               6.60        32.24        65.92     177987     363873
sda1              0.10         0.21         0.00       1163          5
sda2              6.50        32.01        65.92     176684     363868
dm-0             20.19        31.54        65.91     174109     363844
dm-1              0.02         0.08         0.00        440          0
dm-2              0.06         0.25         0.00       1397         20
dm-3              0.03         0.11         0.00        613          4

[root@server ~]#

# cat /proc/stat
cpu  1864 0 16482 416939 2375 34 527 0
cpu0 1864 0 16482 416939 2375 34 527 0
intr 2416023 2368439 12 0 2 2 0 5 0 1 0 0 0 116 0 0 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 29989 0 0 0 0 0 0 0 37 0 0 0 0 0 0 0 17399 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 258727
btime 1314166387
processes 32539
procs_running 1
procs_blocked 0

# cat /proc/meminfo
MemTotal:       218872 kB
MemFree:         36680 kB
Buffers:         40416 kB
Cached:          79080 kB
SwapCached:          0 kB
Active:         116728 kB
Inactive:        47320 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       218872 kB
LowFree:         36680 kB
SwapTotal:      614384 kB
SwapFree:       614384 kB
Dirty:             460 kBWriteback:           0 kB
AnonPages:       44556 kB
Mapped:          15936 kB
Slab:            11628 kB
PageTables:       2320 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:    723820 kB
Committed_AS:   376900 kB
VmallocTotal:   802808 kB
VmallocUsed:      3564 kB
VmallocChunk:   798832 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     4096 kB

[root@server ~]# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Pentium(R) Dual-Core  CPU      E5300  @ 2.60GHz
stepping        : 10
cpu MHz         : 2592.870
cache size      : 2048 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss constant_tsc up pni
bogomips        : 5185.74

[root@server ~]# cat /proc/buddyinfo
Node 0, zone      DMA     37     33     31     29     19     12      9      2      0      0      0
Node 0, zone   Normal   2217    861    467    317     71     17      6      1      1      0      0
[root@server ~]#

[root@server ~]# cat /proc/execdomains
0-0     Linux                   [kernel]

[root@server ~]# cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   cpuset
nodev   binfmt_misc
nodev   debugfs
nodev   securityfs
nodev   sockfs
nodev   usbfs
nodev   pipefs
nodev   anon_inodefs
nodev   futexfs
nodev   tmpfs
nodev   inotifyfs
nodev   eventpollfs
nodev   devpts
ext2
nodev   ramfs
nodev   hugetlbfs
iso9660
nodev   mqueue
ext3

[root@server ~]# cat /proc/interrupts
CPU0
0:    2539099    IO-APIC-edge  timer
1:         12    IO-APIC-edge  i8042
6:          5    IO-APIC-edge  floppy
7:          0    IO-APIC-edge  parport0
8:          1    IO-APIC-edge  rtc
9:          0   IO-APIC-level  acpi
12:        116    IO-APIC-edge  i8042
15:         21    IO-APIC-edge  ide1
51:      31376   IO-APIC-level  ehci_hcd:usb1, ioc0
59:         37   IO-APIC-level  uhci_hcd:usb2
67:      19497   IO-APIC-level  eth0
75:          0   IO-APIC-level  Ensoniq AudioPCI
NMI:          0
LOC:    4700127
ERR:          0
MIS:          0

[root@server ~]# cat /proc/iomem

[root@server ~]# cat /proc/loadavg
0.33 0.36 0.29 1/92 2916

[root@server ~]# cat /proc/locks
1: POSIX  ADVISORY  READ  2689 fd:00:320039 4 4
2: POSIX  ADVISORY  WRITE 2732 fd:00:931460 0 EOF
3: POSIX  ADVISORY  READ  2689 fd:00:320021 4 4
4: POSIX  ADVISORY  WRITE 2689 fd:00:288615 0 0
5: POSIX  ADVISORY  READ  2686 fd:00:320027 4 4
6: POSIX  ADVISORY  READ  2686 fd:00:320026 4 4
7: POSIX  ADVISORY  READ  2686 fd:00:320025 4 4
8: POSIX  ADVISORY  READ  2686 fd:00:320024 4 4
9: POSIX  ADVISORY  READ  2686 fd:00:320021 4 4
10: POSIX  ADVISORY  WRITE 2686 fd:00:288614 0 0
11: FLOCK  ADVISORY  WRITE 2641 fd:00:288138 0 EOF
12: POSIX  ADVISORY  WRITE 2592 fd:00:288509 0 EOF
13: POSIX  ADVISORY  WRITE 2592 fd:00:288508 0 EOF
14: POSIX  ADVISORY  WRITE 2592 fd:00:288507 0 EOF
15: POSIX  ADVISORY  WRITE 2457 fd:00:288680 1024 2047

[root@server ~]# cat /proc/net/tcp
sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode
0: 00000000:0185 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7642 1 c8adbb40 3000 0 0 2 -1
1: 0100007F:0CEA 00000000:0000 0A 00000000:00000000 00:00000000 00000000    27        0 7887 1 c8adb240 3000 0 0 2 -1
2: 00000000:008B 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 8138 1 c8ada4c0 3000 0 0 2 -1
3: 00000000:006F 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7482 1 c9720040 3000 0 0 2 -1
4: 00000000:0015 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7778 1 c8adb6c0 3000 0 0 2 -1
5: 0708A8C0:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000    25        0 7399 1 c9720940 3000 0 0 2 -1
6: 0808A8C0:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000    25        0 7397 1 c9720dc0 3000 0 0 2 -1
7: 0908A8C0:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000    25        0 7395 1 c9721240 3000 0 0 2 -1
8: 0A08A8C0:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000    25        0 7393 1 c97216c0 3000 0 0 2 -1
9: 0100007F:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000    25        0 7391 1 c9721b40 3000 0 0 2 -1
10: 0100007F:03B9 00000000:0000 0A 00000000:00000000 00:00000000 00000000    25        0 7407 1 c97204c0 3000 0 0 2 -1
11: 00000000:01BD 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 8137 1 c8ada940 3000 0 0 2 -1
12: 0908A8C0:D26D 3208A8C0:0016 02 00000001:00000000 01:000000DF 00000000   502        0 143213 3 c28d9b40 3000 0 0 2 -1
[root@server ~]#
[root@server ~]# cat /proc/net/udp
sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode
9: 0A08A8C0:0089 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 8108 2 c4db8d00
9: 0908A8C0:0089 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 8106 2 c4db32c0
9: 0808A8C0:0089 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 8104 2 c4db36c0
9: 0708A8C0:0089 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 8102 2 c4db3ac0
9: 00000000:0089 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 8099 2 c8a04080
10: 0A08A8C0:008A 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 8109 2 c4db8b00
10: 0908A8C0:008A 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 8107 2 c4db30c0
10: 0808A8C0:008A 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 8105 2 c4db34c0
10: 0708A8C0:008A 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 8103 2 c4db38c0
10: 00000000:008A 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 8100 2 c4db3cc0
53: 00000000:0035 00000000:0000 07 00000000:00000000 00:00000000 00000000    25        0 7403 2 c96e9c40
53: 0708A8C0:0035 00000000:0000 07 00000000:00000000 00:00000000 00000000    25        0 7398 2 c96e9240
53: 0808A8C0:0035 00000000:0000 07 00000000:00000000 00:00000000 00000000    25        0 7396 2 c96e9440
53: 0908A8C0:0035 00000000:0000 07 00000000:00000000 00:00000000 00000000    25        0 7394 2 c96e9640
53: 0A08A8C0:0035 00000000:0000 07 00000000:00000000 00:00000000 00000000    25        0 7392 2 c96e9840
53: 0100007F:0035 00000000:0000 07 00000000:00000000 00:00000000 00000000    25        0 7390 2 c96e9a40
111: 00000000:006F 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 7476 2 c96e9040
123: 0708A8C0:007B 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 7770 2 c8a04280
123: 0808A8C0:007B 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 7769 2 c8a04480
123: 0908A8C0:007B 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 7768 2 c8a04680
123: 0A08A8C0:007B 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 7767 2 c8a04880
123: 0100007F:007B 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 7766 2 c8a04a80
123: 00000000:007B 00000000:0000 07 00000000:00000000 00:00000000 00000000     0        0 7762 2 c8a04c80

[root@server ~]# cat /proc/net/protocols
protocol  size sockets  memory press maxhdr  slab module     cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
RAWv6      648     -1      -1   NI       0   yes  ipv6        y  y  y  n  y  y  y  n  y  y  y  y  n  y  y  y  y  n  n
UDPv6      620     -1       0   NI       0   yes  ipv6        y  y  y  n  y  n  y  n  y  y  y  y  n  n  y  y  y  y  n
TCPv6     1248     19       1   no     224   yes  ipv6        y  y  y  y  y  y  y  y  y  y  y  y  n  n  y  y  y  y  y
PACKET     444     -1      -1   NI       0   no   kernel      n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n
UNIX       416     -1      -1   NI       0   yes  kernel      n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n
RAW        500     -1      -1   NI       0   yes  kernel      y  y  y  n  y  y  n  n  y  y  y  y  n  y  y  y  y  n  n
UDP        508     -1       0   NI       0   yes  kernel      y  y  y  n  y  n  y  n  y  y  y  y  y  n  y  y  y  y  n
TCP       1136     19       1   no     224   yes  kernel      y  y  y  y  y  y  y  y  y  y  y  y  n  n  y  y  y  y  y
NETLINK    404     -1      -1   NI       0   no   kernel      n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n

[root@server ~]# cat /proc/partitions
major minor  #blocks  name

8     0   31457280 sda
8     1     104391 sda1
8     2   20860402 sda2
253     0    7168000 dm-0
253     1     512000 dm-1
253     2    3891200 dm-2
253     3    2048000 dm-3

[root@server ~]# cat /proc/schedstat
version 12
timestamp 2436227
cpu0 4336 4336 7 4343 7528 307075 58464 139144 139144 192048 1771799 248611
domain0 00000001 661081 661081 0 0 0 0 0 661081 360 360 0 0 0 0 0 360 58464 58464 0 0 0 0 0 58464 0 0 0 0 0 0 0 0 0 0 0 0
[root@server ~]#

[root@server ~]# cat /proc/stat
cpu  2085 0 18967 484888 2403 42 607 0
cpu0 2085 0 18967 484888 2403 42 607 0
intr 2808623 2749553 12 0 2 2 0 5 0 1 0 0 0 116 0 0 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 33013 0 0 0 0 0 0 0 37 0 0 0 0 0 0 0 25861 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 302029
btime 1314166387
processes 37438
procs_running 1
procs_blocked 0

[root@server ~]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/mapper/MYVOL-SWAPer                partition       511992  0       -1
/extraswap                              file            102392  0       -2
[root@server ~]#

[root@server ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
Type:   Direct-Access                    ANSI SCSI revision: 02
[root@server ~]#

[root@server ~]# cat /proc/tty/drivers
/dev/tty             /dev/tty        5       0 system:/dev/tty
/dev/console         /dev/console    5       1 system:console
/dev/ptmx            /dev/ptmx       5       2 system
/dev/vc/0            /dev/vc/0       4       0 system:vtmaster
serial               /dev/ttyS       4 64-95 serial
pty_slave            /dev/pts      136 0-1048575 pty:slave
pty_master           /dev/ptm      128 0-1048575 pty:master
unknown              /dev/tty        4 1-63 console

[root@server ~]# cat /proc/uptime
5253.31 4967.57
[root@server ~]#

[root@server ~]# cat /proc/version
Linux version 2.6.18-164.el5 (mockbuild@builder16.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Thu Sep 3 03:33:56 EDT 2009
[root@server ~]# cat /proc/vmstat
nr_anon_pages 9791
nr_mapped 3984
nr_file_pages 30072
nr_slab 3002
nr_page_table_pages 521
nr_dirty 107
nr_writeback 0
nr_unstable 0
nr_bounce 0
pgpgin 183179
pgpgout 345817
pswpin 0
pswpout 0
pgalloc_dma 8166
pgalloc_dma32 0
pgalloc_normal 3542647
pgalloc_high 0
pgfree 3561159
pgactivate 41504
pgdeactivate 13669
pgfault 12248866
pgmajfault 885
pgrefill_dma 1954
pgrefill_dma32 0
pgrefill_normal 22667
pgrefill_high 0
pgsteal_dma 1177
pgsteal_dma32 0
pgsteal_normal 13810
pgsteal_high 0
pgscan_kswapd_dma 576
pgscan_kswapd_dma32 0
pgscan_kswapd_normal 7328
pgscan_kswapd_high 0
pgscan_direct_dma 608
pgscan_direct_dma32 0
pgscan_direct_normal 7744
pgscan_direct_high 0
pginodesteal 213
slabs_scanned 23552
kswapd_steal 7342
kswapd_inodesteal 289
pageoutrun 198
allocstall 142
pgrotated 0

[root@server ~]#
[root@server ~]# vmstat -m

## Check NC status
[root@server ~]# mii-tool eth0

Learn MySQL

Learn MySQL

How To Connect MySQL Database Tutorial Example

Open your MySQL Client tools then copy & paste the below code to Connect to MySQL database server

   -- mysql.exe location: c:\xampp\mysql\bin\mysql.exe
   -- host: localhost
   -- username: root
   -- password: ***

   -- modify your host location, username, password accordingly.
   -- i am using dos prompt as client. you can use phpmyadmin or anything else you like.

   -- just copy & paste the bellow code in ms-dos prompt
   c:\xampp\mysql\bin\mysql -hlocalhost -uroot -p
      -- that's it!! we are connected to mysql database using the mentioned credentials
      -- is comment in MySQL
      -- in fact it is comment in MSSQL and Oracle as well

How To Create Database In MySQL Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to create a database in MySQL Database Server

   -- How To Create Database In MySQL Tutorial Example

   CREATE DATABASE basic;

   -- that's it!! mysql database "basic" has been created
      -- is comment in MySQL
      -- in fact it is comment in MSSQL and Oracle as well

How To Create Table In MySQL Database Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to create a database table “test” in MySQL Database Server

   -- How To Create Table In MySQL Database Tutorial Example

   CREATE TABLE test
   (
     TestID int(11) default NULL,
     TestName varchar(100) default NULL,
     TestAge int(11) default NULL
   );

   -- that's it!! mysql database table "test" has been created with 3 columns

How To Insert Single Row In MySQL Table Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to Insert into a database table “test” in MySQL Database Server

   -- How To Insert Single Row In MySQL Table Tutorial Example

   INSERT INTO  test(TestID ,TestName,TestAge) VALUES (1 , 'Donald', 33);

   -- that's it!! a row has been inserted in mysql database table "test" with 3 columns value
      -- is comment in MySQL
      -- in fact it is comment in MSSQL and Oracle as well

How To Insert Rows In MySQL Table Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to Insert multiple rows into a database table “test” in MySQL Database Server

-- How To Insert Rows In MySQL Table Tutorial Example

INSERT INTO  test(TestID ,TestName,TestAge) VALUES
(2 , 'Douglas', 34),
(3 , 'Jennifer', 35),
(4 , 'Michael', 49),
(5 , 'Pat', 40),
(6 , 'Susan', 55),
(7 , 'Hermann', 53),
(8 , 'Shelley', 29),
(9 , 'William', 21),
(10, 'Alexander', 42);

-- that's it!!

How To Insert Specific Columns In MySQL Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to Insert specific columns into a database table “test” in MySQL Database Server

-- How To Insert Specific Columns In MySQL Tutorial Example

INSERT INTO  test(TestName,TestAge) VALUES ('Noor.Hasan', 28);

-- that's it!!

Select Data From MySQL Table Tutorial Example

How To Select Data From MySQL Table Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to select or retrive data from a database table “test” in MySQL Database Server

-- How To Select Data From MySQL Table Tutorial Example

SELECT * FROM  test;

-- that's it!!

How To Select Specific Rows From MySQL Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to select or retrive specific rows data from a database table “test” in MySQL Database Server

-- How To Select Specific Rows From MySQL Tutorial Example

SELECT TestName, TestAge FROM  test WHERE TestID=10;

-- that's it!! TestName, TestAge columns of id=10 of mysql database table "test" has been selected

How To Select Data Using Like From MySQL Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to select or retrive rows data using LIKE from a database table “test” in MySQL Database Server

-- How To Select Data Using Like From MySQL Tutorial Example

SELECT * FROM test WHERE TestName LIKE '%Do%';

-- that's it!! all rows and all columns of mysql database table "test"
-- whose Name has the string "Do" have been selected

 

How To Ascending Sort/Order MySQL Data Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to select or retrive data ascendingly sort or order from a database table “test” in MySQL Database Server

-- How To Ascending Sort/Order MySQL Data Tutorial Example

SELECT * FROM test ORDER BY TestName ASC;

-- that's it!! all rows & columns of mysql database table "test" have been selected
-- Sort or Order By TestName Ascendingly

How To Descending Sort/Order MySQL Data Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to select or retrive data descendingly sort or order from a database table “test” in MySQL Database Server

-- How To Descending Sort/Order MySQL Data Tutorial Example

SELECT * FROM test ORDER BY TestName DESC;

-- that's it!! all rows & columns of mysql database table "test" have been selected
-- Sort or Order By TestName Descendingly


How To Update Data In MySQL Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to update from a database table “test” in MySQL Database Server

-- How To Update Data In MySQL Tutorial Example

UPDATE test SET TestAge=99;

-- that's it!!

How To Update Specific Rows In MySQL Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to update specific rows from a database table “test” in MySQL Database Server

-- How To Update Specific Rows In MySQL Tutorial Example

UPDATE test SET TestID=11 WHERE TestName='Noor.Hasan';

-- that's it!! TestID column of all rows of mysql database table "test" have/has been updated
-- whose TestName value is "Noor.Hasan"

How To Delete Specific Rows Data From MySQL Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to delete specific rows from a database table “test” in MySQL Database Server

-- How To Delete Specific Rows Data From MySQL Tutorial Example

DELETE FROM test WHERE TestName='Noor.Hasan';

-- that's it!! all rows of mysql database table "test" have/has been deleted
-- whose TestName value is "Noor.Hasan"

How To Delete Data From MySQL Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to delete data from a database table “test” in MySQL Database Server

-- How To Delete Data From MySQL Tutorial Example

DELETE FROM test;

-- that's it!! all rows of mysql database table "test" have/has been deleted
-- because there is no WHERE condition, so be careful before using it in Production one 


MySQL TRUNCATE TABLE Example

Open your SQL Query Editor then copy & paste the below code to TRUNCATE a table in MySQL:

   TRUNCATE TABLE test

MySQL TRUNCATE TABLE Example – Execution in SQL Query Editor

How To Drop Table From MySQL Database Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to drop table “test” from a database in MySQL Database Server

-- How To Drop Table From MySQL Database Tutorial Example

DROP TABLE test;

-- that's it!! mysql database table "test" has been droped


How To Drop Database In MySQL Tutorial Example

Open your MySQL Query Editor then copy & paste the below code to drop a database in MySQL Database Server

-- How To Drop Database In MySQL Tutorial Example

DROP Database basic;

-- that's it!! mysql database "basic" has been droped forever



Java in Centos

Install java in centos

1. Download bin file using below command

 wget http://download.oracle.com/otn-pub/java/jdk/6u27-b07/jdk-6u27-linux-i586.bin

If the link is not working,  Please use the below link, If you need latest one download it.

http://www.oracle.com/technetwork/java/javase/downloads/index.html

2. After download complete it look like

jdk-6u26-linux-x64.bin?e=1312191174&h=c5f0b98f8ea25aca97f3b53be8497570

so we need to rename the file using below command,

 mv  jdk-6u26-linux-x64.bin?e=1312191174&h=c5f0b98f8ea25aca97f3b53be8497570  jdk-6u4-linux-x64.bin

3. Move the self-extracting file to where you want to install it and extract the file

 mv jdk-6u4-linux-x64.bin /opt/

 cd /opt

 sh jdk-6u4-linux-x64.bin

4. Create a bash script to set JAVA_HOME and add Java executables to the path.

 vim /etc/profile.d/java.sh

export JAVA_HOME=/opt/jdk1.6.0_26/
export PATH=$JAVA_HOME/bin:$PATH

5. Source you new script so exports take effect

 source /etc/profile.d/java.sh

6. Setup Java to be used by the alternatives system (if you want, or if you have an existing install of Java on your box.

alternatives –install /usr/bin/java java /opt/jdk1.6.0_04/bin/java 2

7. Set this new alternatives as the current configuration

 alternatives –config java

Result:

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.4.2-gcj/jav
 + 2           /usr/java/jdk1.6.0_20/bin/java
*  3           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java

Just note down the number you are going to use.

2 — alternative number noted in step 6.

After complete the process just conform using

java -version

 

Note: JAVA FOR 1.6 VERSION 

vi /etc/proflie.d/java.sh 

export JAVA_HOME=/usr/java/jdk1.6.0_35
export JRE_HOME=/usr/java/jdk1.6.0_35/jre
export PATH=$PATH:/usr/java/jdk1.6.0_35/bin
export CLASSPATH=./:/usr/java/jdk1.6.0_35/lib:/usr/java/jdk1.6.0_35/jre/lib

Note: JAVA FOR 1.7  VERSION

export JAVA_HOME=/usr/jdk1.7.0_09

export JAVA_BIN=/usr/jdk1.7.0_09/bin

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

update-alternatives –install /usr/bin/java java /usr/jdk1.7.0_09/bin/java 300

update-alternatives –install /usr/bin/javac javac /usr/jdk1.7.0_09/bin/javac 300

update-alternatives –config java