<<

. 32
( 69 .)



>>


This type of command can be used in a script to automate posting.
To learn more about curl and how you can use it in scripts, you can
read the man page or download a tutorial available online.

TYPE THIS: RESULTS:
[ferro:˜] curl -O http://curl.planetmirror.com/
The httpscripting.html tutorial downloads.
docs/httpscripting.html




‹ Type the URL of a Web ‹ Type echo “n "URL> " and
DOWNLOAD A BINARY FILE CREATE A SCRIPT FOR
DOWNLOADING WEB
page containing a press Return, then type set
„ Type curl followed by a PAGES WITH CURL
compressed tar file and press URL = $< and press Return
space.
„ Start the Pico editor to
Return. twice.
¤ Type -O followed by a create a file named copy_url.
› Type cd ˜/src; curl “O
Note: On a dial-up connection, this
space.
¤ Type #!/bin/tcsh and press
may take awhile to download. http://$URL.
Return twice.
– The specified binary file ˇ Save your file, and exit
downloads. Pico.
151
UNIX FOR MAC



ENABLE REMOTE ACCESS
TO YOUR COMPUTER
more information). Alternatively, you can configure the service

Y
ou can allow others to log on to your computer or
to start whenever a request arrives. In this latter case, another
make it possible for you to log on to your Mac OS X
process listens for requests on behalf of the service and starts
system from another system.While Mac OS X systems
it as needed. The decision as to which method to use
make it possible for you to log on to remote systems,
depends on the particular service. Web servers, such as
browse Web sites, and download files, they do not allow
Apache's httpd, are better run all of the time. This provides
others to log on to your system or access files on your
better Web performance. Services such as ftp and telnet
system. If you want to allow this type of access, you have to
that are used only now and then are better run on an as-
enable it by modifying your system's configuration.
needed basis. You configure as-needed access through the
/etc/inetd.conf file.
There are two basic ways to provide a network service on
your Mac OS X system. You can start the service ” for
To modify system configuration information in Mac OS X,
example, start up a Web server ” by typing the name of the
you need to be a privileged user. The sudo command,
server process on the command line. These services are
which allows you to run a command as root, works well for
designed to run in the background and continue running until
this purpose if you are allowed access.
you shut your system down or kill them. See Chapter 7 for



ENABLE REMOTE ACCESS TO YOUR COMPUTER




– Your cursor is positioned
„ Type sudo vi ¤ Type your password if ‹ Type /#ftp and press
/etc/inetd.conf and prompted. Return. at the beginning of the line
press Return. detailing the ftp service.




152
10
WORK WITH INTERNET COMMANDS


Whenever you use the sudo command, you
Files responsible for the configuration of a
are prompted to enter your password to
Unix system, Mac OS X included, are always
ensure that you are the user entrusted with
set up so that only the root is able to make
sudo privileges and not someone who has
changes. This is important to system security
just walked up to your unattended Terminal
because it ensures that only trusted users can
window. If you enter another command
modify the configuration of a system. As a
shortly afterwards, you do not have to enter
system manager, you have two choices when
your password again. The sudo command
you need to change a configuration file. You
includes a timer that allows you to work for
can switch users to the root account with the
five minutes before asking for your password
su command; su - sets you up as root with
again.
root's environment. Alternatively, you can
use the sudo command to run the command
You must be set up as a system administrator
that only root can run otherwise.
or listed in the /etc/sudoers file to use sudo.


RESULT:
TYPE THIS:
[ferro:˜] sudo date
On the first call to sudo, the system
[ferro:˜] sudo date
asks you to enter your password.
On the second call, it does not.




– The inetd process reads
› Type x to remove the # ˇ Type :wq and press Á Type ps -aux | grep inetd
character below your cursor. Return. and press Return. the /etc/inetd.conf file,
enabling the ftp server.
‡ Type sudo kill -HUP
° Type ftp localhost and
followed by the process ID
for inetd and press Return. press Return.
– The ftp service that you
just enabled responds to your
request.
153
UNIX FOR MAC




INTRODUCTION TO SYSTEM
ADMINISTRATION
Y
ou can effectively administer a Mac OS X system by
learning some basic commands. Unix administration
is a complex job, but Mac OS X provides many tools
for making the job manageable.



SYSTEM ADMINISTRATOR


The basic responsibilities of any Unix system system crashes or if someone mistakenly deletes the
administrator are to keep the system running smoothly wrong files from their account. System administrators
and to ensure that important data and configuration also manage accounts for other users. They establish an
files are preserved. To administer a Mac OS X system, account for each user and ensure that the user can use
you need to understand the fundamentals of file the tools and applications they need.
systems, know how to set up user accounts, recognize
Users in large companies can often rely on help from a
when the system is having problems, and be prepared
user support team. If you are using Mac OS X at home
to manage applications and disk space.
or in your small business, you are probably responsible
System administrators routinely back up the systems for managing the system yourself; in effect, you are your
they manage. This allows them to restore files if the own system administrator.




ACCESS PRIVILEGES


Critical to the role of a system administrator is the belonging to any user, modify any configuration file,
concept of privilege. In order to install applications and and shut the system down or reboot it from the
modify configuration files, you need to have access to command line.
the root or superuser account or to be a privileged user.
While the privileges assigned to the root user are most
A normal user on a Unix system can only work on files
significant when a Mac OS X system is managed by one
in their home directory.
person and used by many, use of the root account is
The root user has virtually unrestricted access to the important even on systems where root and user are one
system. As a result, the root user can modify files and the same person.




154
11
SYSTEM ADMINISTRATION COMMANDS

MANAGE MAC OS X

Mac OS X is not only different from Mac OS 9 and earlier You also need to know the basic file system layout ”
versions of Mac OS, it is also different from other versions where the system stores files ” and you must also know
of Unix. For example, the root user on a Mac OS X system whether you should pay attention to the files you find in
is disabled by default. This means that you cannot simply the /etc directory ” the normal configuration directory
adopt the root identity and run commands that you are on Unix systems.
not allowed to run as a normal user. Instead, you need to
The table below contains a list of some of the most
either preface these commands with the word sudo, or
important Mac OS X commands for system administrators.
you need to activate the root account.

COMMAND MOST COMMON USE COMMAND MOST COMMON USE
Find related commands. Present the manual page for a system
apropos man
command.
Change the owner and, optionally, Attach a file system to the system.
chown mount
the group of a file.
Compress a file. Look at routing tables, network
compress netstat
connections, or network statistics.
Edit a cron file. Create a new file system.
crontab -e newfs
List cron jobs. Display network information from
crontab -l nidump
NetInfo.
Display free and used disk space. Print tables from NetInfo.
df nireport
Display disk space usage. Look up DNS information.
du nslookup
Dump a file system to a Change the password for a user.
dump passwd
backup device or a file.
Reboot the system without a Test the connection to a system
fastboot ping
disk check. by asking for a reply.
Examine or change DOS Display information on running
fdisk ps
partitioning information. processes.
Determine the type of a file. Shut down and reboot the system.
file reboot
Find files using particular criteria. Shut down a system gracefully.
find shutdown
Check the integrity of a file system. shutdown -r now Shut down and reboot a system
fsck
immediately.
Unzip a file zipped with gzip. Display the strings in a binary file.
gunzip strings
Compress a file. Create a file archive or read from one.
gzip tar
Shut down a system immediately. Display statistics on the most demanding
halt top
processes.
Display or change network interface Update the last changed date on a file
ifconfig touch
information. or create an empty file.
Send a signal to a process, Unmount a file system which is currently
kill umount
possibly terminating it. mounted.
Create a symbolic or hard link to a file. Uncompress a file compressed with the
ln uncompress
compress command.
Display a printer queue.
lpq


155
UNIX FOR MAC



<<

. 32
( 69 .)



>>