Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 
 

Logged in User Information

Linux Tips by Burleson Consulting

To get a quick count of how many users are on the system we can use the uptime command.

$ uptime
22:41:39 up  2:33,  2 users,  load average: 0.00, 0.00, 0.00

We also see some other useful information here, like the current system time, the amount of time since last startup and the load average.  The load average here is exactly the same as we saw in the top command we looked at earlier.

For more detailed information about each logged in user, the w command can be used.  The w command also shows the same information uptime did.

$ w
22:42:14 up  2:34,  2 users,  load average: 0.00, 0.00, 0.00
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
terry    :0        20:10   ?xdm?   5:24   1.49s gnome-session
terry    pts/1     22:22    0.00s  0.24s  0.04s /usr/sbin/sshd

Here we see the user name, what terminal they are connected through (TTY), when they logged in (LOGIN@), how long since they last did something (IDLE), the amount of CPU time used by all this session's processes (JCPU), the amount used by the current process (PCPU) and what the user is currently executing (WHAT).

who is another command which can be used to show who is logged on the system.  It provides a bit less detail than w.

$ who
terry    :0           Oct  4 20:10        
terry    pts/1        Oct  4 22:22 (172.16.10.102)


The who command does tell us where the user has connected from which may be useful.  It may show an IP address as above or a hostname.

To also see the PID of each logged on user, the -u option can be added to the who command.

$ who ?u
terry    :0           Oct  4 20:10   ?         20237        
terry    pts/1        Oct  4 22:22   .          4176 (172.16.10.102)


The process ID for the user's main session is now shown as the second to last column.

Who Am I?

Sometimes it is useful to check who we are currently logged in as.  To do that we use the whoami command.

$ whoami
terry

As you can see, the whoami command just returns the username of who we're logged in as.  This becomes invaluable when we start switching users like we'll see in the next section.

Switch to a Different User

It is often necessary to switch from one user identity to another. For instance, the administrator may want to switch from a regular user login to the root logon in order to set up a new directory structure. In this example, the user?s regular user login ID is terry. Instead of logging off as terry and then logging on as root, the su (substitute user) command facilitates an easy switch.

$ whoami
terry
$ su
Password: rootpassword
# whoami
root
# exit
$ whoami
terry

Here we use the whoami command to show that we're currently logged in as terry, and then we use the su command to temporarily become root.  When we're done working as root we type exit to exit root's shell and go back to being terry.  You may also notice the prompt changed from a $ to a #.  This may not always be the case, but it's a good hint that if your prompt is a # you are probably running as root.

As with other commands, the su command has a number of available options, but one of the most useful ones is the - option.  This option essentially logs the user into a new shell as the specified user with the specified user?s profile.  Another helpful option is the -c option which allows the user that is logged in to run a single command as the specified user. Without using the ? option, the current profile is maintained when switching users and the environment variables, such as path for locating executables, remain unchanged.

Unless you are logged in as root, the system will ask for a password when an attempt to switch users is made.  As root you can su at will and assume the identity of any user on the system.  This is another reason you don't want just anybody having the root password.


This is an excerpt from "Easy Linux Commands" by Linux guru Jon Emmons.  You can purchase it for only $19.95 (30%-off) at this link.


 

 

��  
 
 
 
 

 
 
 

 
 
Oracle performance tuning software 
 
oracle dba poster
Oracle Linux poster
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright ? 1996 -  2014

All rights reserved by Burleson

Oracle ? is the registered trademark of Oracle Corporation.