O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
BSD Hacks
By Dru Lavigne
May 2004
More Info

How do these hacks stand up? Comment on a hack from the book by choosing the associated "Discuss" link below. You can also view the code from any of the hacks by clicking on the "Listing" or "Code" links. A number of hacks have been selected to be featured online in their entirety; you may view those hacks by clicking on the hack titles that are linked.

Jump to: Customizing the User Environment  | Dealing with Files and Filesystems  | The Boot and Login Environments  | Backing Up  | Networking Hacks  | Securing the System  | Going Beyond the Basics  | Keeping Up-to-Date  | Grokking BSD

Customizing the User Environment

HACK
#1

Get the Most Out of the Default Shell
Become a speed daemon at the command line.
[Discuss (0) | Link to this hack]

HACK
#2

Useful tcsh Shell Configuration File Options
Make the shell a friendly place to work in
[Discuss (0) | Link to this hack]

HACK
#3

Create Shell Bindings
Train your shell to run a command for you whenever you press a mapped key
[Discuss (0) | Link to this hack]

HACK
#4

Use Terminal and X Bindings
Take advantage of your terminal's capabilities
[Discuss (0) | Link to this hack]

HACK
#5

Use the Mouse at a Terminal
Use your mouse to copy and paste at a terminal
[Discuss (0) | Link to this hack]

HACK
#6

Get Your Daily Dose of Trivia
Brighten your day with some terminal eye candy
[Discuss (0) | Link to this hack]

HACK
#7

Lock the Screen
Secure your unattended terminal from prying eyes
[Discuss (0) | Link to this hack]

HACK
#8

Create a Trash Directory
Save "deleted" files until you're really ready to send them to the bit bucket
The Code
[Discuss (0) | Link to this hack]

HACK
#9

Customize User Configurations
Now that you know how to set up a useful environment for yourself, it's time to share the wealth
[Discuss (0) | Link to this hack]

HACK
#10

Maintain Your Environment on Multiple Systems
The sign of a true Unix guru is the ability to perform a task quickly when confronted with an unfamiliar shell, keyboard, terminal, window manager, or operating system
[Discuss (0) | Link to this hack]

HACK
#11

Use an Interactive Shell
Save and share an entire login session
[Discuss (0) | Link to this hack]

HACK
#12

Use Multiple Screens on One Terminal

[Discuss (0) | Link to this hack]

Dealing with Files and Filesystems

HACK
#13

Find Things
Finding fles in Unix can be an exercise in frustration for a novice user. Here's how to soften the learning curve.
[Discuss (0) | Link to this hack]

HACK
#14

Get the Most Out of grep
You may not know where its odd name originated, but you can't argue the usefulness of grep
[Discuss (0) | Link to this hack]

HACK
#15

Manipulate Files with sed
If you've ever had to change the formatting of a file, you know that it can be a time-consuming process
[Discuss (0) | Link to this hack]

HACK
#16

Format Text at the Command Line
Combine basic Unix tools to become a formatting expert
[Discuss (0) | Link to this hack]

HACK
#17

Delimiter Dilemma
Deal with double quotation marks in delimited files
The Code
[Discuss (0) | Link to this hack]

HACK
#18

DOS Floppy Manipulation
Bring simplicity back to using floppies
[Discuss (0) | Link to this hack]

HACK
#19

Access Windows Shares Without a Server
Share files between Windows and FreeBSD with a minimum of fuss
[Discuss (0) | Link to this hack]

HACK
#20

Deal with Disk Hogs
Fortunately, you no longer have to be a script guru or a find wizard just to keep up with what is happening on your disks
[Discuss (0) | Link to this hack]

HACK
#21

Manage Temporary Files and Swap Space
Add more temporary or swap space without repartitioning
[Discuss (0) | Link to this hack]

HACK
#22

Recreate a Directory Structure Using mtree
Prevent or recover from rm disasters
[Discuss (0) | Link to this hack]

The Boot and Login Environments

HACK
#23

Ghosting Systems

[Discuss (0) | Link to this hack]

HACK
#24

Customize the Default Boot Menu
Configure a splash screen.
[Discuss (0) | Link to this hack]

HACK
#25

Protect the Boot Process
Thwart unauthorized physical access to a system
[Discuss (0) | Link to this hack]

HACK
#26

Run a Headless System
For those times when you want to run a system "headless.
[Discuss (0) | Link to this hack]

HACK
#27

Log a Headless Server Remotely
More on headless systems, but this time from the NetBSD perspective
[Discuss (0) | Link to this hack]

HACK
#28

Remove the Terminal Login Banner
Give users the information you want them to receive when they log in
[Discuss (0) | Link to this hack]

HACK
#29

Protecting Passwords With Blowfish Hashes
Take these simple steps to thwart password crackers
[Discuss (0) | Link to this hack]

HACK
#30

Monitor Password Policy Compliance
When to use a password cracker utility
[Discuss (0) | Link to this hack]

HACK
#31

Create an Effective, Reusable Password Policy
Traditionally, it has been difficult for a Unix administrator to create and enforce a reusable password policy. Fortunately, PAM addresses this
[Discuss (0) | Link to this hack]

HACK
#32

Automate Memorable Password Generation
Make it easier for your users to choose good passwords
[Discuss (0) | Link to this hack]

HACK
#33

Use One Time Passwords
Sometimes even a complex password may not meet your security needs
[Discuss (0) | Link to this hack]

Backing Up

HACK
#34

Restrict Logins

[Discuss (0) | Link to this hack]

HACK
#35

Back Up FreeBSD with SMBFS
A good backup can save the day when things go wrong. A bad—or missing—backup can ruin the whole week.
[Discuss (0) | Link to this hack]

HACK
#36

Create Portable POSIX Archives
Create portable tar archives with pax
[Discuss (0) | Link to this hack]

HACK
#37

Interactive Copy
When cp alone doesn't quite meet your copy needs
[Discuss (0) | Link to this hack]

HACK
#38

Secure Backups Over a Network

[Discuss (0) | Link to this hack]

HACK
#39

Automate Remote Backups
Make remote backups automatic and effortless
[Discuss (0) | Link to this hack]

HACK
#40

Automate Data Dumps for PostgreSQL Databases
Building your own backup utility doesn't have to be scary
The Code
[Discuss (1) | Link to this hack]

Networking Hacks

HACK
#41

Perform Client-Server Cross-Platform Backups with Bacula
Don't let the campy name fool you. Bacula is a powerful, flexible, open source backup program.
[Discuss (0) | Link to this hack]

HACK
#42

See Console Messages Over a Remote Login
View a server's console messages remotely
[Discuss (0) | Link to this hack]

HACK
#43

Spoof a MAC Address
Even good guys can use secret identities
[Discuss (0) | Link to this hack]

HACK
#44

Use Multiple Wireless NIC Configurations
Take the pain out of configuring your laptop's wireless interface
The Code
[Discuss (0) | Link to this hack]

HACK
#45

Survive Catastrophic Internet Loss
Set up your network to recover from a full Internet loss
[Discuss (0) | Link to this hack]

HACK
#46

Humanize tcpdump Output
Make friends with
[Discuss (0) | Link to this hack]

HACK
#47

Understand DNS Records and Tools
Demystify DNS records
[Discuss (0) | Link to this hack]

HACK
#48

Send and Receive Email Without a Mail Client
Learn to speak SMTP and POP3
[Discuss (0) | Link to this hack]

HACK
#49

Why Do I Need sendmail?

[Discuss (0) | Link to this hack]

HACK
#50

Hold Email for Later Delivery
Control when sendmail uses an intermittent Internet connection
[Discuss (0) | Link to this hack]

HACK
#51

Get the Most Out of FTP
Get the most out of stock ftp with macros and scripts
[Discuss (0) | Link to this hack]

HACK
#52

Distributed Command Execution
Use tentakel for parallel, distributed command execution
[Discuss (0) | Link to this hack]

Securing the System

HACK
#53

Interactive Remote Administration

[Discuss (0) | Link to this hack]

HACK
#54

Strip the Kernel
Don't be shy. A kernel stripped down to the bare essentials is a happy kernel.
[Discuss (0) | Link to this hack]

HACK
#55

FreeBSD Access Control Lists
Unix permissions are flexible and can solve almost any access control problem, but what about the ones they can't?
[Discuss (0) | Link to this hack]

HACK
#56

Protect Files with Flags
Ever feel limited when tightening up Unix permissions? Really, there's only so much you can do with , , , , and
[Discuss (0) | Link to this hack]

HACK
#57

Tighten Security with Mandatory Access Control
Increase the security of your systems with MAC paranoia
[Discuss (0) | Link to this hack]

HACK
#58

Use mtree as a Built-in Tripwire
Why configure a third-party file integrity checker when you already have mtree?
[Discuss (0) | Link to this hack]

HACK
#59

Intrusion Detection with Snort, ACID, MySQL, and FreeBSD
How the alert administrator catches the worm
[Discuss (0) | Link to this hack]

HACK
#60

Encrypt Your Hard Disk
Keep your secrets secret by keeping everything secret
[Discuss (0) | Link to this hack]

HACK
#61

Sudo Gotchas
Be aware of these limitations when configuring sudo
[Discuss (0) | Link to this hack]

HACK
#62

sudoscript
sudo can help enforce strict security policies, but what about situations in which you don't want to restrict what commands your users run?
[Discuss (0) | Link to this hack]

HACK
#63

Restrict an SSH server
Control your ssh scripts by placing them in a jail
[Discuss (0) | Link to this hack]

HACK
#64

Script IP Filter Rulesets
One firewall ruleset isn't always enough
[Discuss (0) | Link to this hack]

HACK
#65

Secure a Wireless Network Using PF
Protect your private wireless network from unauthorized use
[Discuss (0) | Link to this hack]

HACK
#66

Automatically Generate Firewall Rules
Easily protect any FreeBSD workstation with a fully configured firewall
[Discuss (0) | Link to this hack]

HACK
#67

Automate Security Patches
Keep up-to-date with security patches
[Discuss (0) | Link to this hack]

Going Beyond the Basics

HACK
#68

Scan a Network of Windows Computers for Viruses

[Discuss (0) | Link to this hack]

HACK
#69

Tune FreeBSD for Different Applications
Know how to tune and what to tune on your FreeBSD system
[Discuss (0) | Link to this hack]

HACK
#70

Traffic Shaping on FreeBSD
Allocate bandwidth for crucial services
[Discuss (0) | Link to this hack]

HACK
#71

Create an Emergency Repair Kit
The Boy Scout and system administrator motto: "Be prepared!
[Discuss (0) | Link to this hack]

HACK
#72

Use the FreeBSD Recovery Process
Learn how to use your emergency repair kit before the emergency
[Discuss (0) | Link to this hack]

HACK
#73

Use the GNU Debugger to Analyze a Buffer Overflow
You don't have to be a programmer to use a debugger
[Discuss (0) | Link to this hack]

HACK
#74

Consolidate Web Server Logs
Automate log processing on a web farm
[Discuss (0) | Link to this hack]

HACK
#75

Script User Interaction
Use an expect script to help users generate GPG keys
[Discuss (0) | Link to this hack]

Keeping Up-to-Date

HACK
#76

Create a Trade Show Demo

[Discuss (0) | Link to this hack]

HACK
#77

Automated Install
If you're responsible for installing multiple systems, hopefully you've discovered the art of automating installs.
[Discuss (0) | Link to this hack]

HACK
#78

FreeBSD from Scratch
For those who prefer to wipe their disks clean before they upgrade their systems
[Discuss (0) | Link to this hack]

HACK
#79

Safely Merge Changes to /etc
Use a three-way merge to deal with upgraded configuration files
[Discuss (0) | Link to this hack]

HACK
#80

Automate Updates
FreeBSD provides many tools to make software upgrades as painless as possible. In fact, the entire process is fully scriptable. Simply choose the pieces you want and how up-to-date you want to be
[Discuss (0) | Link to this hack]

HACK
#81

Create a Package Repository
Combine the advantages of compiling from source and installing packages
[Discuss (0) | Link to this hack]

HACK
#82

Build a Port Without the Ports Tree
While the ports tree is one of the most useful FreeBSD directory structures, you may have systems where it's not appropriate to maintain the entire ports structure
[Discuss (0) | Link to this hack]

HACK
#83

Keep Ports Up-to-Date with CTM
Keep your ports up-to-date without using cvsup
[Discuss (0) | Link to this hack]

HACK
#84

Navigate the Ports System
Use built-in commands to keep abreast of the FreeBSD ports collection
[Discuss (0) | Link to this hack]

HACK
#85

Downgrade a Port
It doesn't happen often, but occasionally portupgrade will upgrade a port to a newer version that doesn't sit well with your system
[Discuss (0) | Link to this hack]

HACK
#86

Create Your Own Startup Scripts
Ensure your favorite installed applications start at boot time
[Discuss (0) | Link to this hack]

HACK
#87

Automate NetBSD Package Builds
Use a sandbox to build applications that play nicely within your network
[Discuss (0) | Link to this hack]

Grokking BSD

HACK
#88

Easily Install Unix Applications on Mac OS X

[Discuss (0) | Link to this hack]

HACK
#89

How'd He Know That?
Make the most of your available resources.
[Discuss (0) | Link to this hack]

HACK
#90

Create Your Own Manpages
As a Unix administrator, the one word of sage advice you can give to any user that is guaranteed to solve any problem is RTFM
[Discuss (0) | Link to this hack]

HACK
#91

Get the Most Out of Manpages
Now that you know how to create your own manpages, you'll want to know how to get the most out of your manpage viewing
[Discuss (0) | Link to this hack]

HACK
#92

Apply, Understand, and Create Patches
Sometimes only the little differences matter
[Discuss (0) | Link to this hack]

HACK
#93

Display Hardware Information
If you're new to FreeBSD, you may be wondering where to find information about your system's hardware and the resources it uses
[Discuss (0) | Link to this hack]

HACK
#94

Determine Who Is on the System
As a system administrator, it pays to know what's happening on your systems
[Discuss (0) | Link to this hack]

HACK
#95

Spelling Bee
For those who edit their text at the command line
[Discuss (0) | Link to this hack]

HACK
#96

Leave on Time
Use your terminal's built-in timers and schedulers
[Discuss (0) | Link to this hack]

HACK
#97

Run Native Java Applications
Until recently, running Java applications on FreeBSD meant using the Linux compatibility mode
[Discuss (0) | Link to this hack]

HACK
#98

Rotate Your Signature
End your email communications with a short witticism
[Discuss (0) | Link to this hack]

HACK
#99

Useful One-Liners

[Discuss (0) | Link to this hack]

HACK
#100

Fun with X
Use the utilities that come with the core X distribution.
[Discuss (0) | Link to this hack]


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.