05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

302<br />

CHAPTER 18 INTRODUCING DARWIN AND THE SHELL<br />

who<br />

And all our yesterdays have lighted fools<br />

The way to dusty death. Out, out, brief candle!<br />

Life's but a walking shadow, a poor player<br />

That struts and frets his hour upon the stage<br />

And then is heard no more: it is a tale<br />

Told by an idiot, full of sound and fury,<br />

Signifying nothing.<br />

The who command tells you who else is logged in to the computer. Traditionally, this would just<br />

be you, since most personal computers would only allow one person to be logged in at a time<br />

(and this is how we still tend to use them). However, if you’ve turned on the Remote Login<br />

option in the Sharing control pane, it’s possible for multiple users to actually be using one <strong>Mac</strong><br />

<strong>OS</strong> system at a time. who also has a related command, whoami, which will also tell you your username<br />

if you ever forget. (By the way, your Darwin username is the “short” username you pick<br />

when you create your account.)<br />

To see these in action on your system isn’t always that exciting:<br />

ps<br />

<strong>Leopard</strong>:~ scott$ who<br />

scott console May 20 19:39<br />

scott ttyp1 May 20 20:17<br />

<strong>Leopard</strong>:~ scott$ whoami<br />

scott<br />

NOTE who may be considered dangerous by many systems administrators who feel it’s a<br />

potential security breach to disclose too much information about the system or its users; for<br />

this reason, on many of today’s servers, systems are in place to keep you from finding out<br />

who’s really online at any time. Of course, the real cool (or if you’re a systems administrator,<br />

real bad) command that is similar to who is finger. Traditionally, finger would allow you to find<br />

out all sorts of personal information about any user, not only those on your local machine, but<br />

you could actually “finger” anyone on any UNIX-type machine (and most other multiuser systems<br />

of the day). The finger command still exists on some computers and is even installed on<br />

your <strong>Mac</strong> (go ahead try it)—however, it’s unlikely that you’ll be able to find many machines on<br />

your network or on the Internet that will allow you to finger them or any of their users (for<br />

aforementioned security and even privacy fears). By default, <strong>Leopard</strong> will not allow any remote<br />

machine to finger you.<br />

ps allows you to view what processes are running at any given time on your system. By default,<br />

it shows limited information about all the services running from the terminal you are using (i.e.,<br />

only the current Darwin process that you’ve started from your current terminal session). Until<br />

you really start digging into the power of Darwin, ps will likely just return your shell as your<br />

only process:<br />

<strong>Leopard</strong>:~ scott$ ps<br />

PID TTY TIME CMD<br />

310 p1 0:00.12 -bash<br />

The important pieces of information here are the PID (process ID) and the COMMAND. However,<br />

with a few options, ps can give you lots of information about every command running on your<br />

system. The most common options are -a, -u, and -x (so common, in fact, that you can issue<br />

them without the -). This will most likely give you a long scrolling list of processes:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!