FreeBSD tips

Some tips I collected about FreeBSD.

Uninstalling a program

You can go into the ports, and uninstall it manually :

$ cd /usr/ports/myapp && make deinstall

Or you can use pkg_delete. It does not matter if you have installed a port or a package, as the final result is the same. It will also remove dependencies. However, you must either specify the application version or use wildcards :

$ pkg_delete -r myapp-2.0
$ pkg_delete -r myapp-\*

Another solution is to use pkg_rmleaves. It will present a ncurses windows, in which you will only have to select your application. Do not forget to install this utility first, in ports-mgmt/pkg_rmleaves.

New terminal in the same folder

Useful for windows manager (openbox, wmii…) where there is no tab support in the terminals. Create another instance of the terminal :

$ xterm &

Take a screen shot Use the scrot functionnality with a delay, for example 5 seconds :

$ scrot -d 5

Git colors

It is most likely you will not have colors on Git, for example in the log. This comes from a pager issue and can be corrected by placing the following in .git/config

  pager = less -r

Extract useful information from /usr/ports/UPDATING

You can use pkg_updating as described here.

Updating locate database

A very useful utility for finding quickly a file is locate. You will need to keep its database though. For that, see the following link.

Running Linux in Virtualbox from FreeBSD

First, you will need to install Virtualbox on FreeBSD and start it with Virtualbox. Then you have to install addition on the guest OS. Look in the Virtualbox menu, at Install additions. Now run:

$ sh ./runVirtualBoxLinux

If you have shared folders, mount -t vboxfs does not work. So you must mount them with (on Linux) :

$ mount.vboxfs sharedfolder folderlocation

Your folder will be available at folderlocation.

FatRat build error

If you have the following error while building the application

error: 'SA_NOMASK' was not declared in this scope

Then you only need to replace SA_NOMASK by SA_NODEFER.