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.
Disable other security controls to enable future attacks.
|
||||||||||||||||||||||||||||||||||||||||||
Network AttacksYour 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
A 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 <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 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:
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:
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 [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. Logical volume “snap” created Now lets mount the Snapshpot and check whether it has everything from lvm1. How to create mirrored lvm volumes: How to create stripped lvm volumes: 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 Recovery of deleted /etc/passwd File in LinuxIn 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
ProxyPreserveHost On <Proxy *> ProxyPass /gonvaled/examples/jsonrpc/output/services/ http://localhost:8000/services/ <IfModule mod_proxy.c> ProxyRequests Off ProxyPass /transmission http://localhost:9091/transmission # Enable/disable the handling of HTTP/1.1 “Via:” headers. ProxyVia On ifmodule mod_proxy.c=””> ProxyRequests Off <proxy *=””> # Enable/disable the handling of HTTP/1.1 “Via:” headers. ProxyVia On</ifmodule> # Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts) <proxy *=””> 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
To copy an entire folder (directory tree) in Linux
For checking the size of current folder
To find the size of the hdd
To find out the size of the folder in the folder
See all files and their size
To output the number of files in the current directory
See all the jobs
To find out RAM size on Linux machine
Rename folder/filename
To find which process is consuming how much RAM?
To see the free ram memory
To update yum using corn
Create tar.gz file
Untar a tar file Delete bash History To add new user Options:
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.
For allowing sudo
To delete user
To display your crontab file
root can view any users crontab file by adding “-u username”
tar tvf myfiles.tar (show the details) 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. Monitor Your System Performance in Linux
@server ~]# uptime [root@server ~]# ps -eo %u | sort | uniq -c | sort -rn [root@server ~]# sar -c ## Process/sec 11:50:01 AM proc/s [root@server ~]# sar -b ## Data r/wr ps 11:50:01 AM tps rtps wtps bread/s bwrtn/s [root@server ~]# iostat -k avg-cpu: %user %nice %system %iowait %steal %idle Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn [root@server ~]# # cat /proc/stat # cat /proc/meminfo [root@server ~]# cat /proc/cpuinfo [root@server ~]# cat /proc/buddyinfo [root@server ~]# cat /proc/execdomains [root@server ~]# cat /proc/filesystems [root@server ~]# cat /proc/interrupts [root@server ~]# cat /proc/iomem [root@server ~]# cat /proc/loadavg [root@server ~]# cat /proc/locks [root@server ~]# cat /proc/net/tcp [root@server ~]# cat /proc/net/protocols [root@server ~]# cat /proc/partitions 8 0 31457280 sda [root@server ~]# cat /proc/schedstat [root@server ~]# cat /proc/stat [root@server ~]# cat /proc/swaps [root@server ~]# cat /proc/scsi/scsi [root@server ~]# cat /proc/tty/drivers [root@server ~]# cat /proc/uptime [root@server ~]# cat /proc/version [root@server ~]# ## Check NC status Learn MySQLHow To Connect MySQL Database Tutorial ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleHow To Select Data From MySQL Table Tutorial ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 ExampleOpen 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 EditorHow To Drop Table From MySQL Database Tutorial ExampleOpen 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 ExampleOpen 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 Install java in centos1. 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/ 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 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 |
||||||||||||||||||||||||||||||||||||||||||
Copyright © 2025 - All Rights Reserved Powered by WordPress & Atahualpa |
Recent Comments