FreeBSD Tips


This page contains miscellaneous FreeBSD tips that might be useful. Please see the official FreeBSD Documentation for more information.

Use these tips at your own responsibility.

Misc short tips

Install and use sysutils/portupgrade/ to keep your ports up-to-date.

FreshPorts a nice site to get information about FreeBSD ports.

Danish BSD FAQ

Nice stuff for /etc/make.conf

# Start by downloading from a Danish mirror

# Make FreeBSD start getting distfiles (source for ports) from local
# freebsd mirror

# Try mirrors close to Denmark first.
MASTER_SORT?=	.dk .se .no .de \
	.uk .at .nl

# Make it possible to update source and ports by just running make update
# in /usr/src and /usr/ports
SUP_UPDATE=     yes
SUP=            /usr/local/bin/cvsup
SUPFLAGS=       -g -L 2
SUPHOST= # Change to your local cvsup mirror
SUPFILE=        /usr/share/examples/cvsup/standard-supfile
PORTSSUPFILE=   /usr/share/examples/cvsup/ports-supfile

# For servers, tell ports not to compile X11 support if possible
WITHOUT_X11=	yes

Update ports

Quick command for update of local ports collection (wont update the programs just the ports collection in /usr/ports).

cvsup -L 2 -g -h /usr/share/examples/cvsup/ports-supfile

Note: If you don not have cvsup installed, it can be installed with:

pkg_add -r cvsup-without-gui

Get Danish characters

It can be done in (at least) two ways :

Note: You might need to login again / restart X to make the change active.

Per user

Add to ~/.login_conf:


System wide

Add to /etc/login.conf:

danish:Danish Users Accounts:\


cap_mkdb /etc/login.conf
pw usermod <your username> -L danish

English program texts

If you dont want your programs to start using Danish add the following to your ~/.tcshrc:

setenv LC_MESSAGES en_US.ISO8859-1

or if you use bash add the following to your ~/.bashrc:


Note: For some older versions of FreeBSD it might be needed to use da_DK.ISO_8859-1 instead of da_DK.ISO8859-1.


sudo (ports/security/sudo/) is a nice program to run root only things as non root users. Here are some lines from my sudoers (the sudo config) file:

simon  ALL=NOPASSWD:/sbin/mount /mnt/cdrom,/sbin/umount /mnt/cdrom
simon  ALL=NOPASSWD:/usr/sbin/cdcontrol -f /dev/acd0c eject

This can be used with the following lines in your ~/.tcshrc file to make it really easy:

alias mntcd 'sudo mount /mnt/cdrom'
alias umntcd 'sudo umount /mnt/cdrom'
alias ejectcd 'sudo cdcontrol -f /dev/acd0c eject'

Serial console

To force serial console put -H in /boot.config, or to only use serial console if no keyboard is pressent when booting, put -P in /boot.config.

Get FreeBSD version of /usr/src

grep -E 'BRANCH|REVISION' /usr/src/sys/conf/

Count the total size of a ls -l output

cat /tmp/1 | awk 'BEGIN{c=0} {c+=$2; print $2} END{print "Sum = ", c, "B", c/1024/1024/1024, "GB"}'

Make gdb stop paging

set height 0

Make gdb display full strings

set print elements 0

Make gdb pretty print variables

set print pretty on