FreeBSD Information and Tips

This page is here as a catch-all for bits of information, tips and tricks for FreeBSD that I've picked up along the way that aren't large enough to warrant individual pages. Some of the tips are cosmetic, some are usability improvements and some are just there cause I found the information handy to know. They are presented in no particular order (for now).


portaudit

There's this nifty little utility available in security/portaudit in the ports tree that will report (through the nightly security cron report) any known vulnerabilities for third-party software installed on your system. The database probably isn't kept 100% up-to-date, and it's not a perfect substitute for subscribing to the security lists for all the third-party apps you run, but it definitely can't hurt.

portaudit, combined with a nice subscription to freebsd-security-notifications@freebsd.org, can go a long way towards keeping you informed of potential security problems with your machine.


portupgrade

sysutils/portupgrade is a handy little utility that's nice for upgrading installed software on your machine. You can alter make information for a port that portupgrade is working on (-m and -M flags), supply a command, do things before and after portupgrade does certain things (-A and -B flags), rebuild ports recursively that depend on the port you specify (-r) and/or the ports that the port you're upgrading depend on (-R) and do lots of other nifty tricks.

One of the handiest flags that seems to get overlooked a lot is -o. -o is handy for making portupgrade upgrade ports predictably. Say you want to upgrade samba, but when you type "portupgrade samba" portupgrade wants to build net/samba3 instead of good ol' net/samba, which is what you really wanted. Use the -o flag to force portupgrade to replace the installed samba port with net/samba. It's as simple as "portupgrade -o net/samba samba"!


PuTTY and FreeBSD

PuTTY is a great little telnet/ssh client that also includes some very handy tools (pscp, psftp, pageant, etc.) that make life much easier as far as dealing with *nix machines from a Windows box is concerned.

I like to install PuTTY and friends somewhere on my Windows "Path" environment variable so I can run pscp/psftp from a cmd window, so a "quick and dirty" method to insure that everything is in a directory in your path is to install PuTTY or dump the files in to your C:\WINNT\SYSTEM32\ directory.

Having trouble seeing colors in your PuTTY terminals? Set your terminal-type string in the connection options to "xterm-color" instead of the default "xterm" and colors should work correctly.

Set your defaults. That 'Default Settings' saved session in PuTTY isn't there for just looks; you can set things to your liking there and new sessions will inherit those default settings. I prefer the courier font instead of courier-new, an orange cursor, disabling remote-controlled character set reconfiguration (under the features section inside the terminal features options) and such, so I save those to the 'Default Settings' profile early on.

From Tazle in irc.freenode.net's #2CPU comes a nifty trick for making URLs easier to copy with a single double-click (or less clicks) of the mouse. If you set certain characters in the "Control the select-one-word-at-a-time mode" window under the "Selection" option inside the "Window" option list to a class of "2" they can blend in with other "similarly-classed" characters and will automatically get included when you click on anything in the same class that touches those special characters. Tazle says he changed <, >, @, :, /, ?, &, = and "probably more" to class 2 and it makes URLs much easier to pick up with one double-click.


LSCOLORS

At work I'm required to work with Linux quite a bit. I don't necessarily care for Linux all that much, but I found the colors that Red Hat and Fedora Core use for their "ls" output to be much more "clear" than the default FreeBSD "ls" colors. The FreeBSD "ls" doesn't use the same LSCOLORS format as Linux's "ls," so I had to come up with a close approximation of the Red Hat/Fedora Core color scheme. The closest I could find with only a few minutes' worth of work was

ExGxFxdxCxDxDxhbadExEx

Now all you need to do is toss that in your shell's rc file, exported properly, along with whatever you need to set "CLICOLOR" to YES for your shell. For sh (and derivatives), it'll look something like this:
CLICOLOR="YES";    export CLICOLOR
LSCOLORS="ExGxFxdxCxDxDxhbadExEx";    export LSCOLORS
I think these colors are much easier to deal with and less drab than the default FreeBSD "ls" colors.


/usr/src

/usr/src is a handy thing to keep around. I know some users that delete /usr/src after doing their latest buildworld/buildkernel song-and-dance, ostensibly to "save some space." What it does, however, is make upgrading a much more painful process. cvsup will have to rebuild the entire tree, you can't apply patches to /usr/src if you need to patch cause, well, there's no /usr/src and you can't rebuild individual bits of /usr/src (like, say, sendmail) without cvsupping the whole mess, which will require you to do a complete buildworld/buildkernel to get everything back in sync.

It's more than safe to remove /usr/obj after doing the installworld/installkernel shebang, cause you can always build any dependancies you'll need to rebuild individual bits if you've got /usr/src around, but removing /usr/src is generally a Bad Thing(tm) unless something goes very wrong.


mplayer

mplayer playing sound from DVDs horribly? Build multimedia/libdts from ports, then rebuild mplayer (using portupgrade -f). This fixed the occasional screeching racket sound from DVD playback. It only happens on certain DVDs, but when it happens it's annoying.


portsnap

portsnap is a handy utility to update your ports tree quickly without cvsup. Benefits include being part of the base system (from 5.3 on, IIRC), being faster than cvsup and ease of use.

To use portsnap the first time, you simply run

portsnap fetch extract

to create the initial ports tree with up-to-date ports. Once you've done the (time-consuming) "fetch extract" step you can just use

portsnap fetch update

to update the ports tree with the up-to-date ports. The "fetch update" step is generally much faster than cvsup.


TrueType fonts and xterms

Looking for a quick and dirty way to test out all of your monospace, scaleable fonts in order to find one that looks better for you? Try this on for size:

fc-list :spacing=mono:scalable=true family | sort | tr '\n' '\0' | xargs -0 -I FONT echo xterm -fg white -bg black -cr orange -T \'FONT\' -fa \'FONT\' -fs 12 -e man ls \& > xterm_test; sh xterm_test

This will spew a bunch of terminals on-screen, all of them executing 'man ls'. You can change that if you'd like.


Oracle support in PHP

Need to build PHP5 with Oracle support? Check out this page. I've used this successfully at work and found the info on the page very helpful in getting things going.


Page created 20040701 00:01.
Page updated 20080423 14:21.
Comments? Suggestions? Send them to hemi@puresimplicity.net.