05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The jobs command gives us a list of all of our background tasks and tells us their state (in<br />

this case our only task is running).<br />

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

find / -name "motd" >found 2>found_err<br />

The fg command will bring forward the first running task (which for now is our only task).<br />

Since the command is running in the foreground, we can no longer use the terminal unless we<br />

pause the process. We can do this using the Ctrl+Z key combo.<br />

^Z<br />

[1]+ Stopped find / -name "motd" >found 2>found_err<br />

When we use Ctrl+Z, we are giving the message that our task has stopped. We can now<br />

resume this task in the background using bg.<br />

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

[1]+ find / -name "motd" >found 2>found_err &<br />

While this task runs, let’s start another background task.<br />

<strong>Leopard</strong>:~ scott$ (sleep 30; echo "done")&<br />

[2] 359<br />

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

[1]- Running find / -name "motd" >found 2>found_err &<br />

[2]+ Running ( sleep 30; echo "done" ) &<br />

Now we have two jobs running in the background, our find command is still chugging<br />

along, and we have our new command (which will wait, or sleep, 30 seconds, and then run the<br />

echo "done" command. Notice that each job has been giving a number. Our find command is [1]<br />

and our sleep command is [2]. To pull our sleep command into the foreground, we must specify<br />

that we want job 2:<br />

<strong>Leopard</strong>:~ scott$ fg 2<br />

( sleep 30; echo "done" )<br />

done<br />

Eventually, the sleep command will complete and echo “done” to the terminal. At this<br />

point, we can continue to use our terminal, and eventually we will get a message that our find<br />

command has completed:<br />

[1]+ Exit 1 find / -name "motd" >found 2>found_err<br />

<strong>Leopard</strong>:~ scott$ cat found<br />

/private/etc/motd<br />

Working As Root<br />

CHAPTER 18 INTRODUCING DARWIN AND THE SHELL 309<br />

In Darwin, the root user is synonymous with the administrator, superuser, or all-knowing, alldoing,<br />

grand poobah. Working as root is sort of like splitting the atom: great potential for good,<br />

great potential for total destruction . . . in the case of root, that which gets destroyed can vary<br />

from an important file to all of your data and the <strong>OS</strong> itself. Traditionally, root has no boundaries<br />

and no restrictions, and can override all the security safeguards on the system. As such, you<br />

should never use it. (Sometimes, though, if it’s your personal computer, and you really want to<br />

do certain things, you may have to).

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

Saved successfully!

Ooh no, something went wrong!