A Look Through the Ports Collection12/20/2000
If you're like me, you look forward to the end of December as it holds the possibility of receiving new hardware or computer-related toys, as well as the chance to actually have some time to play with your FreeBSD system.
Whenever I have too much time on my hands, I can be found perusing the FreeBSD ports collection. I provide endless amusement for my daughter as I show off my latest geek discoveries; to paraphrase her favourite Dogbert quote, I've entered the state of "nerdvana."
In this week's article, follow along as I take a tour through the ports collection on the hunt for the obscure, the amusing, and the useful.
Building a port is simply a matter of "cd"ing into the desired build directory and typing
make && make install. One might ask, how could one possibly improve upon such a simple concept? How about by providing an intuitive graphical interface? Become the superuser, ensure you are connected to the Internet, and try the following:
cd cd /usr/ports/sysutils/pib make && make install rehash (if you are in the Cshell) startx (to enter an XWindows session)
You will have to remain the superuser to actually install ports using the
pib utility. You can start
pib by either adding an icon to your Windows Manager or by opening up an xterm and typing
pib starts, you'll be presented with a window that displays all the subdirectories of
/usr/ports. If you double-click on a category, you'll get a listing of the available ports in that category. If you double-click on a port, a summary of its description, the name and e-mail address of its maintainer, and a list of its dependencies will be displayed. If you want to read its full description, click on the "?" next to its description.
Let's click on the "Function" menu, then click on the word "Search." Here is an interface to search the ports Index. For example, if you know what you'd like a utility to do, but don't know the name of the port that will do it, try a keyword search with the "comment" button depressed. You can double-click on any search result to be taken to the information available for that port.
Let's actually build something using
pib. Click on the "misc" directory, then on "figlet." Click on the "Function" menu, then on "Maker." You should notice the word "figlet-2.2" in the upper right-hand corner, followed by 8 buttons; the first 7 buttons will be used to make this utility. Start by clicking on the "Clean" button and watch as the
make utility does its stuff on your screen; when you receive your cursor back, click on the "Accept" button in the lower left-hand corner, and then click on the "Fetch" button. Continue this process until you've cycled your way through the first seven buttons. The one dubious "benefit" of
pib is that you do get to see all the functions
make goes through to install a port, as there is no mega-button that you can click on to do everything for you.
Before we use
figlet, let's take a look at your "Message of the Day." Everytime you log in, you receive a message telling you which version of FreeBSD you are using and how to get help using FreeBSD. While this is a useful message, it's not very exciting after you've read it a few hundred times. Fortunately, the file that provides this message is editable by the superuser and can contain whatever the superuser deems appropriate for his users to read at login time.
Let's customize this file (
/etc/motd) using our new
figlet utility. Try the following as the superuser:
figlet "Welcome to FreeBSD 4.2\!\!" > /etc/motd
then log out and back in to see your results.You'll note that
figlettook the text contained within the quotes and wrote it in a more interesting manner. We had to use the "
\" to prevent the shell from interpreting the double exclamation marks as a history command. (Forget how history works?) If you don't believe me, try the above command again without the
\s and see what happens when you log out and back in. Finally, we used the single
>redirector, which overwrote our original
/etc/motdfile. (Forget how redirectors work?)
Let's try a more seasonal message:
figlet -f bubble "SEASONS GREETINGS \!\!" > /etc/motd
When you log out and back in, you should receive this:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ( S | E | A | S | O | N | S ) ( G | R | E | E | T | I | N | G | S ) ( ! | ! ) \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
Figlet comes with several dozen different fonts; see
man 1 figlet for details.
In my search for interesting ports, I usually go to FreshPorts Recently Added Ports page at least once a week to keep abreast of which ports have been recently added. The one that caught my eye this week was "nonsense"; any port with a name like that and a link to its homepage is just asking to be built. I downloaded
nonsense-0.4.tar.gz into my home directory, then issued the following commands:
tar xzvf non* (to unzip and extract the files) cd nonsense-0.4 more README (to figure out how to use this thing)
If you decide to run
nonsense while in this directory, don't forget to put a
./ before your command. Save this utility for a rainy day, as it is a good time-waster; I spent far too much time in the random insults and fortune sections.
While at the "nonsense" homepage, I noticed that they also provide fortune cookies. If you don't receive a humourous fortune when you log in, you probably didn't install the fortune utility when you installed FreeBSD. To rectify this situation, become the superuser and type:
And choose Configure, then Distributions, then arrow down to Games and use your spacebar to select it; press Enter and choose your Installation Media
Once it is finished, exit out of
sysinstall. Now when users log in, they should receive a fortune; if you would also like users to receive a fortune when they log out, see Customizing the Login Shell).
Now that you have the fortune program, you can install additional fortunes as you come across them. This is how I added the Humorix fortunes from the Humorix web site: I saved the file
humorixfortunes-1.2.tar.gz to my home directory. I then typed:
tar xzvf humo* (to unzip and extract the files) ls humorixfortunes-1.2 humorix humorix.dat
These 2 files needed to be copied to
/usr/share/games/fortune, as this is the directory where the fortune databases are stored. To see if I had permission to do so, I typed:
ls -l /usr/share/games
total 20 drwxr-xr-x 6 root wheel 512 Dec 8 21:18 ./ drwxr-xr-x 26 root wheel 512 Nov 20 08:11 ../ drwxr-xr-x 2 root wheel 512 Dec 8 21:16 atc/ -r--r--r-- 1 root games 10087 Nov 20 06:59 cribbage.instr -r--r--r-- 1 root games 1566 Nov 20 06:59 fish.instr drwxr-xr-x 2 root wheel 512 Dec 16 10:33 fortune/ drwxr-xr-x 2 root wheel 512 Dec 8 21:18 larn/ drwxr-xr-x 2 root wheel 1024 Dec 8 21:18 quiz.db/ -r--r--r-- 1 root games 1883 Nov 20 06:59 wump.info
Since only the superuser has write permission to the fortune directory, I copied the files like so:
mv humorixfortunes-1.2/* /usr/share/games/fortune
To double-check that it worked:
ls /usr/share/games/fortune./ fortunes2-o.dat murphy-o.dat ../ fortunes2.dat murphy.dat fortunes humorix startrek fortunes-o humorix.dat startrek.dat fortunes-o.dat limerick zippy fortunes.dat limerick.dat zippy.dat fortunes2 murphy fortunes2-o murphy-o
Both humorix files are now available for use by the fortune program.
Well, we've lingered a bit in the amusing category; let's move over to the obscurely useful. As any of my students can attest to, I spend far too much time reading RFCs and forcing my students to do so as well. (Don't know what an RFC is?) Of course, I was intrigued by a port called "rfc," so I "cd"ed into /usr/ports/misc/rfc to build it. Once it was installed, I typed:
and received the switches available for the utility. Before you can use the utility, you must first build the index by typing:
I had problems connecting to the index site, so I manually fetched the index. Using Netscape, I went to http://www.rfc-editor.org/rfc.html and clicked on the hyperlink for "RFC Search and Retrieval." I then right-clicked on the hyperlink for "Download Entire RFC index file" and saved the file to
/usr/local/etc/rfc-index. I was now ready to use the
rfc utility like so:
rfc -l 1
and I was able to read RFC number 1 without the hassle of going out and looking for it. But that's not the end of this utility's usefulness. RFC 1700 (the RFC for assigned numbers) has its own switches to allow for quick searches. For example:
rfc -p ip 6
will reveal that TCP has a protocol number of 6.
rfc -p port doom
will remind me that 666 is the port number for doom. And:
rfc -p port 1433
will show that this is the registered port number for MS SQL server. But wait, it gets better. If I type:
rfc -n -i
I'll build the index for all known trojan port numbers. Once I've created this index, if I want to check a suspicious port:
rfc -n 12345Looking up service... NetBus 12345/tcp # NetBus backdoor trojan
I can tell this is a utility I'll miss when I'm not sitting at my FreeBSD box.
The last utility I want to mention today is
powershell, which can be found in the
/usr/ports/x11 directory. Once you've built it, open up an XSession and either create an icon for PowerShell within your Windows Manager, or start it from an xterm by typing:
/usr/X11R6/bin/powershell. (You can view a screenshot at the PowerShell SourceForge page).
The first time you start PowerShell, it doesn't look much more exciting than an xterm. In order to use PowerShell, you'll have to tweak it a bit. With your mouse, click on the "Edit" menu, then "Preferences," then the "Menus" button. If you have installed
lynx, their paths are incorrect; change
/usr/bin to the correct path of
/usr/local/bin and apply your changes.
Now you're ready to use PowerShell. If you either click on the "File" menu or right-click on the taskpad, you can start another tcsh shell, bash shell, or pico, pine, lynx, or emacs. Everything you start will be given its own labeled tab, and you can run as many of these as you have the inclination to. It's a simple matter of clicking on the appropriate tab to quickly switch from shell to editor to surfboard.
You'll find that PowerShell's help file is actually helpful, and the utility is quite configurable. It is the ideal utility for the power user who insists on doing several dozen things at once; this utility just may save me from wearing out my Ctrl-Alt function keys.
I hope you have enjoyed the articles in this year's FreeBSD Basics series. Here's wishing you a joyful and restful holiday season. I look forward to seeing you again in 2001 as we discover more about our FreeBSD systems.
Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.
Read more FreeBSD Basics columns.
Discuss this article in the Operating Systems Forum.
Return to the BSD DevCenter.