Learning What's Happening on Your SystemA 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?"
This section explains how to use each of these commands and shows simulated output so you know what you might expect to learn. Tip
To learn your workload & how long since you last restartedIn 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 systemIn 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 doingIn 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 recentlyIn 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 runningIn 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
|