Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

MAC OS X UNIX Toolbox: 1000+ Commands for the Mac OS X
MAC OS X UNIX Toolbox: 1000+ Commands for the Mac OS X
MAC OS X UNIX Toolbox: 1000+ Commands for the Mac OS X
Ebook465 pages3 hours

MAC OS X UNIX Toolbox: 1000+ Commands for the Mac OS X

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Explore a ton of powerful Mac OS X UNIX commands

This handy, compact guide teaches you to use Mac OS X UNIX systems as the experts do: from the command line. Try out more than 1,000 commands to find and get software, monitor system health and security, and access network resources. Apply the skills you learn from this book to troubleshoot networks, lock down security, and uncover almost anything you care to know about your Mac OS X system.

Expand your Mac OS X UNIX expertise in these and other areas:

  • Using the shell

  • Finding online software

  • Working with files

  • Playing with music and images

  • Administering file systems

  • Backing up data

  • Checking and managing running processes

  • Accessing network resources

  • Handling remote system administration

  • Locking down security

LanguageEnglish
PublisherWiley
Release dateJun 29, 2009
ISBN9780470549407
MAC OS X UNIX Toolbox: 1000+ Commands for the Mac OS X

Read more from Christopher Negus

Related to MAC OS X UNIX Toolbox

Related ebooks

Operating Systems For You

View More

Related articles

Reviews for MAC OS X UNIX Toolbox

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    MAC OS X UNIX Toolbox - Christopher Negus

    Introduction

    Mac OS X UNIX Toolbox is loosely based on the BSD UNIX Toolbox written by Chris Negus and François Caen. When I was asked by Wiley to extend what they had done into the world of Mac OS X, I heartily agreed to do so, partly because the original was such an excellent resource.

    From the very beginning, I decided to keep to the spirit and structure of the original title as much as I could. Thankfully, about 90 percent of what you experience UNIX-WISE on Mac OS X is the same as on BSD or Linux environments, so I was able, for the most part, to abide by this agreement. In some cases, though, I had to nip and tuck a few sections; in others, I had to add a bit back in.

    At the end of the day, what you hold is a handbook with more than 1,000 specific command lines to help you become a Mac OS X power user. Whether you are a systems administrator or desktop user, the book will show you commands to create file systems, troubleshoot networks, lock down security, and dig out almost anything you care to know about your Mac OS X system.

    Of course, Mac OS X being what it is, not everything in this book is about the command line (although most of it is). In some cases, I show you not only how to do things on the venerated command line, but also how to take advantage of the Mac OS X GUI. Either way, you learn how to leverage UNIX to do your job.

    Who Should Read This Book

    This book is for anyone who wants to access the power of a Mac OS X system as a systems administrator or user. You may be a free and open-source software (FOSS) enthusiast, a UNIX professional, or possibly a computer professional who is increasingly finding the Windows systems in your data center supplanted by BSD, Linux, and Mac OS X systems.

    The bottom line is that you want to find quick and efficient ways of getting Mac OS X systems working at peak performance. These may be a few desktop systems at work, a file and print server at your school, or a home web server that you’re setting up mostly for fun.

    In the best case, you should already have some experience with BSD, Linux, or other UNIX-like systems. However, if you are a computer professional with skills managing other types of operating systems, such as Windows, you should be able to leverage your knowledge and use the specific commands covered in the book.

    What This Book Covers

    I assume that you’re new to Mac OS X, but that you’re coming to that platform from some other UNIX platform, such as Linux or BSD. In other words, I assume that you know something about the command line, but don’t yet know the Mac OS X Way. I will show you that way, pointing out how to get to the shell, how to run commands, and how things (most of which you may take for granted) have changed from one flavor of UNIX (i.e., the one you’re used to) to Mac OS X’s flavor of UNIX. The book will then supplement that knowledge with information you need to do the following activities:

    Get software—Mac OS X can be extended using various package managers. Using these package managers, you can install both binary packages and source code. I will introduce you to Fink, which you’ll use to find, download, install, and manage software from the command line.

    Access applications—Find what’s available from the Mac OS X distribution.

    Use the shell—Find neat techniques and tips for using the shell.

    Play with GUI tools—Use the command-line options to run products such as iTunes, TextEdit, and Safari.

    Work with files—Use, manipulate, convert, and secure a wide range of file types in Mac OS X.

    Administer file systems—Access, format, partition, and monitor your file storage hardware (hard disks, CD/DVD drives, floppy disks, USB flash drives, and so on). Then create, format, and check the file systems that exist on those hardware devices.

    Back up and restore data—Use simple commands to gather, archive, and compress your files into efficient backup archives. Then store those archives locally or on remote computers.

    Work with processes—List running processes in a variety of ways, such as by CPU use, processor use, or process ID. Then change running processes to have them run in the background or foreground. Send signals to processes to have them reread configuration files, stop and resume processing, or stop completely (abort).

    Manage the system—Run commands to check system resources, such as memory usage, run levels, and more.

    Monitor networks—Bring wired and wireless network connections up and down. Check routing, DNS, and host information. Keep an eye on network traffic.

    Get network resources—Connect to UNIX and Windows remote file systems using FTP, NFS, and Samba facilities.

    Do remote administration—Access and administer other computers using remote login (ssh, telnet, and so on) and screen. Learn about remote administration interfaces, such as SWAT and CUPS.

    Lock down security—Set up firewalls and system logging to secure your Mac OS X systems.

    Get reference information—Use the appendixes at the end of this book to get more information about the shell (such as metacharacters and shell variables) and personal configuration files.

    If we’ve done it right, it will be easier to use this book than to Google for the command lines or GUI tools you need.

    After you’ve mastered many of the features described in this book, you’ll have gained the following advantages:

    Hundreds of commands—By compressing a lot of information into a small space, you will have access to hundreds of useful commands, in over 1,000 command lines, in a handy form to carry with you.

    Transferable knowledge—Most of the same commands and options you use in Mac OS X systems will work exactly the same way on other UNIX-like systems. Different UNIX systems, however, offer different graphical administration tools; and even within a particular distribution, graphical tools change more often than commands do.

    Quick problem solving—By the time others have started up a desktop and launched a graphical administration tool, you will have already run a half dozen commands and solved the problem.

    Enduring value—Many of the commands described in this book were used in early UNIX systems, so you are gaining tools that reflect the experience of thousands of computer experts for more than 30 years.

    Because the full documentation for commands used in Mac OS X systems consists of thousands of man pages, info text, and help messages, you will surely want to reach beyond the pages of this book from time to time. Luckily, Mac OS X and other UNIX systems include helpful information installed on the system itself. Chapter 1 contains descriptions of how to access this information, which is probably already installed, or can be easily installed, on your system.

    How This Book Is Structured

    This book is neither a pure reference book (with alphabetically listed components) nor a guide (with step-by-step procedures for doing tasks). Instead, the book is organized by topic, and includes the most useful commands and options you will likely work with.

    Chapter 1 provides you with a basic understanding of what Mac OS X is and how it relates to the operating systems that are derived from BSD, such as FreeBSD, NetBSD, and OpenBSD. Then it describes some of the vast resources available to support your experience with this book, such as man pages, info material, and help text. Chapter 2 provides a quick overview of the Mac OS X environment and how you can set it up to get easy access to UNIX tools. It also includes a quick introduction to Fink, a package manager that will enable you to install additional tools mentioned in this book.

    Chapters 3, 4, 5, and 6 describe commands that a regular user may find useful on Mac OS X systems. Chapter 3 describes tools for using the shell, Chapter 4 covers commands for working with files, and Chapter 5 describes how to manipulate text. Chapter 6 walks you through more advanced shell scripting and introduces AppleScripting.

    Starting with Chapter 7, we get into topics relating to system administration. Creating and checking file systems is covered in Chapter 7, while commands for doing data backups are described in Chapter 8. Chapter 9 explains how to manipulate running processes, and Chapter 10 describes administrative tools for managing basic components, such as hardware modules, CPU use, and memory use.

    Chapter 11 begins the chapters devoted to managing network resources by describing how to set up and work with network interfaces. Chapter 12 covers text-based commands for file transfer, file sharing, chats, and e-mail. Tools for doing remote system administration are included in Chapter 13.

    Chapter 14 covers how to lock down security, using features such as firewalls and logging. Following that are six appendixes that provide additional reference information for text editing, shell features (metacharacters and variables), personal configuration files, AppleScript commands, a quick Perl primer, and some interesting packages available via Fink that you might want to explore.

    What You Need to Use This Book

    This is definitely not a book you curl up with on your next vacation. Nor is it meant to entertain you. Throughout, I fully expect you to be sitting in front of a Mac OS X system, scratching your head with one hand and holding this book in the other, looking for a solution.

    In other words, the book is meant to be a companion as you work on a problem related to Mac OS X. You’ll probably be working on a desktop system at home or work, but a fair number of you will be working on a file, web, or print server running Mac OS X.

    All the commands in this book have been tested against a 64-bit x86 system running Mac OS X 10.5 (Leopard). Specifically, I’m running a MacBook Pro. My technical editor checked everything on a MacBook Pro (running Mac OS X 10.5) primarily, but he also used a MacBook (running Mac OS X 10.5) and (once) a PowerMac (running Mac OS X 10.4).

    I assume that you’re running Leopard, but don’t despair if you’re on Tiger, as most of what is covered here also pertains to that earlier release. In addition, please note that nearly every command available from the shell has been around for a long time (some dating back more than 30 years to the original UNIX days), and most will work exactly as described here on NetBSD, OpenBSD, and other derivative systems, regardless of CPU architecture.

    Furthermore, many of the commands described in this book will also work on other UNIX and Linux systems. Because this book focuses on Mac OS X, descriptions will differ from other UNIX-like systems most prominently in the areas of packaging, installation, and GUI administration tools.

    Conventions

    To help you get the most from the text and keep track of what’s happening, we’ve used a number of conventions throughout the book. In particular, we have created styles for showing commands that allow us to fit as many command lines as possible in the book.

    With command examples, computer output (shell prompts and messages) is shown in regular monospace font, computer input (the stuff you type) is shown in bold monospace font, and a short description (if included) appears in italics. Here is an example:

    002

    To save space, output is sometimes truncated (or skipped altogether). Three dots (…) are sometimes used to indicate that additional output was cut. If a command is particularly long, backslashes will appear at the end of each line to indicate that input is continuing to the next line, as shown here:

    003

    In the preceding example, you can type the backslashes to have all that information included in the single command; or you can simply put all the information on a single line (excluding the backslashes). Note that command prompts are shown in one of two ways:

    004

    As noted, when a dollar sign prompt ($) appears, any user can run the command. With a pound sign prompt (#), you probably need to be the root user in order for the command to work.

    Notes and warnings appear as follows:

    Warnings and notes are offset and placed in italic like this.

    As for styles in the text:

    • We highlight new terms and important words with italic when we introduce them.

    • We show keyboard strokes like this: 005 N or Ctrl+N.

    • We show filenames, URLs, and code within the text like so: persistence. properties.

    One final technique used in this book is to highlight text that describes what an upcoming command is meant to do. For example, we may say something like "use the following command to display the contents of a file." We’ve styled descriptions in this way to provide you with quick visual cues, so you can easily scan the page for that command you just knew had to be there.

    1

    Starting with UNIX on Mac OS X

    IN THIS CHAPTER

    Finding Mac OS X

    resources

    Quick and powerful

    commands

    Handy references to many

    useful utilities

    Working as Mac OS X

    gurus do

    Are you an old hand at the Mac? Do you use the underlying UNIX just once in a while? Many times a day? Never heard of it? Regardless of your skill level, a book that presents efficient ways to use, check, fix, secure, and enhance UNIX on Mac OS X can be an invaluable resource.

    Mac OS X UNIX Toolbox is that resource.

    Mac OS X UNIX Toolbox is aimed primarily at Mac OS X power users and systems administrators. To give you what you need, we tell you how to quickly locate and get software, monitor the health and security of your systems, and access network resources. In short, we cut to the most efficient ways of using UNIX systems.

    Our goal with Mac OS X UNIX Toolbox is to pack a lot of useful information for using UNIX tools and systems into a small package that you can carry around with you. To that end, we describe the following:

    Commands—Tons of command-line examples to use BSD systems in helpful and clever ways

    GUI tools—Quick pointers to graphical administration tools to configure your system

    Software packages—Short procedures to find and download tons of applications

    Online resources—Listings of the best locations to find BSD forums, mailing lists, IRC channels, and other online resources

    Local documentation—Tools for gathering more information from man pages, doc directories, help commands, and other resources on your BSD system

    Because you’re not a beginner with Mac OS X, you won’t see a lot of screenshots of windows, icons, and menus. What you will see, however, is the quickest path to getting the information you need in order to use UNIX on Mac OS X to its fullest extent.

    If this sounds useful to you, please read on.

    About FreeBSD, NetBSD, and OpenBSD

    Mac OS X is a modern operating system that combines the power of a UNIX-based operating system and the simplicity and elegance of the Macintosh UI. Its open-source core, called Darwin, is a direct descendant of various BSD projects. It is based in part on BSD 4.4 Lite, but many libraries and utilities are from FreeBSD and NetBSD. Because of this history, it’s useful to delve into the history of BSD.

    In the early 1970s, AT&T released the UNIX source code to several colleges and universities, allowing them to begin changing, adapting, and improving that code as they pleased. That decision has led to the development of every major free and open-source software operating system today, not the least of which are the systems based on the Berkeley Software Distribution (BSD).

    The twisty history of BSD is easy to Google, if you care to learn the details. For our purposes, here are the highlights:

    • BSD began as a set of software add-ons to AT&T’s Sixth Edition UNIX.

    • Over the years, BSD developers split off on their own development path, rewriting software with the intention of replacing all AT&T copyrighted code.

    • In the early 1990s, AT&T’s UNIX System Laboratories sued BSD developers (Berkeley Software Design, Inc.) for copyright infringement.

    • Although the lawsuit was eventually settled (with only a few files needing to be changed from the BSD code), the Linux operating system was able to become a leader of open-source software development while questions surrounding how free BSD was were being threshed out.

    • In 1995, the final version of BSD from Berkeley was released under the name 4.4BSD-Lite, release 2. Today’s BSD operating systems, including FreeBSD, NetBSD, and OpenBSD, are all based to some extent on 4.4BSD-Lite.

    Operating systems derived from BSD have a well-earned reputation for stability and security. BSD was developed at a time when computing resources (disk space, network bandwidth, and memory) were meager by today’s standards, so BSD systems were operated by efficient commands, instead of the bloated applications and dumbed-down graphical interfaces often seen today.

    Because of the nature of BSD systems, people running those systems required a high level of expertise. Even when simplified graphical user interfaces based on the X Window System began to appear, to effectively operate a BSD system you still needed to know about such things as

    Enjoying the preview?
    Page 1 of 1