Saturday, June 1, 2013

Unlocking a locked table/object in Oracle

Oracle put locks on tables when any DML/DDL operations performing. Generally, some internal processes accesses the data and locks the table. So if you want to forcibly unlock the table you can follow the below steps.
  1. Get the Object ID from the dba_objects table. All of your tables will be assigned a unique id and stores a reference in dba_objects table. This table is useful in finding the basic information about each object stored on your Oracle instance, and not only tables.
    Here is the SQL statement to get the object id of the locked table.

    SELECT object_id FROM dba_objects WHERE object_name='YOUR TABLE NAME';
  2. Get the SID for the corresponding Object ID we have obtained from the step 1. You can get the SID from v$lock table. Here is the query.

    SELECT sid FROM v$lock WHERE id1=OBJECT ID FROM STEP1
  3. Note down all sid values from step 2. Get the sid, serial number pairs from the v$session table using the SID obtained from the step 2. Here is the query.

    SELECT sid, serial# from v$session where sid in (COMMA SEPARATED LIST OF SIDs FROM STEP2.)
  4. Note down the information from step 3. Now we have to kill the sessions that locked the object we require. Below is the query to do that.

    ALTER SYSTEM KILL SESSION (SID,SERIAL#) pair values from step 3
    e.g. ALTER SYSTEM KILL SESSION '231','23454'

Tuesday, May 29, 2012

Installing mate-desktop in ubuntu


Monday, April 16, 2012

Creating and mounting ISO or Image file in Linux

1. Using DD (Disk Dump) to create image
i. from cd drive
-> dd if=/dev/cdrom of=cd.iso

ii. from dvd drive
-> dd if=/dev/dvd of=dvd.iso

iii. from external drive
-> dd if=/dev/scd0 of=cd.iso

whatever you choose from above first ensure the drive file is the same mentioned above in /dev folder ie. cdrom0, cdrom1, dvd0, dvd1, scd0, scd1.....

2. Now mounting the image file using mount command:
-> mount -o loop IMAGE_FILE_NAME.iso -t iso9660 /home/USER_NAME/DESTINATION_FOLDER

Example:
-> mount -o loop image.iso -t iso9660 /home/raj/loop

Note: Please ensure the loop drive is supported by the kernel.

3. Done

Script For Samba Sharing in Linux


1. Create a text file containing following codes and name the text file as "smb.conf.raj": 

[global] 
workgroup = WORKGROUP 
server string = %h server (Samba, Ubuntu) 
dns proxy = no 
log file = /var/log/samba/log.%m 
max log size = 1000 
syslog = 0 
panic action = /usr/share/samba/panic-action %d 
encrypt passwords = true 
passdb backend = tdbsam 
obey pam restrictions = yes 
unix password sync = yes 
passwd program = /usr/bin/passwd %u 
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . 
pam password change = yes 
map to guest = bad user 
usershare allow guests = yes 

[root] 
path = /home/USER_NAME/SHARED_FOLDER
available = yes 
valid users = USER_NAME
read only = yes 
browsable = yes 
public = yes 
writable = yes 
guest ok = no

2. Execute the following command:
[ROOT ACCESS REQUIRED]
testparm smb.conf.raj > smb.conf 
rm /etc/samba/smb.conf 
cp smb.conf /etc/samba 
restart smbd

3. DONE

TESTED ON UBUNTU & MANDRIVA

Installing PDF Printer in Linux



1. if CUPS not installed (MOSTLY CUPS IS INSTALLED ON MANDRIVA MACHINE, SO YOU MAY SKIP THIS STEP.. 
-> urpmi cups 

2. copy attached ppd file to "/usr/share/cups/model" using konsole (root) 
-> su 
-> cp ADIST5.PPD /usr/share/cups/model 

3. restart cups 
-> /etc/init.d/cups restart 

4. create pdf "OUTPUT_FOLDER" in home directory  
-> mkdir pdfoutput 

5. change permission of "OUTPUT_FOLDER" using root access  
-> chmod 777 -R pdfoutput 

6. lpadmin -p -E -v pdf: -m ADIST5.PPD  
-> lpadmin -p PDFPrinter -E -v pdf:/home/USER_NAME/pdfoutput -m ADIST5.PPD 

7. restart cups 
-> /etc/init.d/cups restart 

8. DONE.. ALL PDF WILL BE AT /home/USER_NAME/pdfoutput

Installing JDK in Linux Manually

1. Download the tar or bin file of JDK of any version you want from JDK download site.

2. Copy the downloaded tar or bin to home folder.
For the sake of example i am using name of the downloaded file as jdk-6u31-linux-i586.bin and path of my home folder as "/home/raj"

2. Extract the tar file using:
-> tar xvf jdk_filename
or
if bin file downloaded then execute using:
-> chmod a+x jdk_filename
-> ./jdk_filename

Example:
-> cd ~
-> chmod a+x jdk-6u31-linux-i586.bin
-> ./jdk-6u31-linux-i586.bin

3. use update-alternatives command: (ROOT ACCESS IS REQUIRED)
-> su
-> update-alternatives --install "/usr/bin/javac" "javac" "/home/raj/jdk1.6.0_31/bin/javac" 1
-> update-alternatives --install "/usr/bin/java" "java" "/home/raj/jdk1.6.0_31/bin/java" 1
-> update-alternatives --install "/usr/bin/javaws" "javaws" "/home/raj/jdk1.6.0_31/jre/javaws/javaws" 1

4. select version of JDK to use: (USE THIS ONLY IF MULTIPLE JDK ARE INSTALLED IN THE SYSTEM)
[WITH ROOT ACCESS]

-> update-alternatives --config javac
[SELECT AND PRESS ENTER]

-> update-alternatives --config java
[SELECT AND PRESS ENTER]

-> update-alternatives --config javaws
[SELECT AND PRESS ENTER]

5. if you want to install multiple version then do the following else skip this step:
repeat the steps from 1 and 2 then
-> update-alternatives --install "/usr/bin/java" "java" "/home/raj/j2sdk1.4.2_19/bin/java" 2
-> update-alternatives --install "/usr/bin/javac" "javac" "/home/raj/j2sdk1.4.2_19/bin/javac" 2
-> update-alternatives --install "/usr/bin/javaws" "javaws" "/home/raj/j2sdk1.4.2_19/jre/javaws/javaws" 2
and the follow step 4.

6. done