Monday, March 22, 2004

Make X work

While I don't run an X server on my server machine (just text mode stuff there), I will be getting a new machine in the near future, and, in the trickle down theory of machines, I think I'll have a slower (800mhz!) machine to play around with FreeBSD 5, and on that I will install X. I've done it a few times, on various Unixen, and it is a process fraught with peril. This is especially true if you are using some cutting edge video card. Trailing edge ones are your best bet.



Anyway, here's an article that supplements the FreeBSD manual entry: The X Window System:


ONLamp.com: Building an X Server and a Window Manager [Jun. 21, 2000]


A little known fact - I was a developer on the original X Window system, way back in the days of MIT's Project Athena, where it all began. Actually, I wasn't an official developer, but I was one of the very first users of X Window System, as I worked as a teacher liason with Project Athena, and one of its centerpieces was X. I wrote a bridge game (unimaginatively called 'xbridge') that for years was on the X distribution tape. That was a looong time ago.....






How To Ask Questions The Smart Way

Interesting article on how to intelligently ask questions in a public forum, like freebsd-questions. Fairly aggressive, but they are right, you know:-)



How To Ask Questions The Smart Way

Thursday, March 18, 2004

Ports makefile

I've talked before about makefiles and ports (see here), but I just found out about Yet Another Makefile used by the port system: /usr/ports/Mk/bsd.port.mk. This one lists an amazing number of options that can and will be used by building stuff in the ports folders. It is of especial interest to port maintainers, but has some options that can also be useful for us mere mortals.



One of the more interesting options are the BATCH and INTERACTIVE ones. They are only docuemented (in 4.9, anyway) indirectly, under the IS_INTERACTIVE comment in /usr/ports/Mk/bsd.port.mk, which I find more than a little odd for something so useful. If you set the BATCH environment variable (or, I assume, define it on the make command line thusly:


$ make -dBATCH

), it will not try to make any port that asks for interactive input. This is especially useful if you are doing a massive portupgrade and want to go away for a bit. Define BATCH in your environment (BATCH=1; export BATCH in bash) and it won't try to build interactive ones, like PHP, which has tripped me up a few times.



INTERACTIVE is the opposite of BATCH. Define this, and only ports marked as INTERACTIVE will build. So you can do the BATCH portupgrade first, then come back and do the INTERACTIVE ones while you are there coaxing it along.




Tuesday, March 16, 2004

The 'wc' command

No, the 'wc' command doesn't "flush" anything :-). Someone asked on the freebsd-questions list "How do I count the number of files beginning with 'db' in my current directory?". And the key command is 'wc'. It's a nice, simple little command
that does one thing and one thing well - it counts "words". If you don't
give it any flags, it tells you the number of lines, words, and bytes. Using
-l will count the number of lines. So you pipe the output of a command to
it and it will count stuff for you. Thus:




$ ls db* |wc -l


will give you a single number telling you the number of lines in its input;
in this case, the input is the output of 'ls db*', which is a simple listing
of all the files in the current directory beginning with 'db'. Thus, you
get a count of the number of files in the directory that begin with db.
A very typical Un*x way of doing things - string together building block
commands to get your output. Flexbile if arcane.



FreeBSD Hypertext Man Pages: wc



Friday, March 12, 2004

ch c/c++ interpreter

A cool looking utility that just may end up in the ports collection, as they are finishing up a FreeBSD version:


Ch -- an embeddable C/C++ interpreter



portupgrade options

When using portupgrade, it can be nice to capture the output it generates, especially if it is a many port upgrade. There's a couple of solutions to this problem:


  • Use commands that grab the output and save it for you. tee and script are ones that immediately come to mind. Script is recommended in several books on FreeBSD, esp. when rebuilding the kernel, which can generate a lot of messages. I tend to do these things inside an emacs command shell, so I "automatically" get logging.

  • portupgrade itself has a very handy option : -l filename. This will log the output to the file. The -L option gives you control over the name of the log file.





Tuesday, March 9, 2004

PHPAccess

Interesting looking PHP utility for controlling access to your web folders. It looks easier to use and more robust than .htaccess.



PHPAccess: htAccess via PHP - The WWW Security Admin Tool with easy-to-use GUI



DBDesigner

While not strictly a FreeBSD utility, this looks like an excellent "free" database designer, esp. for MySQL databases. It has a Linux KDE/Gnome version, which may just run under FreeBSD's excellent Linux emulation. Let me know if it does!



fabFORCE.net's DBDesigner



'id' command

I have often used the 'whoami' command to figure out who I am currently logged in as, if I somehow forget. However, if you need even more info than just who you are currently, you can use the id command. It gives you all sorts of info on your current login id, including groups and aliases. Nice.



FreeBSD Hypertext Man Pages: id



Display keyboard layout (in X)

I don't use X on my server, but I thought I'd point out this nice command that 'epi' posted to the -questions list for displaying a visual map of your keyboard:



xkbprint -color -nkg 2 -lg 1 :0 - | gv -seascape -scale 4 -

I still need to work on my keyboard map for my console though - I miss not having a meta key in emacs. But I've never gotten one that has all the "right" keys for me, so I stick with the default until I have the time to work on it.




Friday, March 5, 2004

cron mail

Whenever you run a command in your crontab, if there is any output, it will send you an email. This is sometimes a good thing, but sometimes not, depending on how often the job runs and what kind of output it generates.



If you just want to get rid of "normal" output, and only have it email you if there is error output, you can redirect stdout to /dev/null, like thus:


5 * * * * yourcommandhere >/dev/null

This sends normal output to the bit bucket, but anything the command puts out the stderr (the error output) will get emailed you.



If you want to ignore all output, error and normal, you can "tie" the error output to go to the same place the normal output goes, like thus:


5 * * * * yourcommandhere >/dev/null 2>&1


Now you won't get any email.



Another option for turning off email is to set the MAILTO variable to NULL. See the manpage for more discussion on this option.




Thursday, March 4, 2004

Quickpatch

Excellent looking utility for keeping up with the Jones' ... err ... I mean the security updates and patches for FreeBSD. A perl script that will read the security bulletins and tell you (or even do) everything you need to know. I've always been a little lax at keeping up with these things, but I should be much more vigilant. Maybe this will help?


Quick Patch for FreeBSD / Roq.com



Fix port collection

Okay, I'm doing it.



Lots of other FreeBSD admins are doing it.



Why aren't you?-)



What is it we're doing? We're upgrading portupgrade, and ruby, that's what! We're doing this by carefully reading /usr/ports/UPGRADING and following its instructions.


Sample ipfilter rules file

Sometimes, it helps to see an example. And when it comes to firewall rules files, that is doubly true. Here's Shaun Erickson's ipfilter rules file:

IP Filter rules



trafshow

A utility that displays in some graphical way (on a text screen anyway) the current traffic on an interface card. I'm going to give this a try, as apachetop just crashes on me.



Port description for net/trafshow



Rotate Apache logs

Yes, I've written a little about syslogd and the associated newsyslog previously, but here's a nice concrete example on how to use it. The gist of it all is that you just add the following line to your /etc/newsyslog.conf file:


/var/log/httpd-access_log 644 7 100 24 B /var/run/httpd.pid 30



Or at least one very much like it. Read more here:


The FreeBSD Diary -- Apache - rotating log files



In fact, I'm going to head off and add this right now!





FreeBSD iso Snapshots

This is a site that maintains updated FreeBSD ISO files. These are the files that you can burn directly onto a CD, thus giving you a bootable CD to install from, using the latest version. On FreeBSD.org, I think only the official RELEASE versions are kept.



FreeBSD SNAPSHOTs



Tuesday, March 2, 2004

memtest

A cool looking utility to test your memory chips. Make a simple boot disk and run this (free) utility to make sure your memory chips are working. This is an important thing to do when your computer starts acting "weird" - boots, freezes and other strange happenings. In FreeBSD, this often manifests itself when you get an "Error 1" when doing a make world. I have no idea why this is true, but it is in the FAQ!



Memtest86 - Memory Diagnostic Page



Monday, March 1, 2004

New ports file

There's a new file that will be coming to /usr/ports near you soon. It is UPDATING, and is a collection of notes to be perused after you've updated your ports collection (probably via cvsup). The first entry will be on the portupgrade/ruby mess, which will show you the steps you need to do to upgrade portupgrade & ruby (basically, delete each of them and then add them back).


sudo

It's not really anything I need, as I'm the only real user for my server, but sudo looks like an important port for those running FreeBSD boxes that want to selectively give others permission to run utilities that are normally reserved for the root user. If you run into this, and don't want to give a user the root password (almost certainly not!) or even make them a member of the very special "wheel" group (which allows them to su as root), you might look into installing this port.



Port description for security/sudo



Jabber

An interesting looking IM (Instant Messaging) and more application called Jabber: Open Instant Messaging and a Whole Lot More, Powered by XMPP. I might install this on my machine and give it a whirl.





Port description for net/jabber



Kernal Config notes

As was just pointed on on the freebsd-questions list, in FreeBSD 5.x, the LINT configuration file found in /usr/src/sys/(arch)/conf file no longer contains comments on all the options. As you may recall, the LINT file contains all the options you can put into your own custom kernal configuration file. It is not a buildable configuration file, though, just a complete list.



In earlier versions of FreeBSD, it also contained short comments that documented the options. However, in 5.x, there is now a separate file that does this. It is called NOTES. I'm not sure why they did these, except that it is probably easier to document something when not forced to use makefile style comments.