View all users currently logged in Oracle Database on Linux server

Problem

You are experiencing performance problems with your  Oracle database server (Linux or Solaris). To help diagnose the issues, you first want to view all users currently logged on to the box.

Solution

Use the who command to display the users logged on to a box:

$ who

The output consists of four columns: users logged on, terminal name, time they logged on, and location where they logged on. Here’s a typical listing of the who command:

ptownshend    pts/1        Jun 15 14:17 (vpn-229-150-36-51.com)

rdaltrey      pts/2        Aug 10 22:11 (122.120.44.181)
jentwistle    pts/3        Aug 16 03:14 (111.155.23.114)
kmoon         pts/4        Sep 4  01:23  (10.6.77.121)
kjones        pts/6        Dec 4  06:66  (101.120.23.171)

You can also use the who command with the am i option to display your current user information:

$ who am i

oracle   pts/2        Aug 4 15:30 (vpn-109-150-32-93.brdstn.com)

 Tip  You can also use whoami or the id -un to display information about your current user. Contrast this with the who am i command, which always shows which user you initially used to log on to a server. For example, if you su to a different user, whoami displays your current user status, whereas who am i shows which user you originally logged on to the server as.


 

How It Works

The who command is important for listing a snapshot of users logged on to the server. An alternative to the who command is the w utility. This simply titled but powerful tool is an extension to the who command. The output of the w command is like a combination of the listings from the who, uptime, and ps -a commands. This example uses the w command to eavesdrop on who is logged on to the system and what they are doing:

$ w

17:59:54 up 9 days,  5:37,  4 users,  load average: 0.00, 0.00, 0.00


USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU    WHAT


enehcd   pts/1    vpn-128-156-33-6  12:32    5:46   0.12s  0.12s  -bash

evork    pts/2    vpn-129-156-33-6  15:22   34:14   0.01s  0.01s -chmod

aznoga   pts/3    vpn-129-156-32-6  17:22   55:24   0.03s  0.01s -sleep

wroot    pts/4    vpn-129-150-150-  17:48   0.00s   0.02s  0.00s      w

The first line of the w output is similar to that produced by the uptime command; it shows current time, how long the system has been up, number of users, and system load averages. After the header line, it displays users logged on, from where and what time, how long they’ve been idle, current job CPU (JCPU), foreground process CPU (PCPU), and what command the user is running.

To specifically look at one user, specify the process name as an option. The following command looks at all oracle accounts logged on to the server:

$ w oracle

The following output indicates that there are two active oracle users on the box:

14:14:58 up 130 days, 21:52,  2 users,  load average: 0.00, 0.00, 0.00


USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU   WHAT

oracle   pts/1    63-231-82-100.hl   13:10   0.00s  0.03s  0.00s  w oracle
oracle   pts/2    63-231-82-100.hl   14:14   6.00s  0.01s  0.01s  -bash

If a user has logged on twice to a server (as in the previous output), you can use the tty command to identify a session. Log on to one of the oracle sessions; here is the tty command and its output:

$ tty

/dev/pts/1

You can also use the finger command to display information about users logged on to a server. If you don’t provide the finger command with a username, it will display all users on a system:

$ finger

Login      Name        Tty        Idle  Login  Time   Office     Office Phone

oracle                 pts/0            Jun 20 13:29  (br-ea-fw-nat.surg.com)
oracle                 pts/1         2  Jun 20 13:29  (br-ea-fw-nat.surg.com)

The pinky command is a lightweight version of the finger command. If no users are specified as a parameter, all users logged on will display:

$ pinky

Login      Name        TTY      Idle   When          Where

oracle                 pts/0           Jun 20 13:29  br-ea-fw-nat.surg.com
oracle                 pts/1    00:03  Jun 20 13:29  br-ea-fw-nat.surg.com

 

 

Вас заинтересует / Intresting for you:

Oracle Database and Security: ...
Oracle Database and Security: ... 885 views sepia Mon, 26 Nov 2018, 12:20:58
Oracle Database and Instance d...
Oracle Database and Instance d... 514 views Masha Thu, 21 Jun 2018, 18:23:39
Restore Oracle Database 12c fr...
Restore Oracle Database 12c fr... 1188 views Stepan Ushakov Tue, 05 Jun 2018, 15:08:17
Recovering from Undo Tablespac...
Recovering from Undo Tablespac... 485 views Aida Thu, 26 Jul 2018, 08:00:38

Comments on View all users currently logged in Oracle Database on Linux server

Be the first to comment
Please login to comment