Desktop FreeBSD Part 3: Adding Software

By Ed Hurst | Posted at 9:46 PM

FreeBSD is very much a source-based system. The operating assumption of the architects of FreeBSD is that you will compile most things from the source code. The system is designed to work that way, and does it exceptionally well. The famous "Ports Collection" is rather unique in making a large number of packages available ready to build and seldom requires anything but a few commands in a terminal window. Having tried to build specialized applications on several different versions of Open Source operating systems, I can assure you that compiling on FreeBSD is about as easy as it gets.

Our problem is that dialup connections are a major bottle-neck for really big programs. If you have time, and your connection is fairly stable, you can download the source code for something like Mozilla using the ports system, and it's quite likely to be fine. However, the source code for Mozilla is massive, and could easily require you to get it in chunks over several days via FTP. That is, providing you use an FTP client that knows how to start where it left off last time -- Konqueror does just fine at this.

You can also download pre-made packages, but you would be forced to use whatever version was available when your version of FreeBSD was released. Something like Mozilla is a moving target, and newer version often have really useful improvements. The newest version is available for FreeBSD, but it is always built with all sorts of newer supporting libraries, newer than you have on your system. It seems nobody builds Mozilla with any sort of backward compatibility for the standard releases of FreeBSD. You'll have to update everything at the same time. For computers with a good fast connection, that's fine. They can be kept up to date with regular rebuilding. We dialup users will have a hard time playing that game.

Commercial users of FreeBSD and serious hobbyists will keep up with the current version of everything, but ordinary desktop users should probably avoid that sort of thing. Aside from security updates, it's best to avoid the upgrade merry-go-round. That doesn't mean we are stuck with some sort of second-class provision, though. You recall I advised everyone to install and enable Linux compatibility. That's because with programs like Mozilla, there are far more Linux users out there, and the Linux versions are more backward compatible. And we can run them as they are. In the case of Mozilla, it's slightly complicated, but with a couple of minor adjustments in the Makefile for Linux Mozilla in the ports system, you can download the .xpi files for the most recent version, run the script and it will install and run just fine. On some machines, it will run faster than it would if you ran Linux itself. For something simpler, like Mozilla-Firebird, you need but unzip the files and put them in a convenient directory and it will run with no adjustment at all. Very few Linux applications won't work in FreeBSD.

If your supplier for the FreeBSD install CD also offers the full collection of packages built for that release on more CDs, it can save you a great deal of time. You can get a good idea what's available by visiting the FreeBSD Ports Page. You can search the database for the version of FreeBSD you run, and there are links to download binary packages ready to install. Please note that the assumption here is that you are running a standard release of FreeBSD, so be sure to select in the drop down list your version with the "RELEASE" tag, not "CURRENT." So you choose your package, click the link that says "Package" under the description, and download something. When finished, you need to open a Konsole window, and login temporarily as root:

   su root

You'll be asked to type in the password. Afterwards, you'll be at a different style of prompt. You should be still in your own home directory, where I'm assuming you saved the package just downloaded. Type ls just to be sure -- it should be somewhere in the list that appears. Then, type the command

   pkg_add something.tgz

Obviously, "something" is replaced by the package name. If there are no problems, if you have all the other stuff needed for that package, it will install and set it up, then return to the root prompt. If there is something missing, you will get an error message with a specific list of packages that you must have before installing this one. Go back and get them, install them, try again to install the original package, and you should be set. It's a good idea to move them to another place when this is done, to avoid clutter in your home directory. I recommend you store them in /usr/local/src, unless you can't afford the hard drive space. In that case, simply delete the packages that were successfully installed.

However, assuming the worst case, we are going to download and install a small and simple package that is very useful. Having logged in as root in a Konsole window, type

   cd /usr/ports/editors/joe

You need to be in the directory with the application you are building. If you are one folder above, you'll be building everything in that category -- all the various editors, in this case. Next, from the KDE menu, open the KPPP program and connect. When that's done, click in the Konsole window and type

   make install

You should see some messages flashed on the screen; try to read them and understand what's happening. Usually, there will be a hunt for the source files, then not finding them, an attempt to download them. There will be a display of progress. Then the package will be configured, then it will be compiled and so forth. Finally, you will see some message indicating the application was registered and the prompt will come back. Now type make clean and you are done. You can exit your root login by typing just that: exit. Don't forget to disconnect from the Internet unless you have a reason to stay connected.

With some packages, you'll see the process downloading other stuff that it has to have before going on to the main event. The editor named "joe" runs in the console/CLI, which means it also works in a Konsole window in KDE. Konsole is one of several "terminal emulators" that allow you to operate as if you were without a GUI, but do it while running the X server. It compares favorably to a DOS prompt in Windows. However, there are other terminal emulators, and one is called "xterm." It's also on your system, because it's a part of the XFree86 packages. Got GUI? You got xterm. There are others, and we will learn to customize in a later article.

For now, let's look at our new editor, joe, in the Konsole window. At the prompt, simply type joe. You should see a border at the top and a message. If you type ^K and then H you'll get a help section at the top of the screen. Keep an eye on that top border, where messages appear from time to time. Depending on what you do, you'll also see some messages at the bottom line of the screen. But the help summary at the top has everything you need to get started. Every good user of FOSS will determine to learn as much as possible on their own, so I will let you handle this for yourself from here. Just remember, you can save and exit with ^K then X or not save with ^C.

However, I will tell you that it is possible to make some adjustments to joe with a file in your home directory. Open the file browser (the icon for "Home") and click the root folder icon on the left side. Navigate to /usr/local/lib. Click on the icon so that the main window displays what's in that directory. There you should see a file named joerc. Look on the left window and identify your home directory there: /usr/home/user (replace user with your chosen user account name). Open folders if you need to by clicking on the plus signs (+) but without clicking on any folder icons. Now, click and hold on the joerc file icon and drag it across to where your home folder is shown until it is high-lighted. Let the mouse button go and you should see a short list of options. Select "Copy here". Now navigate to your home folder by clicking the "Home" icon in the toolbar at the top. You should see a joerc there.

Open Kedit and use the "Open file" function to open this joerc file. You can read the instructions written there. You may not understand all the options, but set those you do understand. Notice that options are set by making them start on the far left margin. There are examples for you to look at. Again, you are pretty much on your own, as you learn to experiment and try it out. Save it and then change the name of the file. Configuration files like this need to remain "hidden" by putting a period (or dot) in front of them. You already have several others there. In your file browser, right click on the file icon, select "Rename" and hit the HOME key. Type a period at the front of the name, then hit ENTER. It should change to a shadowy icon to indicate it's not normally visible.

If you are totally clueless, and you need to make it work today, you can e-mail me for a copy of my .joerc. I have mine setup to write plain text files a certain way. The right margin stops at 72 characters, which is the Internet standard, and some of the keyboard commands are different. I compose text in block format, with a blank line between each paragraph. If the lines get too far out of place by changes, I type ^J to reformat. Other composition settings apply to any file with a .txt ending and they follow the standards I discuss in my e-text guide. Voluntary adherence to standards is a very important part of the Open Source way.

The reason I have chosen joe for this exercise is that it's the easiest to use, and the most flexible console editor for newbies, having the most options, but easy to understand. When you find yourself needing to edit files from the console/CLI as root, joe is much easier once you've gotten used to it. You may browse the entire ports collection at http://www.freebsd.org/ ports/ and learn for yourself what's available. You can check with your favorite Internet search engine for more details on what the various applications do. Join a mailing list, forum, or user group to get advice on which programs do what.

In the next tutorial, we will discuss setting up your internal mail server -- postfix -- to connect to the Internet, and other e-mail issues.

Ed Hurst is Associate Editor of Open for Business. Ed is also the Music Director for Grace Baptist Church of Kickapoo Creek, Texas. He loves computers, runs FreeBSD and reads all sorts of things. You can reach Ed at ehurst@ofb.biz.