Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Sunday, May 14, 2017

removing file extensions for a group of files

Below are the couple of ways with which we can replace/remove a file extension for a group of files.

i.e renaming a file from "abcxyz.processed" to "abcxyz".


method 1:

for file in *processed
do
    mv -i "${file}" "${file/.processed/}"
done



method 2:

find . -name "*.processed" -exec rename 's/.processed$//' {} \;

Tuesday, March 28, 2017

awk substring function

To search for couple of strings in a single line, from a file.


cat somefile.txt |  awk 'substr($0,73,3)=="ABC" && substr($0,177,4)=="WXYZ" {print}'


Here we are searching for the strings in position 70-73 for the 1st string and for the 2nd string in 170-174 position in the same line.

pargs - full details of a process

To get full details of a process, issue pargs command

$pargs -l 15549
/u01/app/oracle/apps/tech_st/10.1.3/appsutil/jdk/bin/java '-DCLIENT_PROCESSID=15549'
-server
-verbose:gc
-Xmx512M
-Xms128M '
-XX:MaxPermSize=160M' '
-XX:NewRatio=2' '
-XX:+PrintGCTimeStamps' '
-XX:+UseTLAB' '
-XX:+UseParallelGC' '
-XX:ParallelGCThreads=2'
-Dcom.sun.management.jmxremote '
-Djava.security.policy=/u01/app/oracle/apps/tech_st/10.1.3/j2ee/oacore/config/java2.policy' '
-Djava.awt.headless=true' '
-Dhttp.webdir.enable=false' '
-Doracle.security.jazn.config=/u01/app/oracle/inst/apps/DEV_orasys/ora/10.1.3/j2ee/oacore/config/jazn.xml' '
-Dhttp.cookie.ignoreCommaInCookiesNamed=X_NoMatchingCookies' '
-Doracle.ons.oraclehome=/u01/app/oracle/apps/tech_st/10.1.3' '
-Doracle.home=/u01/app/oracle/apps/tech_st/10.1.3' '
-Doracle.ons.oracleconfighome=/u01/app/oracle/inst/apps/DEV_orasys/ora/10.1.3' '
-Doracle.ons.clustername=default' '
-Doracle.ons.instancename=DEV_orasys.orasys.devglobalpay.com' '
-Dopmn.compatible=904' '
-Doracle.ons.indexid=oacore.default_group.1' '
-Doracle.ons.numprocs=1' '
-Doracle.ons.uid=1382292201' '
-Doracle.oc4j.groupname=default_group' '
-Doracle.oc4j.instancename=oacore' '
-Doracle.oc4j.islandname=default_group' '
-Doracle.opmn.routingid=g_rt_id' '
-DOPMN=true' -jar oc4j.jar
-config /u01/app/oracle/inst/apps/DEV_orasys/ora/10.1.3/j2ee/oacore/config/server.xml
-properties
-out /u01/app/oracle/inst/apps/DEV_orasys/logs/ora/10.1.3/opmn/oacorestd.out
-err /u01/app/oracle/inst/apps/DEV_orasys/logs/ora/10.1.3/opmn/oacorestd.err
-ports default-web-site:ajp:21515,rmi:20015,jms:23015

Saturday, June 18, 2016

How to get process id attached with particular port in SunOS

Solution 1:

$ lsof -i :6200


Solution 2:

Usage:
#pcp -p PORT_NUMBER or 
#pcp -P PROCESS_ID
-----------------------------------------------------------------------------------------------
#!/usr/bin/ksh
#
# # PCP (PID con Port)
# v1.10 08/10/2010 Sam Nelson sam @ unix.ms
#
# If you have a Solaris 8, 9 or 10 box and you can't
# install lsof, try this. It maps PIDS to ports and vice versa.
# It also shows you which peers are connected on which port.
# Wildcards are accepted for -p and -P options.
#
# Many thanks Daniel Trinkle trinkle @ cs.purdue.edu
# for the help, much appreciated.

#
i=0
while getopts :p:P:a opt
do
case "${opt}" in
p ) port="${OPTARG}";i=3;;
P ) pid="${OPTARG}";i=3;;
a ) all=all;i=2;;
esac
done
if [ $OPTIND != $i ]
then
echo >&2 "usage: $0 [-p PORT] [-P PID] [-a] (Wildcards OK) "
exit 1
fi
shift `expr $OPTIND - 1`
if [ "$port" ]
then
# Enter the port number, get the PID
#
port=${OPTARG}
echo "PID\tProcess Name and Port"
echo "_________________________________________________________"
for proc in `ptree -a | awk '/ptree/ {next} {print $1};'`
do
result=`pfiles $proc 2> /dev/null| egrep "port: $port$"`
if [ ! -z "$result" ]
then
program=`ps -fo comm= -p $proc`
echo "$proc\t$program\t$port\n$result"
echo "_________________________________________________________"
fi
done
elif [ "$pid" ]
then
# Enter the PID, get the port
#
pid=$OPTARG
# Print out the information
echo "PID\tProcess Name and Port"
echo "_________________________________________________________"
for proc in `ptree -a | awk '/ptree/ {next} $1 ~ /^'"$pid"'$/ {print $1};'`
do
result=`pfiles $proc 2> /dev/null| egrep port:`
if [ ! -z "$result" ]
then
program=`ps -fo comm= -p $proc`
echo "$proc\t$program\n$result"
echo "_________________________________________________________"
fi
done
elif [ $all ]
then
# Show all PIDs, Ports and Peers
#
echo "PID\tProcess Name and Port"
echo "_________________________________________________________"
for proc in `ptree -a | sort -n | awk '/ptree/ {next} {print $1};'`
do
out=`pfiles $proc 2>/dev/null| egrep "port:"`
if [ ! -z "$out" ]
then
name=`ps -fo comm= -p $proc`
echo "$proc\t$name\n$out"
echo "_________________________________________________________"
fi
done
fi
exit 0


Tuesday, April 26, 2016

command: not found (declare: not found)


If you have any of these shebangs

Code:
#!/bin/sh
#!/bin/dash
#!/bin/bash
#!/bin/tcsh
#!/bin/zsh
#!/bin/awesome_shell
but you still call your code with
Code:
sh my_script.sh
the program effectively used will be "sh", and the shebang will be ignored.

You need to use the appropriate shell
Code:
sh   my_script.sh     # If the shebang is #!/bin/sh
dash my_script.sh     # If the shebang is #!/bin/dash
bash my_script.sh     # If the shebang is #!/bin/bash
tcsh my_script.sh     # If the shebang is #!/bin/tcsh
zsh  my_script.sh     # If the shebang is #!/bin/zsh
or better yet, just give the full or relative path of the script
Code:
./my_script.sh
then the shell used, is the same as the shebang.

Wednesday, July 8, 2015

Advanced Format: 4k Sector Size


For understanding of Advance Formating and other various terminologies like Emulation mode and Native mode, check this site: http://flashdba.com/4k-sector-size/




Monday, April 13, 2015

Automate file transfer from FTP to UNIX server



#!/bin/sh
set -x
rm commands.txt

echo "Enter the Path... example:"
echo "/oraftp/OraFin"
echo "/oraftp/OraFin/mm541"
read pth
        echo "cd $pth" > commands.txt

echo "Name of the file?"
read file_name
        echo "get $file_name" >> commands.txt

echo "Below are the Path and the file name you entered"
cat commands.txt

sftp -b commands.txt oraftp@10.10.10.10


#Note: This setup works only when passwordless authentication is eanbled b/w the servers.

https://libsys.kctcs.edu/stapleton/file-xfer/scripting.html
http://linuxcommand.org/wss0090.php

Saturday, March 28, 2015

Configuring a new disk in Linux


[root@ebsapp01 ~]# cd /dev/
[root@ebsapp01 dev]# ls -l sd*
brw-rw----  1 root disk 8,  0 Aug 29  2014 sda
brw-rw----  1 root disk 8,  1 Aug 29  2014 sda1
brw-rw----  1 root disk 8,  2 Aug 29  2014 sda2
brw-rw----  1 root disk 8, 16 Aug 29  2014 sdb
brw-rw----  1 root disk 8, 17 Aug 29  2014 sdb1
brw-rw----  1 root disk 8, 32 Aug 29  2014 sdc

--------------------------------------------------------------------------------------

[root@ebsapp01 dev]# fdisk sdc

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklab el
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 26108.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk sdc: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-26108, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-26108, default 26108):
Using default value 26108

Command (m for help): p

Disk sdc: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
  sdc1               1       26108   209712478+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

--------------------------------------------------------------------------------------

[root@ebsapp01 dev]# mkdir -p /db01

--------------------------------------------------------------------------------------

[root@ebsapp01 ~]# mkfs.ext3 /dev/sdc1

mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
26214400 inodes, 52428119 blocks
2621405 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=54525952
1600 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

--------------------------------------------------------------------------------------

[root@ebsapp01 ~]# mount -t ext3 /dev/sdc1 /db01/

[root@ebsapp01 ~]# mount -a

[root@ebsapp01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             7.9G  2.1G  5.5G  28% /
none                  506M     0  506M   0% /dev/shm
/dev/sdb1             2.0G  270M  1.8G  14% /app01
/dev/sdc1             197G   93M  187G   1% /db01

--------------------------------------------------------------------------------------


[root@ebsapp01 ~]# grep "/dev/sdc1" /etc/fstab

/dev/sdc1               /db01                   ext3    defaults        0 0
[root@ebsapp01 ~]#


http://geektnt.com/how-to-format-and-mount-second-hard-drive-on-linux.html

Monday, January 12, 2015

public and private key differences



The Public and Private key pair comprise of two uniquely related cryptographic keys (basically long random numbers). Below is an example of a Public Key:
3048 0241 00C9 18FA CF8D EB2D EFD5 FD37 89B9 E069 EA97 FC20 5E35 F577 EE31 C4FB C6E4 4811 7D86 BC8F BAFA 362F 922B F01B 2F40 C744 2654 C0DD 2881 D673 CA2B 4003 C266 E2CD CB02 0301 0001
The Public Key is what its name suggests - Public. It is made available to everyone via a publicly accessible repository or directory. On the other hand, the Private Key must remain confidential to its respective owner.
Comodo - SSL Certificate Authority

Because the key pair is mathematically related, whatever is encrypted with a Public Key may only be decrypted by its corresponding Private Key and vice versa.
For example, if Bob wants to send sensitive data to Alice, and wants to be sure that only Alice may be able to read it, he will encrypt the data with Alice's Public Key. Only Alice has access to her corresponding Private Key and as a result is the only person with the capability of decrypting the encrypted data back into its original form.
Comodo - SSL Certificate Authority

As only Alice has access to her Private Key, it is possible that only Alice can decrypt the encrypted data. Even if someone else gains access to the encrypted data, it will remain confidential as they should not have access to Alice's Private Key.
Public Key Cryptography can therefore achieve Confidentiality. However another important aspect of Public Key Cryptography is its ability to create a Digital Signature.

source: https://www.comodo.com/resources/small-business/digital-certificates2.php?key5sk1=d1e305ec97a4884240a5beb0bbf1752567484838&key5sk2=&key5sk3=1421051826000&key5sk4=&key5sk5=1421051997000&key5sk6=&key5sk7=1421056404000&key5sk8=&key5sk9=1421056410000&key5sk10=&key5sk11=1421060369000&key5sk12=&key5sk13=1421061153000&key5sk14=&key5sk15=1421061592000&key5sk16=&key5sk17=1421074159000&key5sk18=&key5sk19=1421074167000&key5sk20=&key5sk21=1421074168000&key6sk1=&key6sk2=FF330&key6sk3=7&key6sk4=en-us&key6sk5=US&key6sk6=0&key6sk7=Google&key6sk8=150-1&key6sk9=1366768&key6sk10=true&key6sk11=3a127a12f97ae13ecb45f2ba97a030ec0027da10&key6sk12=2037&key7sk1=399&key7sk2=406&key7sk3=399&key7sk4=7611&key7sk5=399&key7sk6=406&key7sk7=412&key7sk8=406&key1sk1=ors&key1sk2=Google

Friday, September 5, 2014

GParted - Increase disk size of a Linux native partition


Prerequisites:
You will need to download the GParted live CD ISO file so that you can use it later, you can get this here.
Below is an image displaying disk information on the server before we begin.
disk free and fdisk
It is important to identify that you are actually using a Linux native partition – as this is what we are extending. As you can see in the above image /dev/sda1 is listed as “Linux” and it has the ID of 83. The 83 hex code shows that it is a Linux native partition, while 8e shows a Linux LVM.
Note that /dev/sda1 is the partition we will be expanding.
Increasing the virtual hard disk
First off we increase the allocated disk space on the virtual machine itself.
VMware virtual disk increase
Booting into the GParted Live CD
Mount GParted live CD



Now we are ready to power on the virtual machine.
Once the virtual machine has powered on and you have booted to the CD, you will be presented with the following menu, just press enter to boot into GParted Live (Default Settings).
GParted
After some time you will then arrive at the following screen, for this I did not change anything and just accepted the defaults by pressing enter.
GParted
You will then be prompted to select a language, pressing enter defaults to English.
GParted
Next we select the default option 0 by pressing enter as we will be working with the GUI.
GParted
Once complete you will be presented with the GUI with GParted already open, if it is not already open you can select it from the Desktop icon.
GParted
As you can see the original /dev/sda1 partition that is making use of the 20gb disk is there, as well as the new unallocated 10gb from when we increased the size of the virtual hard disk earlier. The space between the two is the swap space. The total /dev/sda disk size of 30gb is also shown.
What needs to be done now is get /dev/sda1 to take up that unallocated space, this is not currently possible because swap is in the way so we need to move things around. If you do not have swap in between the partition to be extended and the unallocated space then you will be able to skip down a few steps until you arrive at the image where /dev/sda1 and the unallocated space are next to each other.
First we select /dev/sda2 which is the extended partition containing the swap, we want to expand this to include the 10gb of unallocated space.
Select /dev/sda2 and click “Resize/Move” and you will be presented with the following.
GParted
Basically you just need to drag the black arrow of /dev/sda2 all the way to the end of the unallocated space and click the Resize/Move button.
GParted
After doing this, you should see /dev/sda2 (represented by the blue box) spread out over the unallocated space.
GParted
This change and all further changes will not yet be applied, you can see the tasks down the bottom of the GParted interface and these will be applied only once you click the Apply button. Alternatively you can click the Undo button to remove a pending change.
This time we want to select /dev/sda5 which is the swap partition and select Resize/Move, this will result in the following.
GParted
This time rather than expanding the partition, we want to just move swap all the way to the end of the /dev/sda2 space that it is in, this is done by just dragging the box to the end which will then look like this.
GParted
Click the Resize/Move button and then a warning may appear informing you that moving a partition might cause your operating system to fail to boot. It also warns that performing this move may take a long time to apply, read the warning then click OK to continue.
The GUI should now look something like the below image, where /dev/sda1 is located right next to /dev/sda2 which contains the unallocated space.
GParted
Select the /dev/sda2 extended partition and click Resize/Move.
GParted
Drag this to the right so that only the swap space is contained and the grey unallocated space is freed, click Resize/Move once complete.
GParted
Once this is complete the disk will look like this.
GParted
Now we have /dev/sda1 next to the unallocated space so we are finally ready to expand /dev/sda1. Select /dev/sda1 and click the Resize/Move button.
GParted
You will be able to perform this action straight away if you did not have swap in between /dev/sda1 and the unallocated space, the previous steps were to get swap out of the way in GParted.
Drag the arrow over so that the unallocated space is then consumed by /dev/sda1 as shown below, then click Resize/Move.
GParted
Once this is done the /dev/sda1 partition will now be using the unallocated space that was previously there. All that is left to do is click the apply button which will apply the changes – you will be prompted to confirm with a warning that data loss may occur.
Note that this may take a while depending on how much of the disk is currently in use and the amount of disk space you are increasing, because a file system check (fsck) is run before the expansion and after it to ensure that there are no issues. I have performed this method on a 400gb server in the past and to increase it 100gb took approximately 5 hours. In this example I am only increasing by 10gb and there is only about 1gb of data on the disk so this took approximately 2 minutes to finish applying.
Once complete you will see something similar to the below image, you will be able to click close once finished.
GParted
Everything is now finished, you just need to reboot the virtual machine and then boot from disk rather than CD, alternatively shut down the virtual machine and unmount the live CD and then power it back on.
Once the operating system has booted you can confirm that the disk space has expanded correctly. Below you can see that /dev/sda1 is now 30gb in size.
GParted


Friday, August 15, 2014

Installing a lower version rpm using YUM

You are trying to install a rpm and it got errored because of "missing dependency" where the dependency required is already installed but it's on a higher version.

# yum install ocfs2-2.6.9-67.0.0.0.1.ELxenU-1.2.7-1.el4
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for ocfs2-2.6.9-67.0.0.0.1.ELxenU to pack into transaction set.
ocfs2-2.6.9-67.0.0.0.1.EL 100% |=========================| 2.9 kB 00:00
---> Package ocfs2-2.6.9-67.0.0.0.1.ELxenU.i686 0:1.2.7-1.el4 set to be updated
--> Running transaction check
--> Processing Dependency: kernel-xenU = 2.6.9-67.0.0.0.1.EL for package: ocfs2-2.6.9-67.0.0.0.1.ELxenU
--> Finished Dependency Resolution
Error: Missing Dependency: kernel-xenU = 2.6.9-67.0.0.0.1.EL is needed by package ocfs2-2.6.9-67.0.0.0.1.ELxenU

Step 1:
Identify the "missing dependency" package you have.

# yum list kernel-xenU*
Setting up repositories
Reading repository metadata in from local files
Installed Packages
kernel-xenU.i686                         2.6.9-103.0.0.0.1.EL   installed
kernel-xenU-devel.i686                   2.6.9-103.0.0.0.1.EL   installed


Step 2:
If you have the higher version package remove it.

# yum remove kernel-xenU.i686
Setting up Remove Process
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package kernel-xenU.i686 0:2.6.9-103.0.0.0.1.EL set to be erased
--> Running transaction check

Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Removing:
kernel-xenU i686 2.6.9-103.0.0.0.1.EL installed 8.4 M

Transaction Summary
=============================================================================
Install 0 Package(s)
Update 0 Package(s)
Remove 1 Package(s)
Total download size: 0
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Removing : kernel-xenU ######################### [1/1]

Removed: kernel-xenU.i686 0:2.6.9-103.0.0.0.1.EL
Complete!


Step 3:
Install the package with the required version

# yum install kernel-xenU-2.6.9-67.0.0.0.1.EL
Setting up Install Process
Setting up repositories
el4_latest 100% |=========================| 1.4 kB 00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for kernel-xenU to pack into transaction set.
kernel-xenU-2.6.9-67.0.0. 100% |=========================| 198 kB 00:02
---> Package kernel-xenU.i686 0:2.6.9-67.0.0.0.1.EL set to be installed
--> Running transaction check

Dependencies Resolved=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
kernel-xenU i686 2.6.9-67.0.0.0.1.EL el4_latest 3.6 M

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 3.6 M
Is this ok [y/N]: y
Downloading Packages:
(1/1): kernel-xenU-2.6.9- 100% |=========================| 3.6 MB 00:37
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: kernel-xenU ######################### [1/1]
WARNING: No module mptbase found for kernel 2.6.9-67.0.0.0.1.ELxenU, continuing anyway
WARNING: No module mptscsi found for kernel 2.6.9-67.0.0.0.1.ELxenU, continuing anyway
WARNING: No module mptspi found for kernel 2.6.9-67.0.0.0.1.ELxenU, continuing anyway
WARNING: No module mptsas found for kernel 2.6.9-67.0.0.0.1.ELxenU, continuing anyway
WARNING: No module mptscsih found for kernel 2.6.9-67.0.0.0.1.ELxenU, continuing anyway
WARNING: No module ata_piix found for kernel 2.6.9-67.0.0.0.1.ELxenU, continuing anyway

Installed: kernel-xenU.i686 0:2.6.9-67.0.0.0.1.EL
Complete!
[root@shared Desktop]#


Step 4:
Try install your main package.

# yum install ocfs2-2.6.9-67.0.0.0.1.ELxenU-1.2.7-1.el4
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package ocfs2-2.6.9-67.0.0.0.1.ELxenU.i686 0:1.2.7-1.el4 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
ocfs2-2.6.9-67.0.0.0.1.ELxenU i686 1.2.7-1.el4 el4_latest 296 k

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 296 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): ocfs2-2.6.9-67.0.0 100% |=========================| 296 kB 00:02
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: ocfs2-2.6.9-67.0.0.0.1.ELxen ######################### [1/1]

Installed: ocfs2-2.6.9-67.0.0.0.1.ELxenU.i686 0:1.2.7-1.el4
Complete!

Change/Remove node entries from OCFS2 config file

Step 1: Stop the cluster service 
#/etc/init.d/o2cb offline
#/etc/init.d/o2cb unload


Step 2: Edit the config file 
/etc/ocfs2/cluster.conf


Step 3: Start the cluster service
#/etc/init.d/o2cb load
#/etc/init.d/o2cb online
 
Source: https://oss.oracle.com/projects/ocfs2/dist/documentation/v1.2/ocfs2_faq.html#O2CB

Wednesday, August 13, 2014

Create Multiple IP Addresses to One Single Network Interface

Source: http://www.tecmint.com/create-multiple-ip-addresses-to-one-single-network-interface/

Install & Configure YUM on Linux

source: http://public-yum.oracle.com/#a6

Step 1:

cd /etc/yum.repos.d wget http://public-yum.oracle.com/public-yum-ovm2.repo

Step 2:
Open the yum configuration file in a text editor
Locate the section in the file for the repository you plan to update from, e.g. [el4_u6_base]
Change enabled=0 to enabled=1

Step3:

yum list
yum install firefox --- To install firefox software.

Tuesday, August 5, 2014

Adding & Configuring a new disk to a VMWare Virtual Machine in Linux

Source: http://www.matttopper.com/2006/05/adding-a-new-disk-to-a-vmware-virtual-machine-in-linux/comment-page-5/
 
http://download.parallels.com/desktop/v9/ga/docs/en_US/Parallels%20Desktop%20User%27s%20Guide/27773.htm



Step 1: Open virtual machine settings
Select your virtual machine, as you can see from the photo I selected the Infrastructure virtual machine. Next press the “Edit virtual machine settings’ to open the Virtual Machine Settings dialog.
 

Step 2: Add new hardware
From the “Virtual Machine Settings” dialog select the “Add…” button at the bottom of the screen. From this dialog you can also modify how much memory you dedicate to the machine when it boots.

Step 3: Select new hard disk
From this screen we can see the many types of hardware we can add to a virtual machine. You can emulate just about any piece of hardware that one can expect in a modern operating system. It definitely makes testing with different configurations and devices much easier. For our example we want to select “Hard Disk” and then select the “Next >” button.

Step 4: Create the virtual disk
In the next screen we see the three options for adding a new disk. We can “Create a new virtual disk”, this will create a brand new disk on the guest operating system. The second option, “Use an existing virtual disk”, allows you to mount a disk from another virtual machine. I like to do this with my “source” drive. I have one virtual disk that I’ve made that has all the Oracle and Linux CDs on it, that way I can just mount it to the machine I need when I have to do a new install instead of copying the binaries I need across disks, its definitely a big time saver. The last option is to “Use a physical disk”, this allows you to mount a local physical disk to the operating system. This option is akin to NFS mounting a drive to a virtual machine. To add a new disk we select the “Create a new virtual disk” option and select the “Next >” button.

Step 5: Select type of disk
Next we want to select the type of disk. I’ve been using VMWare for a long time and agree that the recommended Virtual Disk Type should be SCSI. I don’t know why, but I’ve had much better success with the SCSI virtual disks than the IDE ones. So in this step we want to select “SCSI (Recommended)” and the “Next >” button.

Step 6: Set disk size and options
Now we want to set the size of the disk we are creating. One of the nice features of VMWare is that you don’t have to allocate all of the disk when you create it. So if you create a 40 GB disk it doesn’t have to take it all right away, the disk will grow as your virtual machine needs it. I will say this is a big performance hit you take when the disk has to extend, but for most applications its OK. Also, I will warn that if the virtual disk grows and there is no physical disk left on the host operating system you will see a catastrophic failure and in most cases both the host and guest operating systems lock up and become unusable. (Don’t say I didn’t warn you) Lastly, you can split the files into 2GB sizes, while this isn’t necessary, it just makes all the disks much easier to manage and move around. For this step we want to set our disk size (12 GB in this case), I chose not to allocate the disk space right now (the machine has a 300 GB drive and has only 20 GB on it) and Split disk into 2 GB files.

Step 7: Name the disk file
This is actually pretty simple in that you decide what you want to physically call the disk and where to put it. .vmdk is the extension for VMWare virtual disks. After we name the disk we can select the “Finish” button which adds the disk to the virtual machine.

Step 8: Ensure new disk exists
So now we can see that the new disk has been added to the “Virtual Machine Settings” within the selected virtual machine. From here the disk acts just like it would if you added a new disk to a standalone server. So we select the “OK” button to continue.

Step 9: Boot the virtual machine
From here we just start the virtual machine like we would normally, either by selecting the button on the toolbar or selecting the “Start this virtual machine” link.

Step 10: Virtual machine start up
The machine boots normally as it would any other time.

Step 11: Create the Partition
After we’ve logged in and accessed a terminal window as root (or another user with root/sudo privs) we first want to run fdisk on the newly created drive. In Linux the first SCSI drive is sda, the second sdb, the third sdc, etc. since this was the second SCSI drive we added to the system, the device is known as /dev/sdb
The first command we want to run is fdisk /dev/sdb (NOTE: Thanks to everyone that caught my typo here) this utility works very much like the DOS utility of the old days and allows you to create and manage partitions. To create a new partition we enter the command n to create a new partition. This is going to be a primary partition p, and the first partition number 1. Because I want this disk to consume the full 12 GB I specified earlier we start at the first cylinder and end it at the last cylinder. We then want to write the partition table with the new partition we have just created so we enter the command w which writes the new table and exits fdisk.

Step 12: Format the partition
Now that we’ve create the partition, we now want to format the first with the new file system. I’ve decided to use ext3 filesystem for this disk, ext3 provides all the features of the classic ext2 file system plus journaling which helps to prevent disk corruption in the event of an improper shutdown and speeds up the recovery process. For a good overview of Linux standard file systems check out this article: http://linux.org.mt/article/filesystems So, to format the new partition we enter the command mkfs -t ext3 /dev/sdb1. This command makes a new files system with the type t ext3 on the /dev/sdb1 partition, this is the first partition on the sdb disk.
Create new filesystem in the virtual machine
Step 13: Create the mount point
Determine where you want to add the new virtual disk you’ve created. I like to create a partition specifically for all the software I install after the basic Linux install called /software to do that we run mkdir /software, just a simple make directory command. Once that is complete we then want to mount the newly created partition. Because we haven’t added the partition to the /etc/fstab yet we have to mount it manually. To do that we run mount -t ext3 /dev/sdb1 /software. To break down this command we run mount with the ext3 filesystem type, the partition /dev/sdb1 to the directory /software. Pretty simple and straight forward. To check that the partition is properly mounted we run df -k which shows us the mounted partitions and the amount of available space.

Step 14: Open the fstab file
The fstab file holds all of the used disks and partitions, and determines how they are supposed to be used by the operating system. So we edit the file to add the newly created partition

http://www.matttopper.com/images/blog/adding_disk_to_vmware/15.jpg
Step 15: Modify the fstab for the new partition
After we open the fstab file in the previous step we add the following line:
/dev/sdb1 /software ext3 defaults 1 1
The first column is the partition name, the second is the default mount point, the third is the filesystem type. The fourth is the mount options, in this case I used default which mounts the drive rw, suid, dev, exec, auto, nouser and asynchronous. The 5th and 6th options are for the dump and fsck options. If dump is set to 1 the filesystem is marked to be backed up, if you are going to have sensitive material on the drive its a good idea to set it to 1. If fsck is set to greater than 1, then the operating system uses the number to determine in what order fsck should be run during start up. If it is set to 0 it will be ignored such as in the case of a cdrom drive since its a solid state disk. For more information on the fstab file check out this article: http://www.tuxfiles.org/linuxhelp/fstab.html
Lastly, we write and quit the file with the :wq command.

So now that the fstab has been written the drive will be mounted and unmounted when the machine is either started or shutdown. So there you have it, the quick and dirty process for adding a brand new disk to a virtual machine. Until next time…

Thursday, July 3, 2014

To Remove/Delete Nth line from a Big File

To remove 100th line from a file.
sed -e '100d' oracle.log > oracle_new.log

To remove lines between 100-110 from a file.
sed -e '101,111d' oracle.log > oracle_new.log

To view the content of Nth(200) line in a Big File

Method 1:
oracle=>head -200 filename | tail -1



Method 2:
oracle=>sed '199p;200q;d' filename

Thursday, May 22, 2014

Unix Command PRSTAT

http://www.joyent.com/blog/bruning-questions-prstat-1m-output