Tag Archive : freebsd

/ freebsd

Guide for FreeBSD Ports Collection

December 5, 2015 | Article | 7 Comments

Compared to another Operating System such as Linux and Windows; FreeBSD has different and unique package management schemes. The Ports Collection, can be found under /usr/ports, contains the Makefiles for a vast amount of software available to configure and compile.

Unlike package management such as apt, yum, yast, and other package management for linux which download the compiled-binary file, ports collection let you download the source code, configure in your way, and compile it. You just configure some aspects before compilation begin and Ports will do the rest for you. You don’t need to worry about dependency, the Ports will take it for you.

In this article we will discuss about how to use Ports Collection: install, find, and remove.

Getting the ports collection

If you did not choose to install the ports collection during the FreeBSD installation then you will need to get it through CVSup. Do install CVSup with pkg_add command (as you don’t have Ports Collection yet) by

pkg_add -r cvsup-without-gui

Make sure you have empty /usr/ports if you run CVSup for first time. And then run CVSup for downloading the ports as described at previous articles.

Another alternative would be using portsnap. Do installation of portsnap by

pkg_add -r portsnap

Now, download / fetch the compressed snapshot to /var/db.

portsnap fetch

If you are running portsnap for first time, then extract the snapshot info to /usr/ports.

portsnap extract

If you have already populate /usr/ports then you need only update it.

portsnap update

If you don’t have enough time to manually download ports collection (or other reason which make you can’t download) and have FreeBSD installer CD, you can use the CD to install ports. Make sure you have the correct version before you proceed. Insert the CD and then enter the following commands:

mount /cdrom
cd /cdrom/`uname -r`/ports

Finding a Port

FreeBSD provides so many software and classified it to some categories such as net, www, database, security, etc. With so many ports it can be hard to find the one we are looking for. The easiest way to find a port is to use the ports directory on the FreeBSD website.

To search locally on our machine we can use the locate command if you know a word in the name of the package

locate <package> | grep distinfo

The “grep distinfo” filters out other files in the port directory so each port that comes up is only shown once.

Another method to find a package:

cd /usr/ports
make search name=postfix

That command will return a list of all ports that have “postfix” i the name, including some other useful infos. If you need to dig deeper, use “key” instead of “name”

cd /usr/ports
make search key=spam

This searches all COMMENT fields of the ports “pkg-description” files and returns the same info as with the “name” search. Make sure to use quotes if you want make more specific searches:

cd /usr/ports
make search key="spam filter"

Files in the port directories


– This is the main file that tells where the files for the port are located and the options to build with. If you wish to install the port with certain options it is a good idea to look through this file and see what is available.


– Gives the version number of the package


– This is displayed after the port is installed giving information on how to finish setting it up, or security warnings. If you get the port installed and can’t figure out how to start it, or where the config files are you should look back at the message.


– A list of files in the package.

Installing a port

To install a port change to its directory and do a “make install”. For example, if we were to install the database server mysql 5.5 it would look like this

cd /usr/ports/database/mysql55-server
make install

To delete the tar file that was downloaded to install mysql once the install was complete simply append the command “distclean” after install like this

cd /usr/ports/database/mysql55-server
make install distclean

To clean out compiled files from the make use “make clean” in the port’s directory

make clean

If you wished to uninstall mysql you could do so with the following

cd /usr/ports/database/mysql55-server
make deinstall

Many ports give a menu during the install asking you to choose certain options. If you wish to skip these menus “all” may be appended after “make install” to install the port more forcefully

make install all

Thus you are going to install default configuration for that ports.

Removing a saved configuration

Ports that give a menu with installation options after starting the make save your choices and this saved config needs to be manually removed if you want to rebuild the port later and want different options. To delete a saved config go to port’s directory and run

make rmconfig

Viewing installed packages and removing them

A list of all installed packages on the machine can be viewed with “pkg_info”


Deleting a package can be done with “pkg_delete” listed by pkg_info above.

pkg_delete -f <package name>

The -f flag forces the package to be deinstalled even if other packages depend on it.

Cleaning up the ports

FreeBSD saves all files downloaded to install the ports to /usr/ports/distfiles. This is useful when you want to do reinstallation as you don’t need to waste your bandwidth and FreeBSD will pick the appropriate package from /usr/ports/distfiles. But if you don’t have much free space, you can clean the distfiles by simply delete it contents.

rm -r /usr/ports/distfiles/*

The above command will removes all of these files, but not the files created during the build. To get rid of these you must run

portsclean -CD

The -CD flags will remove all files in the work directories within the ports tree and any unreferenced distfiles.

Upgrading a port

A port can be upgraded with the port /usr/ports/ports-mgmt/portupgrade

portupgrade <package name>

Using Mirror Repository for FreeBSD

December 5, 2015 | Article | No Comments

Mirror is a server outside of official server which acts as duplicate of official server. Generally mirror utilizing a backup server that duplicates all the processes and transactions of the primary server which gives very identical content.

Choosing the nearest mirror can speed up the transfer process and thus very recommended.

In this case, mirror repository is a mirror of FreeBSD.org which provides binary, source, etc for upgrade and installation of package. In FreeBSD There are two method for installing an application: through ports collection (source), and through binary installation.

In this article we will discuss about how to use mirror repository for installation via ports or pkg_add for FreeBSD. In this case I use ITB server as my mirror repository. The url will be ftp.itb.ac.id. This might be different from you as your nearest mirror might be something else.

Also my machine would be FreeBSD 8.3 for amd64.

Using Port Collections

Edit /etc/make.conf and append this to the end of file:


Using PKG_ADD facility

To use pkg_add, we need to set environment variable PACKAGEROOT to point to our mirror server. There are two approach: using command line and editing .cshrc. To use command line, just invoke this command:

export PACKAGEROOT=ftp://ftp.itb.ac.id

But with this approach, we need to recommand everytime we want to install package via pkg_add. Another approach is editing .cshrc and which located at home directory and append the above command at the end of file.

Fluxbox is an extremely lightweight Window Manager for X.org. Based on BlackBox but has several extra features built in.

In this article we will discuss the basics of FluxBox installation and configure it, including setting a style, configuring menu, and save & backup settings.

For this article I use:

  1. FreeBSD 8.3 amd64
  2. X.org

Before you proceed, make sure you have install X.org.

Installing Fluxbox

Fluxbox installation is quite straightforward and can be done like other ports installation. Use these commands to do so:.

cd /usr/ports/x11-wm/fluxbox
make install clean

Once the installation is complete, add the following to the end of your .xinitrc (~/.xinitrc) file.

exec fluxbox

Remember that it must be the last command run on your .xinitrc

Starting the Fluxbox

Fluxbox is a stacking window manager. It has only a taskbar, a pop-up menu accessible by right clicking the desktop, and minimal support for graphical icons. There is no familiar “start-button”. All menu is accessible at right click, including application, utility, and also settings.

Creating Menu

Menus on FluxBox follows this format:

[submenu] (MENU NAME)

An example of a menu for terminals with eterm and wterm would have these in the fluxbox menu (~/.fluxbox/menu)

[exec] (Wterm Blue) {wterm -bg blue -fg white -tr -sh}
[exec] (Wterm Green) {wterm -bg green -fg white -tr -sh}
[exec] (Wterm Red) {wterm -bg red -fg white -tr -sh}
[exec] (Wterm Orange) {wterm -bg orange -fg white -tr -sh}
[exec] (Wterm Clear) {wterm -fg white -tr}

[exec] (Eterm 20 Purple) {Eterm --buttonbar=0 --trans
--shade=20 --tint=purple -v -f white}
[exec] (Eterm 20 Gray) {Eterm --buttonbar=0 --trans
--shade=20 -v -f white}
[exec] (Eterm 60 Gray) {Eterm --buttonbar=0 --trans
--shade=60 -v -f white}
[exec] (Eterm 60 Blue) {Eterm --buttonbar=0 --trans
--shade=60 --tint=blue -v -f white}
[exec] (Eterm Clear) {Eterm --buttonbar=0 --trans
-v -f white}


X.org Setup for FreeBSD

December 5, 2015 | Article | 2 Comments

X.Org is an open source project which aim to provides implementation of the X Window System. The development work is being done in conjuction with the freedesktop.org community. The product, X11, is widely used in some operating system such as Linux and FreeBSD.

In this article we will discuss about how to setting up X.org to present Graphical User Interface experience on FreeBSD machine. For this article I use FreeBSD 8.3 for amd64 architecture (x86_64)

Pre Installation

It is a good idea to run CVSup to get the latest version of the port. To do CVSup, you can read this article. But if you feel update is not necessary, then you can proceed to next stage.


An installation to X.org is straightforward like other FreeBSD ports. You can invoke following commands to do installation:

cd /usr/ports/x11/xorg
make install clean

The process will take awhile (depending on the speed of machine), so grabbing snacks and drinks is recommended 😉


Once the installation finished, then comes configuration time. The best way to do this is using X.org config script and run it with root privileges.


Things you need to know:

Mouse Protocol – protocol for interact with your mouse. If you don’t know this, then choose either Auto or Sysmouse and in most case it will works.

Emulate 3 Button Protocol – If you have a 3 button mouse, or a mouse with a wheel (counts as a 3rd button). It allows us to paste text with 3rd button. If you choose no, the 3rd button can be represented by both button (left and right).

Mouse Device – Your mouse device, usually /dev/sysmouse. If your mouse is not it, then enter your device name.

Keyboard – Your keyboard

XKB – X11 Keyboard extension. Well it means you can create your custom keyboard layout, but in this case choose no.

Monitor – Most important parts. Please read carefully the specification of your monitor and make sure you give the right commands. Some monitor will tell us hsync and vsync under their menu. Another things to look for is the color depth.

Video card – Your video cards. If you have proprietary video, make sure you have install the driver provided by the vendor.

Video memory – Using unit KB (KiloBytes which you need to multiply by 1024 for MB and multiply it again with 1024 for GB). Normally this is just hashed out in the X.org config file so it is not of high importance to get it right.

Resolutions – Choose some resolutions that are suitable for your display.

Once it finished, it will write the file to /etc/X11/xorg.conf

In some system, X11 can be configured by invoking this command:


Instead of xorgconfig like told before.

Setting up Touch Pad

If you have Touch Pad, then you might also want to configure it. You can follow similar guideline here for Synaptic on Lenovo z480.

Starting Up

You can try invoking command startx to start the X11. If there is no problem then you can see your desktop now. Well, it’s still a simple interface provided by X11. If you want to install rich desktop interface then you can choose one of these:

  • Desktop Environtment
    1. Gnome
    2. KDE
    3. XFCE
  • Window Manager
    1. Fluxbox

If you have more than 1 Desktop Environment or Window Manager, you can also run one at a time. To select what DE / WM you want to run, you can run xwmconfig and then pick one you like.

When X11 is running, the X11 or X.org will create an initialization script called .xinitrc. The file is on ~/.xinitrc (~ is the current user home directory). And please note the “.” (dot) character in front of the filename which is also parth of the name.

To stop the X.org, press ctrl + alt + backspace simultaneously.

Launching Programs on Startup using ~/.xinitrc

.xinitrc is run whenever X.org starts up. Thus it can be a good place to put everything we want to load at startup regardless of DE and WM. For example you can use it to be something like this:

exec yourapp &

All programs being launched need an & after them so they will run in the background, the window manager however does not. Any program can be added to this file.

Social media & sharing icons powered by UltimatelySocial