Desktop FreeBSD Part 3: Adding Software

By Ed Hurst | Posted at 10:10 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.

At this point, dialup users need to configure KPPP. From the KDE menu button, go to Internet, then KPPP. For the most part, the program options should be self-explanatory. If nothing else, click on the "Help" button. There really isn't room to cover the details of it here.

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 NEdit using the ports system, and it's quite likely to be fine. However, the source code for Firefox 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, but the ports building scripts are intelligent enough to start where you last left off if you stop the process before finishing.

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 Firefox is a moving target, and newer version often have really useful improvements, or security fixes. The newest version is available for FreeBSD, but it is always built with all sorts of newer supporting libraries, sometimes newer than you have on your system. It seems nobody builds Firefox 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 until they have some experience. Until you're ready, there's the Linux compatibility. You may recall I advised everyone to install and enable Linux compatibility. That's because with programs like Firefox, 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 Firefox, it's slightly complicated, but the install script in the ports system will take care of everything. On some machines, the Linux version will run faster than it would if you ran Linux itself. A very large number of Linux applications work in FreeBSD, and many are already scripted in the ports.

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: the assumption here is 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/pkg. Simply create the directory like this:

mkdir /usr/local/pkg

Then move the package there:

mv something.tgz /usr/local/pkg/

If you can't afford the hard drive space, 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. Dialup users, 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. Next, 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.

Basic tip: You can always stop the process by typing CTRL+C (normally represented like this: ^C). If you want to come back later and restart, it should resume where you left off.

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 X.org packages. Got GUI? You've 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 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/etc/joe/. 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.

First, we have to change the permissions on the file so you can edit. Right-click, and you should see a list of options, including "Properties" at the bottom. On the window which pops open, click on the "Permissions" tab, then the drop down bar near the top of that page next to "Owner." Select the option "Can Read and & Write." Click the "Okay" button. Then, open Kedit and use the "Open file" function to open this joerc file. You can read the instructions written there in the file itself. 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. However, I offer an more advanced HOWTO on customizing Joe here. Save this file and then change the name. 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 F3 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 for what it does. 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.

Ed Hurst is Associate Editor of Open for Business. Ed operates a computer ministry in Oklahoma City. He loves computers, runs FreeBSD and GNU/Linux and reads all sorts of things.


Join the Conversation

16 comments posted so far.

Re: Desktop FreeBSD Part 3: Adding Software

Ed,

Wonderful series of articles. I’m a long time Linux user, and I’ve recently become interested in the BSD way of doing things, so I was glad to see these articles showing up. I would like you to consider one thing: PLEASE stop referring to Linux as GNU/Linux. Now, I’m not looking to start a holy war, but please let me explain my reasoning.

Linux is the operating system - the kernel upon which all other services run. The GNU utilities/programs are a small subset of Linux compatible code - nothing more. It’s no more “GNU/Linux” than it is “Xorg/Linux”. In fact, by any standard of measure, “Xorg/Linux” would be more accurate. Think about it, measured by lines of code, percent of usage, or importance to the desktop, Xorg is a far more important component than the GNU utilities or programs (for which there exist viable alternatives in nearly every case).

The one “holy and untouchable” exception to this arguement follows: “But Linux is built using the GNU Compiler collection, so it’s foundational to the operating system.” This is so blindly stupid that it makes me ill to have to reply to it, but here goes: The GNU compiler is a good TOOL, just like the Intel and Microsoft compilers. But let’s face it, it is a tool, nothing more. The Linux kernel doesn’t depend on it to “validate it’s existence” any more than it depends on Xorg. Further, as I understand it (please correct me if I’m wrong), BSD is still compiled with GNU’s beloved compiler also, and nobody runs around calling it “GNU/BSD.”

In any case, something to think about I hope. Thank you again for your efforts. By the way, what do you think of PC-BSD?

Posted by GregM - Apr 13, 2007 | 5:53 PM

Re: Desktop FreeBSD Part 3: Adding Software

I must admit that I did not read the entire article, for several reasons.

1) I have been using FreeBSD for over 5 years as a desktop and server environment. 2) It’s a pretty big article, and I have other things to do :P and… The best way to install software from the packages is to not fetch the packages manually, let the system do it for you :) with: pkg_add -r appname
replace appname with the name of the directory in the ports directory eg. /usr/ports/x11/gnome2 would be: pkg_add -r gnome2

This -r option is VERY useful. It will fetch the package for you from the main FreeBSD repo’s… and ALL the dependencies that you don’t already have. Obviously you would need to connect to the internet in what ever way you would normally.

If you have older dependencies (which you should not if all your software is installed via the packages) then use the -f option to force the new dependency to install, this might or might not crash the system it just depends on how much you want to risk it.

Last tip when you install something from the ports, I would use “make install clean” instead of “make install” the clean bit tells the system to literally clean up after it’s self and delete the files used for compiling the package.

I fortunately have never had to deal with FreeBSD and dialup , but I am sure there is a way of auto-connecting when needed?

Just my few tips I should really tidy up my JBSD installation article… and the scripts to go with it…

Posted by Jayton - Apr 14, 2007 | 9:02 PM

Re: Desktop FreeBSD Part 3: Adding Software

Well, Greg, that reference to GNU is an editorial decision not made by me.

Jayton, I wrote the original version while tied to dialup, and a very slow connection at that. When I tried using the -r switch, it didn’t work well. Manual downloads were safer. This series is predicated on near-worst-case situations: What’s the one safest way to get this done? Extra options would only confuse newbies. However, I’m very glad you added it just in case someone wants to try it.

As for auto-connecting: Yes, there is a way, but it was unsuitable for my home user, two-computer situation. Again, I’m writing from the low-end.

Posted by Ed Hurst - Apr 15, 2007 | 1:50 AM

Re: Desktop FreeBSD Part 3: Adding Software

Greg, sorry for that (and for my bad english), but you like it or not, Linux isn’t an operating system, it is only a kernel. The whole operating system is a combination of a kernel (Linux), and the user-land formed by GNU software. Is something “normal” to call GNU/Linux to combination of a Linux kernel and the GNU user-land, also know like “distro” or distribution. From this point, is the normal way everybody (especially in edition world) call a “Linux” distro like “GNU/Linux”.

Regards.

TooManySecrets
Have a nice day ;-)

Posted by TooManySecrets - Apr 15, 2007 | 6:35 PM

Firefox updating?

Hi, I’ve been considering FreeBSD for my home computer instead of its current Linux, mainly because from older experience I know it has a lightning-fast boot time compared to most Linux distros, and is rock-stable, but the one thing I have concerns about is Firefox and keeping it updated (for the Significant Other user of the computer, Firefox is pretty much the only app need). This is critical because Firefox, being a popular and “netward-facing” program is also becoming a popular malware target. Your article indicates there is still no convenient solution. Recompiling that mega-app regularly just won’t fly. I assumed the new FreeBSD update system in 6.2 would help here, but apparently not, so it is still Linux at my manor…

Posted by MacroRodent - Apr 17, 2007 | 8:02 AM

Re: Desktop FreeBSD Part 3: Adding Software

As a dialup user I learned a lot of tricks to download the latest versions of software using binary patches on old versions. I suggest you to try misc/xdelta… KDE uses them so you don’t have to download the whole source, but anyone could just download the new version and the old version to a computer they own at work with a faster connection and compute a xdelta… Tricks to make the compressed tarball match the original involve trying an older version of bzip2 and/or the -9 option, or with gzip try the -9 & -n options using, of course, GNU gzip since 6.2-STABLE is using a newer BSD licensed program.

Posted by Richard W. - Apr 18, 2007 | 2:01 AM

Re: Desktop FreeBSD Part 3: Adding Software

Have you ever tried Debian/kFreeBSD? I really curious on how this OS works out. Maybe I give it a try someday.

Posted by Florian Stinglmayr - Apr 29, 2007 | 9:12 PM

Re: Desktop FreeBSD Part 3: Adding Software

In reply to - MacroRodent’s - question on Firefox upgrad on FreeBSD, I would say, use portupgrade,

simply install portupgrade from FreeBSD ports, then do this from CLI:

portupgrade -vNPrR firefox

-v: verbose -N: if not installed, do new installation -P: use binary package, similar to pkg_add -r NOTE: if you want to enforce complete binary installation, use: -PP (meaning -use-packages-only) -rR: will do both forward/backword dependency upgrade, the reason is for a “mega-app”, firefox has a lot of dependencies, let FreeBSD and portupgrade sort out everything for ya.

cheers, fjordan

Posted by Ricky - May 03, 2007 | 6:04 PM

Re: Desktop FreeBSD Part 3: Adding Software

GNU/Linux is the right spelling because (as previously said by “TooManySecrets”) it’s (almost) always a combination of GNU userland and linux kernel. If you build BSD userland ontop of Linux kernel (which could be possible, but never done since you already a real BSD kernel) then you may be should call it BSD/Linux. Then there is the Debian/kFreeBSD, which using the same justification is a GNU/BSD variant. There is also of course pure GNU when using the HURD processor. There does not exist a “pure linux”, except (may be) for some “embedded” devices where they have completely wiped the GNU userland having it replaced with just a GUI (i think QTopia is another similar good example). To summarize here are some examples: GNU/Linux: Suse, Fedora, Debian, Ubuntu (and most Linux distros) GNU/Solaris: Nexenta GNU/BSD: Gentoo/kFreeBSD, Gento/kNetBSD, Debian/kFreeBSD pure BSD: FreeBSD, NetBSD, OpenBSD (and all *BSDs) pure GNU: GNU with HURD BSD/Mach: Mac OS X, Darwin, NeXT pure Linux: may be some embedded linuxes Linux/BSD: never heard of such hybrid

As you can see more and more UNIX-like OSes are hybrids between some kernel and some userland because you can’t do UNIX without neither of them, most popular hybrid being Mac OS X, followed by Linux. However since in most cases the assembly parts of hybrid UNIX-like OSes are not being build by the same team the pure ones tend to be more stable (at least according to netcraft http://uptime.netcraft.com/up/today/top.avg.html ), most notable examples being the BSDs and Solaris (followed by other UNIX vendors, and pure GNU (with HURD) being virtually nonexistent)

Posted by Anton - May 08, 2007 | 9:36 PM

Re: Desktop FreeBSD Part 3: Adding Software

Ed, thanks for the article; some bits that seem important to me: pkg_add -r is very useful indeed, and pkg_add also has -K argument which instructs the pkg_add to leave the downloaded package file rather than delete it after installing; it is also possible to manually check the url of the ftp package repository and specify the url with the pkg_add command (the location of 5.4 packages changed after the 5.5 release, pkg_add -r could not find them by default). the -K argument is mentioned in the pkg_add’s man in release 6, not in release 5; a FreeBSD package collection on DVD is also useful (the respective release).

Posted by Gleb - May 09, 2007 | 12:07 AM

Re: Desktop FreeBSD Part 3: Adding Software

Ricky suffests “portupgrade -vNPrR firefox” to my concerns about keeping complex FreeBSD internet apps updated. Fine. A bit longer than “yum update firefox” (which is what one would use on Red Hat style system these days) but reasonable. How often do such binary updates get created? Another question is what would be the equivalent of “yum update” (with no packages specified)? On those Linux distros that implement “yum”, this updates every installed package for which an update exists in the repository, keeping track of dependencies.

Posted by MacroRodent - May 09, 2007 | 11:00 AM

Re: Desktop FreeBSD Part 3: Adding Software

“Firefox updating?

Hi, I’ve been considering FreeBSD for my home computer instead of its current Linux, mainly because from older experience I know it has a lightning-fast boot time compared to most Linux distros, and is rock-stable, but the one thing I have concerns about is Firefox and keeping it updated (for the Significant Other user of the computer, Firefox is pretty much the only app need). This is critical because Firefox, being a popular and “netward-facing” program is also becoming a popular malware target. Your article indicates there is still no convenient solution. Recompiling that mega-app regularly just won’t fly. I assumed the new FreeBSD update system in 6.2 would help here, but apparently not, so it is still Linux at my manor…”

There are several answers or opinions that may answer your question. If you don’t like compiling from source you can always use an alternate package site. For reference; please check out:

http://bsdpants.blogspot.com/

Now with respect to compiling software. The ports system is going under a few changes. One change that will speed up the compile time is the use of the -j flag. Ports will be able to be built a lot quicker. Here are two projects that may be of interest:

Parallelization in the Ports Collection http://code.google.com/soc/freebsd/appinfo.html?csaid=9E93133179E28737

Revise ports / package system database backend and implement unified interface http://code.google.com/soc/freebsd/appinfo.html?csaid=AFC910638C0B5FF8

Other SOC projects can be found here; http://code.google.com/soc/freebsd/about.html

So in essence; the compile time is being addressed or you can use a different repository for your software requirments.

Regards, FreeBSD_User

Posted by FreeBSD_User - May 11, 2007 | 10:19 PM

Re: Desktop FreeBSD Part 3: Adding Software

FreeBSD, as of today, except Mac, has been mostly targeting more of those server-oriented users …

if you alias: portupgrade -NvrR as of “pu”

then just pu firefox

will get you an equivalence of: apt-get install firefox

I think it’s just as cool or better than Debian/Ubuntu/Xandros and at least than RedHat…

hehe

Posted by Ricky - May 14, 2007 | 7:34 AM

Re: Desktop FreeBSD Part 3: Adding Software

ola! Freebsd is powerfull to serve !!

Posted by Alfredo - May 29, 2007 | 12:12 AM

Re: Desktop FreeBSD Part 3: Adding Software

It is fun reading all this silly and mostly irrelevant nonsense about how to name something that is merely a tool that enables you to use your computer.

Who cares and what does it all matter? What do we matter for that matter?

Posted by Boepie - May 31, 2007 | 10:20 AM

Trackback: FreeBSD für den Desktop: Eine Anleitung

Das FreeBSD auf dem Desktop nutzbar ist wird immer noch gerne belächelt. Sicher, gerade im Multimediabereich gibt es noch einiges aufzuholen, aber mit swfdec sind nun auch die bewegten Bilder und Töne von YouTube unter FreeBSD nutzbar. Daneben gib…

Posted by grUNIX - Aug 16, 2007 | 8:06 AM