Sunday 22 November 2015

VPN - Connection Guide For Windows 8

We recommend that you have the latest version of Java on your computer before installing the VPN. You can find out if you have the latest version and download a new version at www.java.com.


USING THE VPN FOR THE FIRST TIME

  1. From the Windows 8 Start screen, open a web browser by clicking on the program icon, or selecting it from the Desktop.
    27208-001.png

  2. Point your browser to https://download.uchicago.edu/vpn/anyconnect-win-3.1.04072-pre-deploy-k9.msi(NOTE: Updated on 10/30/2013 to version 3.1.04072 which is compatible with Windows 8 and 8.1). We highly recommend using Firefox rather than Explorer as your browser.
    27208-002.png

  3. Save the file and double-click to run the install program.
    27208-003a

  4. Click Next on the welcome screen.
    27208-004.png

  5. Select the I accept radio button regarding the End-User License Agreement, then click Next.
    27208-005.png

  6. Click Install to begin the installation.
    27208-006.png

  7. Choose Yes if a dialog box appears asking permission to allow the program in install.
  8. Select Finish to exit the Setup Wizard.
    27208-007.png

  9. Click the lower left corner of the screen to return to the Start screen.
  10. Select the Cisco AnyConnect icon on the Start screen.
    27208-008.png

  11. Enter cvpn.uchicago.edu in the text field, then Connect.
    27208-009.png

  12. Log in with your CNetID and Password, then press OK.
    27208-010.png

  13. Press Accept.
    27208-011.png

  14. The Cisco AnyConnect VPN Client will be connected. To see details of the VPN connection, click the gear icon.
    27208-012.png

  15. To disconnect from the VPN, right-click the Cisco AnyConnect icon and select VPN Disconnect.
    27208-013.png
Subsequent times that you use the VPN:
  1. From the Windows 8 Start screen, select the Cisco AnyConnect Icon.
    27208-008.png

  2. Press Connect.
    27208-009.png

  3. Log in with your CNetID and Password, then press OK.
    27208-010.png

  4. Press Accept.
    27208-011.png

  5. The Cisco AnyConnect icon will display in the notification area (previously known as the system tray).anyconnecticon.png

Saturday 21 November 2015

How to extract Current execution of query

Step 1:Execute the query

column username format 'a10'
column osuser format 'a10'
column module format 'a16'
column program_name format 'a20'
column program format 'a20'
column machine format 'a20'
column action format 'a20'
column sid format '9999'
column serial# format '99999'
column spid format '99999'
set linesize 200
set pagesize 30
select
a.sid,a.serial#,a.username,a.osuser,c.start_time,
b.spid,a.status,a.machine,
a.action,a.module,a.program
from
v$session a, v$process b, v$transaction c,
v$sqlarea s
Where
a.paddr = b.addr
and a.saddr = c.ses_addr
and a.sql_address = s.address (+)
and to_date(c.start_time,'mm/dd/yy hh24:mi:ss') <= sysdate - (15/1440) -- running for 15 minutes
order by c.start_time
/   

Step 2: desc v$session

Step 3:select sid, serial#,SQL_ADDRESS, status,PREV_SQL_ADDR from v$session where sid='xxxx' //(enter the sid value)

Step 4: select sql_text from v$sqltext where address='XXXXXXXX';

Step 5: select piece, sql_text from v$sqltext where address='XXXXXX' order by piece;

Checking Long running queries

This one shows SQL that is currently "ACTIVE":-

select S.USERNAME, s.sid, s.osuser, t.sql_id, sql_text
from v$sqltext_with_newlines t,V$SESSION s
where t.address =s.sql_address
and t.hash_value = s.sql_hash_value
and s.status = 'ACTIVE'
and s.username <> 'SYSTEM'
order by s.sid,t.piece

/


This shows locks. Sometimes things are going slow, but it's because it is blocked waiting for a lock:

select
  object_name, 
  object_type, 
  session_id, 
  type,         -- Type or system/user lock
  lmode,        -- lock mode in which session holds lock
  request, 
  block, 
  ctime         -- Time since current mode was granted
from
  v$locked_object, all_objects, v$lock
where
  v$locked_object.object_id = all_objects.object_id AND
  v$lock.id1 = all_objects.object_id AND
  v$lock.sid = v$locked_object.session_id
order by
  session_id, ctime desc, object_name

/


This is a good one for finding long operations (e.g. full table scans). If it is because of lots of short operations, nothing will show up.

COLUMN percent FORMAT 999.99 

SELECT sid, to_char(start_time,'hh24:mi:ss') stime, 
message,( sofar/totalwork)* 100 percent 
FROM v$session_longops
WHERE sofar/totalwork < 1

/

Wednesday 18 November 2015

vi editor

Introduction
vi  pronounced as ” vee eye ” is a unix editor available on almost all the unix  operating systems , solaris , bsd ,aix , hpux etc.
This document is a quick reference to vi editor and will be of help if your are new to unix , learning unix  or just refreshing your vi knowledge after a few years.
Requirements:
In order to work correctly the vi need  correct terminal type (TERM) setting  .The TERM setting depends on the   type of terminal you have . Commonly used TERM types are vt100 , vt220 and ansi .  In most cases vt100 will  work  fine . In case  vi is not able to understand the TERM you have given, it starts in open mode   giving you a line by line display .
Generally TERM is taken from .profile or  /etc/profile  but can be set at the command line as :
$TERM=vt100
$export TERM
echo $TERM will display the current TERM set.
Create new file or  Open existing file in vi
vi without any file name will open a   new file where you can enter the text and edit but while coming out you will  be asked to enter a valid file name to save the text.  vi with a  file name as argument will  open that file for editing  if the file already exists it opens it  otherwise it creates a new file by the argument.
Example :  $vi  testfile
Creates or opens the existing file called testfile
Modes in vi
vi operates in following  two modes :
i. ) Command Mode : After a file is opened it is opened  in command
mode ,that is , input from the keyboard will be treated as vi commands
and you will not see the words you are typing on the screen .
ii.) Insert Mode: To enter the text you have to put vi in insert  by pressing ‘i’ or ‘a’  after  which you can add the text and whatever is being type will be seen on the  screen. . To switch between these mode Esc key is used .   Esc i
(text mode)  Esc (command mode)
Saving  & Exiting  vi editor
You can exit vi in different ways :
1.) Quit without saving : If you don’t  want to save the work :q  will take you out without saving  your editing in vi.
2.) Write & quit : . Simple :w saves the current file but don’t exit. For save and quit  :wq is  used in vi.
3.) Forced Quite : An ! (Exclamation  sign at the end of  exit commands ( :q! , :wq! )  causes a forced  quit from vi  after ignoring editing (for :q!)  or writing (for :wq!)  all the change

Vi Commands – Reference
Moving Cursor in File
Lefth
Rightl
Upk
Downj
Line
Beginning^ or B
end$
Sentence
Next sentance)
Previous sentance(
Paragraph
Next}
Previous{
file
Go to end of file:$
on chacter forword:w
One word forword:W
go to a line number:line_number
display file info .^g
Inserting and appending text
inserts text to the left of cursori
nserts in the beginning of lineI
appends text to right of cursora
appends to the end of lineA
Adding new line
add a new line below the current lineo
adds a new line above the current line.O
Deleting the text :
deletes text above the textx
deletes text character on right of cursorX
deletes line 2020d
deletes current linedd
delete till end of current line.D
Replacing a character & word
replace the character above the cursor.r
replces characters until Esc is pressed.R
replaces the word from cursor to the end indicated by $ sign .cw
replaces till end of line.C
Substitute
subistutes current charcater.s
substitutes entire line.S
Undo last changes
undo last change.u
undo changes to the current line.U
Copy and pasting lines
copys the current line into buffer.yy
copies 5 lines from the current line.5yy
pastes the current buffer.p
Searching
Searches for the word name in the file:/name
n continues search forward.n
N searches backwardsN
Saving
saves the text does not quit.:w
saves & quit the editor .:wq!
saveZZ
Quit without savingq!
Search & Replaces/<search>/<replace>/g .
Repeating last command.
Recovering a unsaved vi file.
vi -r filename

Crontab

Setting up cron jobs in Unix and Solaris
cron is a unix, solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix , solaris.  Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times.
This document covers following aspects of Unix cron jobs
1. Crontab Restrictions
2. Crontab Commands
3. Crontab file – syntax
4. Crontab Example
5. Crontab Environment
6. Disable Email
7. Generate log file for crontab activity
1. Crontab Restrictions
You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow. If that file does not exist, you can use
crontab if your name does not appear in the file /usr/lib/cron/cron.deny.
If only cron.deny exists and is empty, all users can use crontab. If neither file exists, only the root user can use crontab. The allow/deny files consist of one user name per line.
2. Crontab Commands
export EDITOR=vi ;to specify a editor to open crontab file.
crontab -e    Edit your crontab file, or create one if it doesn’t already exist.
crontab -l      Display your crontab file.
crontab -r      Remove your crontab file.
crontab -v      Display the last time you edited your crontab file. (This option is only available on a few systems.)
3. Crontab file
Crontab syntax :
A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.
*     *     *   *    *        command to be executed
-     -    -   -  -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)
* in the value field above means all legal values as in braces for that column.
The value column can have a * or a list of elements separated by commas. An element is either a number in the ranges shown above or two numbers in the range separated by a hyphen (meaning an inclusive range).
Notes
A. ) Repeat pattern like /2 for every 2 minutes or /10 for every 10 minutes is not supported by all operating systems. If you try to use it and crontab complains it is probably not supported.
B.) The specification of days can be made in two fields: month day and weekday. If both are specified in an entry, they are cumulative meaning both of the entries will get executed .
4. Crontab Example
A line in crontab file like below removes the tmp files from /home/someuser/tmp each day at 6:30 PM.
30     18     *     *     *         rm /home/someuser/tmp/*
Changing the parameter values as below will cause this command to run at different time schedule below :
minhourday/monthmonthday/weekExecution time
30011,6,12*— 00:30 Hrs  on 1st of Jan, June & Dec.
020*101-5–8.00 PM every weekday (Mon-Fri) only in Oct.
001,10,15**— midnight on 1st ,10th & 15th of month
5,10010*1— At 12.05,12.10 every Monday & on 10th of every month
:
Note : If you inadvertently enter the crontab command with no argument(s), do not attempt to get out with Control-d. This removes all entries in your crontab file. Instead, exit with Control-c.
5. Crontab Environment
cron invokes the command from the user’s HOME directory with the shell, (/usr/bin/sh).
cron supplies a default environment for every shell, defining:
HOME=user’s-home-directory
LOGNAME=user’s-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh
Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry.
6. Disable Email
By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command At the end of the cron job line .
>/dev/null 2>&1
7. Generate log file
To collect the cron execution execution log in a file :
30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log