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.
Nice stuff for /etc/make.conf
# Start by downloading from a Danish mirror
MASTER_SITE_BACKUP?= \
ftp://ftp.dk.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
# Make FreeBSD start getting distfiles (source for ports) from local
# freebsd mirror
MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
# Try mirrors close to Denmark first.
MASTER_SORT?= .dk sunet.se .se dk.php.net .no .de mirrorservice.org \
.uk .at heanet.dl.sourceforge.net .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= cvsup.dk.freebsd.org # 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 cvsup.dk.freebsd.org /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:
me:\
:charset=iso-8859-1:\
:lang=da_DK.ISO8859-1:
System wide
Add to /etc/login.conf:
danish:Danish Users Accounts:\
:charset=ISO-8859-1:\
:lang=da_DK.ISO8859-1:\
:tc=default:
Run:
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:
LC_MESSAGES=en_US.ISO8859-1; export LC_MESSAGES
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
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/newvers.sh
NTP
A list of danish/nordic NTP servers:
- ntp.cybercity.dk
- ntp1.inet.tele.dk
- ntp2.inet.tele.dk
- ntp.worldonline.dk
- ntp.forskningsnettet.dk
- ntp1.uni2.dk
- ntp2.uni2.dk
- ntp3.uni2.dk
- gps.dix.dk
- ntp1.tele.dk
- ntp2.tele.dk
- ntp1.mmo.netnod.se
- ntp2.mmo.netnod.se
More can be found at http://ntp.isc.org/bin/view/Servers/WebHome.
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