Cover | Table of Contents
$TERM is xterm-color when running under Terminal (it's set to xterm under xterm by default).
xterm &
xterm -e -fg green -bg black -e pine -name pine -title pine &
$TERM), which is set as xterm-color by default. The other choices for the environment variable TERM are ansi, dtterm, rxvt, vt52, vt100, vt102, and xterm. Among other things, the default setting for TERM allows you to take advantage of the support for color output in ls (via the -G option) and color syntax highlighting in the vim
editor. Although color is enabled by the default xterm-color, dtterm provides some additional capabilities. For example, the visual bell in vi works with dtterm, but not with xterm-color.
|
Pane
|
Description
|
|---|---|
|
Shell
|
Displays the shell used by the Terminal and lets you choose whether to close the Terminal window when the shell exits.
|
|
Processes
|
Displays the processes running under the frontmost window. You can also control whether Terminal will warn you if you try to close the window while you are running a program. You can disable this by choosing Never under "Prompt before closing window." You can also supply a list of commands that should be ignored, so if you're running a program (such as |
http://developer.apple.com/networking/bonjour), formerly known as Rendezvous, is a networking technology that allows Bonjour-enabled devices on a local network to automatically discover each other. As are many Mac OS X applications, Terminal is Bonjour-enabled. For example, you can select File → Connect to Server to make an SSH connection to any other Mac OS X system on the LAN, provided it allows such connections. The other Macs on the LAN are identified by their computer names, as specified in their Sharing System Preferences.http://www.zeroconf.org), which was initiated by the Internet Engineering Task Force (http://www.ietf.org) in 1999.http://images.apple.com/macosx/pdf/MacOSX_Bonjour_TB.pdf.http://iterm.sourceforge.net), developed by Fabian and Ujwal S. Sathyam, is a particularly attractive one. Although Mac OS X's Terminal is rich with useful features, iTerm offers some interesting extras that make it worthy of consideration. We won't cover iTerm in great detail, but will touch on a few of its more attractive aspects.TERM is vt100, but this can be changed either on the fly with a bash shell command, such as TERM=xterm-color, in the Configure menu, or, if you want a global change, in iTerm's Preferences dialog. Like the Terminal application, iTerm is also Bonjour-enabled.
open .
open ~/Public
open /Applications
open -a Xcode
open -a Xcode data.xml
open *.c
open -e *.c
open -a BBEdit filename
$ sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit
$ ls -l Sample.textClipping
-rw-r--r-- 1 bjepson bjepson 0 Feb 27 11:05 Sample.textClipping
$ ls -l Sample.textClipping/rsrc
-rw-r--r-- 1 bjepson bjepson 1770 Feb 27 11:05 Sample.textClipping/rsrc
$ file Sample.textClipping/rsrc
Sample.textClipping/rsrc: ms-windows icon resource
$ strings Sample.textClipping/rsrc
KApple's HFS+ filesystem has been stashing metadata away since its
introduction in Mac OS X 8.1. Resource forks are generally invisible
portionsof files used for stashing additional information (the primary
portion of the...
I) that makes them invisible to the Finder.http://netatalk.sourceforge.net) is best known as a suite for introducing Unix servers to AppleTalk networks. However, it has a daemon, afpd, which can share files over TCP/IP using the native Apple sharing protocol, AFP (Apple Filing Protocol)
. Early versions (and often the versions that are bundled with many Linux distributions) only supported an earlier version of AFP, and were limited in the length of file names. The most recent version of Netatalk works great with Mac OS X, with the exception of its non-standard Apple Double implementation, described later in this section.http://www.cis.upenn.edu/~bcpierce/unison) is a powerful file synchronizer that lets you keep Windows, Mac OS X, Linux, and Unix files in sync. It does so by maintaining a replica on each side of the synchronization, comparing the state of the filesystem against the last-known replica, and making intelligent decisions about which files are the most recent. In cases where it can't figure something out (perhaps you changed the file in both places), it prompts you to tell it what to do.|
File or directory
|
Description
|
|---|---|
|
.DS_Store
|
Contains Finder settings, such as icon location and window size. The file will appear in any directory that you've viewed with the Finder.
|
|
.Spotlight-V100/
|
Contains metadata used by Spotlight. For more information, see Chapter 2.
|
|
.Trashes/
|
Contains files that have been dragged to the Trash. On a boot volume, such files are stored in ~/.Trash. On a non-boot volume, these files are in /.Trashes/uid/.
|
|
.vol/
|
Maps HFS+ file IDs to files. If you know a file's ID, you can open it using /.vol/id.
|
|
Applications/
|
Holds all your Mac OS X applications. Its Utilities subdirectory includes lots of useful things, such as the Terminal, Console, and the Activity Monitor.
|
sudo /usr/sbin/nvram boot-args="-v"
sudo /usr/sbin/nvram boot-args=
sudo /usr/sbin/nvram boot-args="-v"
sudo /usr/sbin/nvram boot-args=
http://www.mysql.com).
15 3 * * * root periodic daily
30 4 * * 6 root periodic weekly
30 5 1 * * root periodic monthly
StartCalendar tag to specify when it is to be run. For example, here is the com.apple.periodic-daily.plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.
com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.apple.periodic-daily</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/periodic</string>
<string>daily</string>
</array>
<key>LowPriorityIO</key>
<true/>
<key>Nice</key>
<integer>1</integer>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>15</integer>
</dict>
</dict>
</plist>
/etc/periodic/daily/100.clean-logs
/etc/periodic/daily/500.daily
/etc/periodic/monthly/500.monthly
/etc/periodic/weekly/500.weekly
gethostent( ). The C library connects to lookupd, a thin shim that is the doorway to the DirectoryService
daemon. The DirectoryService daemon consults the available plug-ins until it finds the one that can answer the directory query.getpw* family of functions. However, those functions are not ideal for working with systems that support multiple directories (flat files, NetInfo, LDAP, etc.). Also, in the interest of thwarting dictionary attacks against password files
, many operating systems have stopped returning encrypted passwords
through those APIs. Many Unix and Linux systems simply return an "x" when you invoke a function like getpwnam( ). However, those systems can return an encrypted password through functions like getspnam( ), which consult shadow password entries and can generally be invoked by the root user only. Example 5-1 shows the typical usage of such an API, where the user enters her plaintext password, and the program encrypts it and then compares it against the encrypted password stored in the system.
/*
* getpw* no longer returns a crypted password.
*
* Compile with gcc checkpass.c -o checkpass
* Run with: ./checkpass
*/
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
const char *user = NULL;
struct passwd *pwd;
/* Set the user name if it was supplied on the command
* line. Bail out if we don't end up with a user name.
*/
if (argc == 2)
user = argv[1];
if(!user)
{
fprintf(stderr, "Usage: checkpass <username>\n");
exit(1);
}
/* Fetch the password entry. */
if (pwd = getpwnam(user))
{
char *password = (char *) getpass("Enter your password: ");
/* Encrypt the password using the encrypted password as salt.
* See crypt(3) for complete details.
*/
char *crypted = (char *) crypt(password, pwd->pw_passwd);
/* Are the two encrypted passwords identical? */
if (strcmp(pwd->pw_passwd, crypted) == 0)
printf("Success.\n");
else
{
printf("Bad password: %s != %s\n", pwd->pw_passwd, crypted);
return 1;
}
}
else
{
fprintf(stderr, "Could not find password for %s.\n", user);
return 1;
}
return 0;
}
|
Tool
|
Description
|
|---|---|
|
dscl
|
Provides a command-line interface to Directory Services.
|
|
nicl
|
Provides a command-line interface to NetInfo.
|
|
nidump
|
Extracts flat file format data (such as /etc/passwd) from NetInfo.
|
|
nifind
|
Finds a NetInfo directory.
|
|
nigrep
|
Performs a regular expression search on NetInfo.
|
|
niload
|
Loads flat file format data (such as /etc/passwd) into NetInfo.
|
|
nireport
|
Prints tables from NetInfo.
|
|
niutil
|
NetInfo utility for manipulating the database.
|