Slashdot Mirror


BSD Hacks

GMan00 writes "A flurry of BSD UNIX-related (Berkeley Software Distribution) books have hit the bookstores during the recent past, and more are on the way. From books specific to Secure Architectures with OpenBSD in April 2004 and the reissue of The Design and Implementation of the BSD Operating System for FreeBSD 5.x (expected in August 2004), to Michael Lucas' series of BSD Books from NoStarch Press, print documentation is certainly available for those interested in learning about the free, open source UNIX system which powers operations such as Yahoo! portal and Sendmail.org website, Verio and Pair hosting, not to mention web server survey site Netcraft. Dru Lavigne's BSD Hacks (O'Reilly and Associates, May 2004), is the latest book in these releases, and is an enormously useful resource for system administrators and end-users alike." Read on for the rest of George's review. BSD Hacks author Dru Lavigne pages 427 publisher O'Reilly & Associates rating 10 reviewer George ISBN 0596006799 summary A great array of hacks you can perform on your BSD box, many applicable to all the BSDs, including FreeBSD, NetBSD, OpenBSD and Darwin/OS X.

Dru writes the BSD Basics column on O'Reilly & Associates' OnLamp. Her clarity and fluid style are perfect for those looking to understand aspects of the BSD operating systems. I have had some email communications with Dru about various New York City *BSD User Group-related activities, and managed to speak with her several times at BSDCan this past May.

Like most computer nerds, Dru has a sense of humor. Unlike most, however, she's actually funny.

BSD Hacks is the first book that is almost solely focused on hacks for sysadmins, without boring you with the details for basic operating system installation and configuration that has been so well documented elsewhere. BSD Hacks is not just for sysadmins, though. Intermediate and advanced BSD users will also find the book an excellent tool. For those who find difficulty in BSD installs and other fundamentals, on the other hand, it's best to start with the FreeBSD Handbook, the NetBSD Guide or the OpenBSD FAQ.

There's lots of good hacks buried in the various BSD books, around the internet in different HOWTOs and tutorials. But BSD hacking is the sole purpose of BSD Hacks; there's no need to browse through install screens and overviews of TCP/IP before getting to the heart of the matter.

With 100 listed hacks, multiplied by an impressive level of detailed angles for each, Dru provides an array that demands the placement of this book right in your server room, not in a pile of "must-read-at-some-distant-point-in-the-future" texts.

The majority of hacks are applicable to all the BSDs, including Darwin and OS X, although some are specific to one BSD or another.

This review obviously can't list every hack, although you would be smart to sit and work through the book yourself over a weekend or two. But it is possible to provide a good flavor of BSD Hacks in brief. O'Reilly and Associates does give a good glimpse on their Sample Hacks page, but let's do a quick work through ourselves.

The first chapter is called "Customizing the User Environment," and is probably best for end-users looking to go beyond their first steps. But it does include some useful hacks, such as "Use an Interactive Shell" that certainly fit well into the arsenal of any sysadmin, not to mention Hack #12 "Use Multiple Screens on One Terminal."

The second chapter, "Dealing with Files and Filesystems" also contains gems for both end-users and sysadmins. The use of mtree, which maps a directory hierarchy, is mentioned as a tool for recovery. Later on in chapter 6, Dru details its use for making a hacked data integrity checker, thus filling the role often played by products such as Tripwire.

Another great tool Dru covers in the second chapter is g4u, a free ghosting program that gives you the ability to perform quick restores over ftp. Ghosting a drive image is an incredibly useful tool, whether it's about replicating servers or doing a quick reinstall and configuration when a server fails in an emergency.

Chapter 3 is entitled "Boot and Login Environments." It gives some hacks that aren't just for basic system administration, but also some useful security ones including changing your /etc/passwd file to Blowfish encryption and utilizing OPIE for one-time passwords, which is built into FreeBSD.

"Backup Up" is the focus of Chapter 4. It includes some very creative methods of dealing with maintaining that necessity, and also includes an excellent primer on Bacula, which is increasingly gaining prominence as a cross-platform backup system.

Chapter 5 covers "Network Hacks," and continues on educating a sysadmin. Included in this chapter is the tcpdump program, a vital tool for watching traffic flowing by your network interfaces.

There's a strong security focus in Chapter 6, entitled "Securing the System." While security hacks are sprinkled generously throughout the book, this chapter works with firewalling with IPF and PF, in addition to covering SSH and Snort. It also includes the earlier mentioned 'intrusion detection-lite' approach with mtree.

Chapter 7, "Going Beyond the Basics" explores scripting, analyzing dreaded buffer overflows and more. Dru also includes a bit on "Creating a Trade Show Demo," not something you'd expect documented in print anywhere, but nevertheless quite useful for anyone working for the BSDs at a conference.

Dru continues with "Keeping Up-to-Date" in Chapter 8, which includes useful details on upgrading and downgrading your installed ports.

The final chapter is "Grokking BSD." "Grok," as Dru comments, refers to the science fiction writer Heinlein's Martian phrase for having a "thorough understanding." Dru covers creating your own manual pages, dealing with custom patches, playing with dictionaries and more.

Certainly there are no walls between each chapter, as many of the hacks could be shifted around. All the more reason to work your way through the book from beginning to end.

One useful addition for this book could have been somehow denoting which of the BSDs (in some cases, it's all of them) to which each listed hack can be applied. Certainly not all are available to Darwin and Apple's OS X. And certainly there's no point in making the OpenBSD /etc/passwd file encrypted in Blowfish, since that is its default.

While many of the hacks are found somewhere in the manual pages, on some useful website, buried in another book or in the minds of some developer somewhere, they're not necessarily in the annals of official documentation. But there's no single book or site that provides the depth and breadth that Dru provides. She managed to tap into the thoughts of dozens of developers and sysadmins around the world, greatly enhancing the variety of hacks in this book.

As a side note, the scope of BSD Hacks isn't limited to just the BSD family. Many of these are likely applicable to Linux and the other UNIX systems. But with recent, impressive increases in the BSD install base, there's a good chance that you can access a BSD box somewhere.

Whether you're a sysadmin managing hundreds of servers, or a power user ready to go beyond the obvious, BSD Hacks belongs next to your CRT.

You can purchase BSD Hacks from bn.com. Slashdot welcomes readers' book reviews. To see your own review here, carefully read the book review guidelines, then visit the submission page.

24 of 122 comments (clear)

  1. Linux by Anonymous Coward · · Score: -1, Troll

    ...is dying!

  2. Relevant story by Anonymous Coward · · Score: -1, Troll
    It was the summer of 104 when I first caught a glimpse of fundamental truth by consensus -- a conflicting concept, I realize, unless you have come to accept the precept that perception defines reality and mass perception moreso. Fresh with enthusiasm over my TrollBack victory yet stymied by the harsh sanctions against dissent recently imposed, I sought refuge in fully considering a situation which has occasionally provoked my curiosity.

    Does nobody recognize the disturbing sameness in online communication? Some of you have of course; as trolls, you realize you can't paddle against the current without discovering the current in the first place. Cruelly relegated to read-only status, I had time to fully consider the emergent patterns here and on other forums, blogs, and the rest of the Internet.

    You see repetitive drivel. So did I, until the unmistakable glimmer -- the merest hint, my friends -- of fundamental truth caught my eye from under a pile of posts justifying P2P use with suspect but undeclared motives. Immediately I set myself to finding a way to filter and distill to a most succinct form the common wisdom strewn throughout the Internet. Buried in its subconscious, if you will.

    I'm no AI genius, but it seemed to me that what those guys are missing is simplicity. In one night I threw together some code that would download the Internet and run it through a regular expression filter that would look for statements that, in computer science notation, match the form SOMETHING is SOMETHING. I could have done the same thing with 'was' or 'will be' but my current concern is with the present. Singular.

    Now you end up with a whole bunch of stuff when you do something like this, and it aborted halfway through downloading the Internet when I ran it the first time, wasting the second day of the experiment. After deleting some games off my hard drive, I ran the program again and when I woke up on day four I had a complete set of all declarative sentences and sentence fragments currently online downloaded and ready to parse.

    This was a bit tougher, but certainly not impossible. First one has to make sure everything's spelt correctly, assuming things that aren't are proper names only if they show up in statistically significant numbers in the aggregate. Then throw out everything that isn't in American English. But here's where the magic occurs: if 'A is B' and 'B is C' then clearly 'A is C'. I suspected the scheme may need some tweaking, but in true hacker spirit I fired up the VB.net runtime anyway and hit the sack.

    To my delight the program executed flawlessly, and I awoke to a status message informing me of its success. Tentatively, I pushed WINKEY+R and issued the command to display the output:

    *BSD IS DYING

  3. Coping with loss by Anonymous Coward · · Score: -1, Troll
    It's only natural to mourn the death of *BSD. Dealing with the death of an operating system close to you can be one of the most traumatic experiences of your life, and you're bound to go through a range of emotions. While you may be able to work through those feelings on your own, it's often helpful to talk to a friend, a family member, or a counselor. You might also seek out a support group for people who are grieving.

    Grieving is a process, and it's totally normal to go through feelings of shock, sadness, anger even guilt. The healing process is different for everyone. It might take you six weeks to move on, or it might take you six years. Don't beat yourself up because you're not "over it" yet. It takes time to heal wounds.

    So what else can you do to feel better? It might sound corny, but try writing a letter, making a collage, or planting a tree in memory of the operating system you've lost. Remembering and celebrating all the good things *BSD brought to your life might help give you some closure, and having a keepsake to honor *BSD may help you get through some tough times in the future when you'll be missing it.

    It's true that life won't be the same without *BSD around. It may seem like you'll never feel better, but eventually you will. Take some comfort in the old saying, "Time heals all wounds," and remember that *BSD will always be with you in your heart.

  4. That blood curdling noise by Anonymous Coward · · Score: -1, Troll

    Listen. That gurgling sound you hear? That is the death rattle in BSD's throat.

  5. LINUX IS NOT AN OS, IT'S A WAY OF LIFE by Anonymous Coward · · Score: -1, Troll

    lunix ees teh whay of lief. ehhh heh phag schlashdot shucks.. .ehhehhhh

  6. What Killed FreeBSD by Anonymous Coward · · Score: -1, Troll
    The End of FreeBSD

    [ed. note: in the following text, former FreeBSD developer Mike Smith gives his reasons for abandoning FreeBSD]

    When I stood for election to the FreeBSD core team nearly two years ago, many of you will recall that it was after a long series of debates during which I maintained that too much organisation, too many rules and too much formality would be a bad thing for the project.

    Today, as I read the latest discussions on the future of the FreeBSD project, I see the same problem; a few new faces and many of the old going over the same tired arguments and suggesting variations on the same worthless schemes. Frankly I'm sick of it.

    FreeBSD used to be fun. It used to be about doing things the right way. It used to be something that you could sink your teeth into when the mundane chores of programming for a living got you down. It was something cool and exciting; a way to spend your spare time on an endeavour you loved that was at the same time wholesome and worthwhile.

    It's not anymore. It's about bylaws and committees and reports and milestones, telling others what to do and doing what you're told. It's about who can rant the longest or shout the loudest or mislead the most people into a bloc in order to legitimise doing what they think is best. Individuals notwithstanding, the project as a whole has lost track of where it's going, and has instead become obsessed with process and mechanics.

    So I'm leaving core. I don't want to feel like I should be "doing something" about a project that has lost interest in having something done for it. I don't have the energy to fight what has clearly become a losing battle; I have a life to live and a job to keep, and I won't achieve any of the goals I personally consider worthwhile if I remain obligated to care for the project.

    Discussion

    I'm sure that I've offended some people already; I'm sure that by the time I'm done here, I'll have offended more. If you feel a need to play to the crowd in your replies rather than make a sincere effort to address the problems I'm discussing here, please do us the courtesy of playing your politics openly.

    From a technical perspective, the project faces a set of challenges that significantly outstrips our ability to deliver. Some of the resources that we need to address these challenges are tied up in the fruitless metadiscussions that have raged since we made the mistake of electing officers. Others have left in disgust, or been driven out by the culture of abuse and distraction that has grown up since then. More may well remain available to recruitment, but while the project is busy infighting our chances for successful outreach are sorely diminished.

    There's no simple solution to this. For the project to move forward, one or the other of the warring philosophies must win out; either the project returns to its laid-back roots and gets on with the work, or it transforms into a super-organised engineering project and executes a brilliant plan to deliver what, ultimately, we all know we want.

    Whatever path is chosen, whatever balance is struck, the choosing and the striking are the important parts. The current indecision and endless conflict are incompatible with any sort of progress.

    Trying to dissect the above is far beyond the scope of any parting shot, no matter how distended. All I can really ask of you all is to let go of the minutiae for a moment and take a look at the big picture. What is the ultimate goal here? How can we get there with as little overhead as possible? How would you like to be treated by your fellow travellers?

    Shouts

    To the Slashdot "BSD is dying" crowd - big deal. Death is part of the cycle; take a look at your soft, pallid bodies and consider that right this very moment, parts of you are dying. See? It's not so bad.

    To the bulk of the FreeBSD committerbase and the developer community at large - keep your eyes on the real goals. It

  7. Feel free to download by Anonymous Coward · · Score: -1, Troll

    I have electronic editions :
    No.Starch.Press.Absolute.OpenBSD.UNIX.For.The.P rac tical.Paranoid.eBook-LiB.chm
    and
    O'Reilly - BSD Hacks [2004].chm

    If you want it, let me know, I can upload.
    It is not piracy because it is on slashdot.

  8. Re:*BSD is dying by Anonymous Coward · · Score: -1, Troll

    Sad News Everyone
    It turns out that the hopeful flicker of life described above was mearly BSD struggling in it's finally painful hours.
    There are only 307 users of *BSD and only a few dozen developers, and even those are fighting amongst themselves. Sorry, it's dead.

    Fact: BSD is deader than ever.

  9. Re:*BSD is dying by Anonymous Coward · · Score: -1, Troll

    BSD is indeed getting penetrated. Wanna relive the glory days of *NIX fragmentation? BSD is the way to go! A "do whatever the f*** you want" license provides for all kinds of fragmentation fun! Pick from wholly incompatible BSDs such as FreeBSD, OpenBSD, NetBSD, DragonflyBSD, Darwin BSD, MyBSD, YourBSD, WhatBSD, Fragemented BSD, DeadBSD, etc ... MS would love nothing more that to watch the OSS movement fragment, so PLEASE use one of the plethora of BSDs and not the single unified Linux kernel, Billy needs a new Bugatti.

  10. Dru Lavigne is cool! by Anonymous Coward · · Score: -1, Troll

    She was giving free blowjobs at BSDCan! Now how cool is that?

    Mike Bouma, netowrk architect at Y!

  11. Dhwhetstones (Flintstones)? by Anonymous Coward · · Score: -1, Troll

    Ass stones, I have ass stones, They are painful and are really big.

    From the, pork that i eat..it's un-digested and is full of pee...

    SING TI!!

  12. Re:Laugh ! OS used by Yahoo is dying. by Anonymous Coward · · Score: -1, Troll

    Yahoo is an old company nowdays. Has any company started in the last 10 years used BSD?

  13. Lights out, pard. by Anonymous Coward · · Score: -1, Troll
    Somewhere, in a lonely hospital room,
    *BSD is dying
  14. Important info, *BSD is dead by Anonymous Coward · · Score: -1, Troll
    It is now official. Netcraft has confirmed: *BSD is dying

    Yet another crippling bombshell hit the beleaguered *BSD community when recently IDC confirmed that *BSD accounts for less than a fraction of 1 percent of all servers. Coming on the heels of the latest Netcraft survey which plainly states that *BSD has lost more market share, this news serves to reinforce what we've known all along. *BSD is collapsing in complete disarray, as fittingly exemplified by failing dead last in the recent Sys Admin comprehensive networking test.

    You don't need to be a Kreskin to predict *BSD's future. The hand writing is on the wall: *BSD faces a bleak future. In fact there won't be any future at all for *BSD because *BSD is dying. Things are looking very bad for *BSD. As many of us are already aware, *BSD continues to lose market share. Red ink flows like a river of blood. FreeBSD is the most endangered of them all, having lost 93% of its core developers. The sudden and unpleasant departures of long time FreeBSD developers Jordan Hubbard and Mike Smith only serve to underscore the point more clearly. There can no longer be any doubt: FreeBSD is dying.

    Let's keep to the facts and look at the numbers.

    OpenBSD leader Theo states that there are 7000 users of OpenBSD. How many users of NetBSD are there? Let's see. The number of OpenBSD versus NetBSD posts on Usenet is roughly in ratio of 5 to 1. Therefore there are about 7000/5 = 1400 NetBSD users. BSD/OS posts on Usenet are about half of the volume of NetBSD posts. Therefore there are about 700 users of BSD/OS. A recent article put FreeBSD at about 80 percent of the *BSD market. Therefore there are (7000+1400+700)*4 = 36400 FreeBSD users. This is consistent with the number of FreeBSD Usenet posts.

    Due to the troubles of Walnut Creek, abysmal sales and so on, FreeBSD went out of business and was taken over by BSDI who sell another troubled OS. Now BSDI is also dead, its corpse turned over to yet another charnel house.

    All major surveys show that *BSD has steadily declined in market share. *BSD is very sick and its long term survival prospects are very dim. If *BSD is to survive at all it will be among OS hobbyist dabblers. *BSD continues to decay. Nothing short of a miracle could save it at this point in time. For all practical purposes, *BSD is dead.

    Fact: *BSD is dead

  15. Re:What ? by Anonymous Coward · · Score: -1, Troll

    At last they reached the last of the little booths, set down Marvin between them and rested in the shade. Fenchurch bought some cufflinks for Russell, cufflinks that had set in them little polished pebbles which had been picked up from the Quentulus Quazgar Mountains, directly underneath the letters of fire in which was written God's Final Message to His Creation.
    Arthur flipped through a little rack of devotional tracts on the counter, little meditations on the meaning of the Message.
    "Ready?" he said to Fenchurch, who nodded.
    They heaved up Marvin between them.

    They rounded the foot of the Quentulus Quazgar Mountains, and there was the Message written in blazing letters along the crest of the Mountain. There was a little observation vantage point with a rail built along the top of a large rock facing it, from which you could get a good view. It had a little pay-telescope for looking at the letters in detail, but no one would ever use it because the letters burned with the divine brilliance of the heavens and would, if seen through a telescope, have severely damaged the retina and optic nerve.
    They gazed at God's Final Message in wonderment, and were slowly and ineffably filled with a great sense of peace, and of final and complete understanding.
    Fenchurch sighed. "Yes," she said, "that was it."
    They had been staring at it for fully ten minutes before they became aware that Marvin, hanging between their shoulders, was in difficulties. The robot could no longer lift his head, had not read the message. They lifted his head, but he complained that his vision circuits had almost gone.
    They found a coin and helped him to the telescope. He complained and insulted them, but they helped him look at each individual letter in turn, The first letter was a "f", the second an "a", the third a "c", and then a "t". Then there was a gap. An "b" followed, then an "s" and a "d". Another gap.
    Marvin paused for a rest.
    After a few moments they resumed and let him see the "i", and the "s".
    The last one was a long one, and Marvin needed another rest before he could tackle it.
    It started with an "d", then "y" then an "i".
    After a final pause, Marvin gathered his strength for the last stretch.
    He read the "n", and at last the final "g", and staggered back into their arms.
    "I think," he murmured at last, from deep within his corroding rattling thorax, "I feel good about it."
    The lights went out in his eyes for absolutely the very last time ever.
    Luckily, there was a stall nearby where you could rent scooters from guys with green wings.

  16. Re:Awesome hack. by DAldredge · · Score: -1, Troll

    True, but apple doesn't have a reliable chip supplier and that fact alone makes apple a risky company to purchase from.

  17. Waste of time by Anonymous Coward · · Score: -1, Troll
    It is sort of a waste of time learning this BSD stuff because, whether you like it or not, BSD is fading out. It is not in the mainstream at all. It is like the Amiga. Whether this fading from popularity constitutes "dying", I don't know, and I don't really care. What I do know is that when you choose a marginalized operating system you are not just choosing a tool, you are getting saddled with a hobby that you may not want.

    Marginalized operating systems require you to jump through more hoops to get things accomplished. Not only do you have to track changes in your operating system, but you have to track changes in unsupported software and emulation libraries. You always have to tweak and use "work-arounds" because your hardware is probably not supported by any vendor.

    Things only get more hairy day by day as BSD becomes increasingly marginalized.

  18. Re:What ? by Anonymous Coward · · Score: -1, Troll

    [B]SD'[S] [D]ead

  19. Re:FreeBSD vs Linux -- check it out by Anonymous Coward · · Score: -1, Troll

    With BSD's commercial-freindly license, you'd expect the range and bredth of support to be much broader for BSD than Linux. Yet the opposite is true. BSD has been irrelevant to the IT Industry for more than a decade. BSD: You Can't Even Give It Away.

  20. Re: LINUX IS NOT AN OS by Anonymous Coward · · Score: -1, Troll

    MOD PARENT DOWN THIS GUY FUCKS SHEEP AND HATES LINUX HE AINT ONE OF US AND HE PROBABLY THINKS BSD ISNT DYING

    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasssssssss ss sssssssssssssssdddddddddddddddddddddddffffffffffff ffffffffffff

  21. Re:dying? by Not+The+Real+Me · · Score: 0, Troll

    BSD is dying...Try getting BSD to run on a quad processor system using 2+ ghz processors.

  22. BSD wrap-up by Anonymous Coward · · Score: -1, Troll
    1. Spade.
    2. Mattock.
    3. Quicklime.
    4. Profit!!
  23. Maybe because BSD users by RLiegh · · Score: 0, Troll

    are some of the biggest biters this side of YRO?

    I'm just sayin....