Learning What s Happening on Your System


Learning What's Happening on Your System

A few Unix commands can provide you with answers to questions about your system: "Who is logged in?" "What are they doing?" "What jobs are taking up all my CPU cycles?" "How long has my system been up?"

  • uptime tells you how long it has been since you last restarted and what your workload is.

  • who tells you who is logged in to your system, where they're logged in from, and when they logged in.

  • w tells you who is online and what they are doing.

  • last tells you who has logged into your computer.

  • ps and top tell you what jobs are running on your computer.

This section explains how to use each of these commands and shows simulated output so you know what you might expect to learn.

Tip

  • You can learn more about these commands by viewing their man pages. In the Terminal window, type man uptime, man who, man w, man last, man ps, or man top and press to view the command's man pages.


To learn your workload & how long since you last restarted

In the Terminal window, type uptime and press .

The results might look something like what you see in Code 1. You see the current time, the time since the last restart, or boot (7 days, 17 hours, and 48 minutes), and load averages of how many active jobs were in the queue during the last 1, 5, and 15 minutes. The load shown here is high because my system is running the SETI@home screensaver. Normally these numbers will be less than 1.

Code 1. The results of the uptime command.


To learn who is on your system

In the Terminal window, type who and press .

The results might look something like what you see in Code 2. In this example, I'm logged in remotely twice from the machine with the IP address 192.168.2.1, once as root and once as myself. I'm also logged in from a remote location (isaac.exploratorium.edu) and at the system console.

Code 2. The results of the who command.


To learn who is online & what they are doing

In the Terminal window, type w and press .

The command's output looks something like Code 3. The w command first does an uptime command. Then it gives you information about each user, when they logged in, and how long it's been since they've done anything.

Code 3. The results of the w command.


To learn who has logged in to your machine recently

In the Terminal window, type last and press .

The output should look similar to Code 4. The last command spews out a list of everyone who has logged in to your machine, when and from where they logged in, how long they stayed, and when you last shut down or restarted your machine.

Code 4. The results of the last command.


Or

In the Terminal window, type last user (where user is the user name of a specific user) and press .

If you specify a user, last will show only the logins for that user.

To learn what jobs are running

In the Terminal window, type ps and press .

The ps command tells you what you are running at the instant you run the command.

Or

In the Terminal window, type top and press .

The top command gives you a running commentary of the top ten jobs. If you expand the size of the Terminal window, top shows more than the top ten jobs. Press to quit top.

Tip

  • You may find Activity Monitor (in the Utilities folder) a more useful utility to see the processes that are running. Activity Monitor is covered in Chapter 22.




Visual QuickStart Guide. Mac OS X 10. 4 Tiger
Mac Os X 10.4 Tiger (Visual Quickstart Guides)
ISBN: 0321423372
EAN: 2147483647
Year: 2003
Pages: 301
Authors: Maria Langer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net