FreeBSD Survival Guide

This document refers to FreeBSD 14.0.

Installation

  1. Networking under VirtualBox: use Intel Pro/1000 MT Desktop (8254OEM) network card. The inferface is available under FreeBSD as em0.

  2. Allow remote login for root by editing /etc/ssh/sshd_config:

    PermitRootLogin yes
    

    Add to /etc/rc.conf:

    sshd_enable="yes"
    

    and start SSH server:

    $ service sshd start
    

    Use bsdconfig to configure it: Configure –> Networking –> sshd.

  3. Resize virtual drive image and then resize the partition:

    $ gpart show
    $ gpart recover ada0
    $ gpart show
    $ gpart resize -i 4 ada0
    $ gpart show
    

    and finally resize the filesystem:

    $ growfs /dev/gpt/rootfs
    

Packages

  1. Install pkg command by running:

    $ pkg
    The package management tool is not yet installed on your system.
    Do you want to fetch and install it now? [y/N]: y
    
  2. Info about installed packages:

    $ pkg info
    $ pkg info vim
    $ pkg info -l vim
    
  3. Search for packages:

    $ pkg search vim
    
  4. Update remote repository cache:

    $ pkg update
    
  5. Install a package:

    $ pkg install vim
    
  6. Upgrade packages:

    $ pkg upgrade
    
  7. Remove unneeded packages:

    $ pkg delete vim
    $ pkg autoremove
    

Administration

System settings

  1. The main settings are stored in /etc/rc.conf file which consists of parameters listed in /etc/defaults/rc.conf. See rc.conf(5) for more details.

  2. The main administration tool is bsdconfig.

  3. To access the CD-ROM:

    $ mount -t cd9660 /dev/cd0 /mnt
    
  4. Install bash and set it as a default shell for root using chsh.

  5. Networking: add to /etc/rc.conf:

    ifconfig_DEFAULT="DHCP accept_rtadv"
    

    to activate DHCP for em0 interface.

Console

  1. History is available after pressing ScrollLock.

  2. Polish keybord/fonts: add to /etc/rc.conf:

    font8x8="iso02-8x8"
    font8x14="iso02-8x14"
    font8x16="iso02-8x16"
    keymap="pl"
    

    Next, add to /etc/login.conf to the default section:

    default:\
            ...
            :charset=UTF-8:\
            :lang=en_US.UTF-8:
    

    Finally run:

    $ cap_mkdb /etc/login.conf
    
  3. Mouse in text mode: add to /etc/rc.conf:

    moused_enable="YES"
    

Kernel modules

  1. List of modules:

    $ kldstat
    
  2. Automatic loading of modules: edit /boot/loader.conf:

    linux_load="YES"
    

FB as VirtualBox guest

  1. Install:

    $ pkg install virtualbox-ose-additions
    
  2. Add to /etc/rc.conf:

    vboxguest_enable="YES"
    vboxservice_enable="YES"
    

Users management

  1. Add user to a group:

    $ pw groupmod wheel -m voytek
    

Networking

  1. Restart:

    $ service netif restart
    $ service routing restart
    
  2. Start/stop a single interface:

    $ ifconfig eth0 down
    $ ifconfig eth0 up
    
  3. Alias:

    $ ifconfig em0 192.168.1.2/24 alias
    $ ifconfig em0 192.168.1.2/24 -alias
    
  4. Show routing:

    $ netstat -r -4
    $ route add -net 192.168.2.0/24 192.168.0.1
    
  5. Show network services listening on ports:

    $ sockstat -4 -l
    

Resources

  1. FreeBSD Handbook. Available at https://www.freebsd.org/doc/handbook/.

  2. Wikipedia entry for FreeBSD: http://en.wikipedia.org/wiki/FreeBSD.