• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. Unix Security & Utilities > 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 into 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 onto 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 chown, man who, man w, man last, man ps, or man top and press to view the command's man pages.


To learn how long since you last restarted & your workload

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 my 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 are they 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. (In Unix, you normally would also see what program the users are running, except this feature doesn't seem to work right now in Mac OS X.)

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.

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.

Code 4. The results of the last command.


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 Process Viewer (in the Utilities folder) a more useful utility to see the processes that are running. Process Viewer is covered in Chapter 10.


  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint