FreeBSD Handbook — títulos y todos los comandos
Escuchar este artículo
Leer en voz alta (navegador)
FreeBSD Handbook — títulos y comandos
Extraído del FreeBSD Handbook oficial (fuente AsciiDoc en inglés, edición 2026). Se han eliminado todas las explicaciones y las salidas de pantalla; solo quedan los títulos de sección y los comandos.
Nota: la traducción oficial al español está muy desactualizada (menciona FreeBSD 4.x/8.x, sysinstall, cvsup y no incluye ZFS, bhyve ni pkg moderno), por lo que los comandos se han extraído de la edición inglesa vigente. Los títulos se mantienen en inglés para que coincidan con el manual y con man.
Fuente: https://docs.freebsd.org/en/books/handbook/ · PDF: https://download.freebsd.org/doc/en/books/handbook/handbook_en.pdf
Comandos por sección
Preface
Preface > Conventions used in this book > Examples
dd if=kern.flp of=/dev/fd0
top
Introduction
Introduction > About the FreeBSD Project > Third Party Programs
make install
pkg install
Introduction > About the FreeBSD Project > Additional Documentation
pkg install en-freebsd-doc
Installing FreeBSD
Installing FreeBSD > Pre-Installation Tasks > Prepare the Installation Media
sha256sum -c CHECKSUM.SHA256-FreeBSD-15.1-RELEASE-amd64 --ignore-missing
Installing FreeBSD > Pre-Installation Tasks > Prepare the Installation Media > Writing an Image File to USB
dd if=FreeBSD-15.1-RELEASE-amd64-memstick.img of=/dev/da0 bs=1M conv=sync
Installing FreeBSD > Using bsdinstall > Selecting Installation Type
pkg upgrade
Installing FreeBSD > Network Interfaces, Accounts, Time Zone, Services and Hardening > Final Configuration
shutdown -p now
Installing FreeBSD > Troubleshooting
set hint.acpi.0.disabled="1"
FreeBSD Basics
FreeBSD Basics > Virtual Consoles and Terminals > Changing Console Video Modes
kldload vesa
vidcontrol -i mode
vidcontrol MODE_279
FreeBSD Basics > Users and Basic Account Management > Account Types > The Superuser Account
make install
configure
make
su -
exit
FreeBSD Basics > Users and Basic Account Management > Managing Accounts > Adding a user
adduser
FreeBSD Basics > Users and Basic Account Management > Managing Accounts > Removing a user
rmuser jru
FreeBSD Basics > Users and Basic Account Management > Managing Accounts > Change user information
chpass jru
FreeBSD Basics > Users and Basic Account Management > Managing Accounts > Change user password
passwd
passwd jru
FreeBSD Basics > Users and Basic Account Management > Managing Groups
pw groupadd teamtwo
pw groupshow teamtwo
pw groupmod teamtwo -M jru
pw groupmod teamtwo -m db
id jru
FreeBSD Basics > Permissions
ls -l
FreeBSD Basics > Permissions > Symbolic Permissions
chmod go= FILE
chmod go-w,a+x FILE
FreeBSD Basics > Permissions > FreeBSD File Flags
chflags sunlink file1
chflags nosunlink file1
ls -lo file1
FreeBSD Basics > Permissions > The setuid, setgid, and sticky Permissions
chmod u+s suidexample.sh
chmod 4755 suidexample.sh
ps aux | grep passwd
chmod g+s sgidexample.sh
chmod 2755 sgidexample.sh
chmod +t /tmp
chmod 1777 /tmp
ls -al / | grep tmp
FreeBSD Basics > Mounting and Unmounting File Systems > Using mount
mount device mountpoint
FreeBSD Basics > Processes and Daemons > Viewing Processes
ps
top
FreeBSD Basics > Shells
rm foo
setenv EDITOR /usr/local/bin/emacs
export EDITOR="/usr/local/bin/emacs"
echo $TERM
echo *
echo \$TERM
FreeBSD Basics > Shells > Changing the Shell
chsh -s
chsh -s /usr/local/bin/bash
echo /usr/local/bin/bash >> /etc/shells
FreeBSD Basics > Shells > Advanced Shell Techniques
ls > directory_listing.txt
sort < directory_listing.txt
sort < directory_listing.txt > sorted.txt
cat directory_listing.txt | sort | less
FreeBSD Basics > Text Editors
ee _filename_
FreeBSD Basics > Manual Pages
man command
man ls
man 1 chmod
man -k
man -k mail
cd /usr/sbin
man -f * | more
whatis * |more
FreeBSD Basics > Manual Pages > GNU Info Files
info
Installing Applications: Packages and Ports
Installing Applications: Packages and Ports > Overview of Software Installation
pkg install
pkg audit -F
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Getting Started with pkg
pkg
pkg -N
pkg install
pkg help install
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Quarterly and Latest Ports Branches
mkdir -p /usr/local/etc/pkg/repos
echo 'FreeBSD-ports: { url: "pkg+https://pkg.FreeBSD.org/${ABI}/latest" }' > /usr/local/etc/pkg/repos/FreeBSD.conf
pkg update -f
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Searching Packages
pkg search nginx
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Installing and Fetching Packages
pkg install curl
pkg info
pkg fetch -d -o /usr/home/user/packages/ nginx-lite
cd /usr/home/user/packages/
pkg install nginx-lite-1.22.1,3.pkg
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Obtaining Information About Installed Packages
pkg info pkg
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Upgrading Installed Packages
pkg upgrade
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Auditing Installed Packages
pkg audit -F
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Removing Packages
pkg delete curl
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Automatically Removing Unused Packages
pkg autoremove
pkg prime-list
pkg prime-origins
pkg set -A 1 devel/cmake
pkg set -A 0 devel/cmake
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Removing Stale Packages
pkg clean
pkg clean -a
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Locking and Unlocking Packages
pkg lock nginx-lite
pkg unlock nginx-lite
Installing Applications: Packages and Ports > Using pkg for Binary Package Management > Modifying Package Metadata
pkg set -o lang/python3:lang/python311
pkg set -o lang/ruby31:lang/ruby32
pkg install -Rf lang/ruby32
Installing Applications: Packages and Ports > Using the Ports Collection > Installing the Ports Collection
cd /usr/ports/devel/git
make install clean
pkg install git
git clone --depth 1 https://git.FreeBSD.org/ports.git /usr/ports
git clone --depth 1 https://git.FreeBSD.org/ports.git -b 2023Q1 /usr/ports
git -C /usr/ports pull
git -C /usr/ports fetch --depth 1 origin 2023Q2:2023Q2
git -C /usr/ports switch 2023Q2
Installing Applications: Packages and Ports > Using the Ports Collection > Installing Ports
pkg audit -F
make install
cd /usr/ports/sysutils/lsof
/usr/local/sbin/lsof
make clean
make install clean
Installing Applications: Packages and Ports > Using the Ports Collection > Installing Ports > Customizing Ports Installation
make config-recursive
make install [clean]
make config
make showconfig
make rmconfig
make fetch
make fetch-recursive
cd /usr/ports/directory
make MASTER_SITE_OVERRIDE= \
make WRKDIRPREFIX=/usr/home/example/ports install
make PREFIX=/usr/home/example/local install
make WRKDIRPREFIX=../ports PREFIX=../local install
Installing Applications: Packages and Ports > Using the Ports Collection > Removing Installed Ports
pkg delete
make deinstall
cd /usr/ports/sysutils/lsof
Installing Applications: Packages and Ports > Using the Ports Collection > Upgrading Ports
pkg version -l "<"
Installing Applications: Packages and Ports > Using the Ports Collection > Upgrading Ports > Upgrading Ports Using Portmaster
cd /usr/ports/ports-mgmt/portmaster
make install clean
portmaster -L
portmaster -a
portmaster -af
portmaster shells/bash
Installing Applications: Packages and Ports > Using the Ports Collection > Upgrading Ports > Upgrading Ports Using Portupgrade
cd /usr/ports/ports-mgmt/portupgrade
make install clean
portupgrade -a
portupgrade -ai
portupgrade _pkgname_
portupgrade -R firefox
portupgrade -PP gnome3
Installing Applications: Packages and Ports > Using the Ports Collection > Ports and Disk Space
make clean
portsclean -C
portsclean -D
portsclean -DD
portmaster --clean-distfiles
Installing Applications: Packages and Ports > Building Packages with poudriere > Initialize Jails and Port Trees
poudriere jail -c -j 13amd64 -v 13.1-RELEASE
/poudriere/jails/13amd64/fromftp/base.txz 125 MB 4110 kBps 31s
/poudriere/jails/13amd64/fromftp/src.txz 154 MB 4178 kBps 38s
/poudriere/jails/13amd64/fromftp/lib32.txz 24 MB 3969 kBps 06s
/usr/src/contrib/unbound/.github
/usr/src/contrib/unbound/.github/FUNDING.yml
/usr/src/contrib/unbound/contrib/drop2rpz
/usr/src/contrib/unbound/contrib/unbound_portable.service.in
/usr/src/contrib/unbound/services/rpz.c
/usr/src/contrib/unbound/services/rpz.h
/usr/src/lib/libc/tests/gen/spawnp_enoexec.sh
poudriere ports -c -p local -m git+https
poudriere options -j 13amd64 -p local -z workstation -f 13amd64-local-workstation-pkglist
poudriere bulk -j 13amd64 -p local -z workstation -f 13amd64-local-workstation-pkglist
Installing Applications: Packages and Ports > Post-Installation Considerations
pkg info
Installing Applications: Packages and Ports > Dealing with Broken Ports
make maintainer
The X Window System
The X Window System > Graphics Drivers
pciconf -lv | grep -B3 display
sysctl machdep.bootmethod
The X Window System > Graphics Drivers > Intel(R) Graphics
pkg install drm-kmod
sysrc kld_list+=i915kms
The X Window System > Graphics Drivers > AMD(R) Graphics
pkg install drm-kmod
sysrc kld_list+=amdgpu
sysrc kld_list+=radeonkms
The X Window System > Graphics Drivers > NVIDIA(R) Graphics
pkg install nvidia-drm-kmod
sysrc kld_list+=nvidia-drm
sysrc kld_list+=nvidia-modeset
sysrc kld_list+=nvidia
The X Window System > Installing The X.org Server
pkg install xorg
pw groupmod video -m username
The X Window System > X.org Configuration > Graphics Configuration
pciconf -lv | grep -B3 display
The X Window System > X.org Configuration > Monitor Configuration > Using RandR (Resize and Rotate)
xrandr
xrandr --output LVDS-1 --mode 1280x720 --rate 60
xrandr --auto
The X Window System > X.org Configuration > Input Configuration > Using Atomic Input Configuration
xinput
The X Window System > Using Fonts in the X Window System
fc-cache
The X Window System > Using Fonts in the X Window System > TrueType(R) Fonts
pkg install mkfontscale
cd /usr/local/share/fonts/TrueType
mkfontscale
xset fp+ /usr/local/share/fonts/TrueType
xset fp rehash
The X Window System > Using Fonts in the X Window System > Type1 Fonts
pkg install urwfonts
xset fp+ /usr/local/share/fonts/urwfonts
xset fp rehash
The X Window System > Using Fonts in the X Window System > Anti-Aliased Fonts
fc-cache -f
Wayland on FreeBSD
Wayland on FreeBSD > Wayland Overview
pw groupmod video -m user
pkg install wayland seatd
export XDG_RUNTIME_DIR=/var/run/user/id -u
mount -t tmpfs tmpfs /var/run
sysrc seatd_enable="YES"
service seatd start
Wayland on FreeBSD > The Wayfire Compositor
pkg install wayfire wf-shell alacritty swaylock-effects swayidle wlogout kanshi mako wlsunset
mkdir ~/.config/wayfire
cp /usr/local/share/examples/wayfire/wayfire.ini ~/.config/wayfire
swaylock --effect-blur 7x5
wayfire -c ~/.config/wayfire/wayfire.ini
wcm
Wayland on FreeBSD > The Hikari Compositor
pkg install hikari alacritty
mkdir ~/.config/hikari
cp /usr/local/etc/hikari/hikari.conf ~/.config/hikari
hikari -c ~/.config/hikari/hikari.conf
Wayland on FreeBSD > The Sway Compositor
pkg install sway swayidle swaylock-effects alacritty dmenu-wayland dmenu
mkdir ~/.config/sway
cp /usr/local/etc/sway/config ~/.config/sway
sway -c ~/.config/sway/config
Wayland on FreeBSD > Using Xwayland
pkg install xwayland
env | grep DISPLAY
sockstat | grep x11
Xwayland
export DISPLAY=:0
Wayland on FreeBSD > Remote Desktop Using VNC
pkg install wayvnc
wayvnc -C ~/.config/wayvnc/config
Wayland on FreeBSD > Wayland Login Manager
pkg install ly
Wayland on FreeBSD > Useful Utilities
pkg install pavucontrol waybar
mkdir ~/.config/waybar
cp /usr/local/etc/xdg/waybar/config ~/.config/waybar
mkdir ~/.config/lavalauncher
Network
Network > Setting up the Network > Identify Network Adapters
pciconf -lv | grep -A1 -B3 network
kldload if_alc
Network > Wired Networks
ifconfig
Network > Wired Networks > Configuring Static IPv4 Address
ifconfig em0 inet 192.168.1.150/24
sysrc ifconfig_em0="inet 192.168.1.150 netmask 255.255.255.0"
sysrc defaultrouter="192.168.1.1"
service netif restart && service routing restart
ping -c2 www.FreeBSD.org
Network > Wired Networks > Configuring Dynamic IPv4 Address
sysrc ifconfig_em0="DHCP"
dhclient em0
sysrc background_dhclient="YES"
service netif restart
ping -c2 www.FreeBSD.org
Network > Wired Networks > IPv6
ifconfig
Network > Wired Networks > Configuring Static IPv6 Address
sysrc ifconfig_em0_ipv6="inet6 2001:db8:4672:6565:2026:5043:2d42:5344 prefixlen 64"
sysrc ipv6_defaultrouter="2001:db8:4672:6565::1"
sysrc ifconfig_em0_alias0="inet6 2001:db8:4672:6565::a anycast"
Network > Wired Networks > Configuring Dynamic IPv6 Address
sysrc ifconfig_em0_ipv6="inet6 accept_rtadv"
sysrc rtsold_enable="YES"
Network > Wired Networks > Router Advertisement and Host Auto Configuration
sysrc rtadvd_enable="YES"
sysrc rtadvd_interfaces="em0"
Network > Wired Networks > IPv6 and IPv4 Address mapping
sysrc ipv6_ipv4mapping="YES"
Network > Wireless Networks > Quick Start to Connect to a Wireless Network
sysctl net.wlan.devices
sysrc wlans_iwm0="wlan0"
sysrc ifconfig_wlan0="WPA DHCP"
service netif restart
Network > Wireless Networks > Basic Wireless Configuration
ifconfig wlan0 create wlandev iwm0
sysrc wlans_iwm0="wlan0"
ifconfig wlan0 regdomain etsi2 country AT
sysrc create_args_wlan0="country AT regdomain etsi2"
Network > Wireless Networks > Scan Wireless Networks
ifconfig wlan0 up list scan
Network > Wireless Networks > Connection and Authentication to a Wireless Network > Authenticate with WPA2/WPA/Personal
sysrc ifconfig_wlan0="inet 192.168.1.20 netmask 255.255.255.0"
sysrc ifconfig_wlan0="WPA DHCP"
service netif restart
Network > Wireless Networks > Connection and Authentication to a Wireless Network > Authenticate with Open Networks
ifconfig wlan0 ssid SSID
dhclient wlan0
Network > Hostname > Check The Current Hostname
hostname
Network > Hostname > Change Hostname
sysrc hostname="freebsdhostname.example.com"
Network > DNS > Configuring the Nameserver
sysrc local_unbound_enable="YES"
service local_unbound start
Network > Troubleshooting > Troubleshooting in Wired Networks
netstat -rn
Desktop Environments
Desktop Environments > Desktop Environments > Plasma > Install Plasma meta package
pkg install kde
pkg search -S origin kde-applications
Desktop Environments > Desktop Environments > Plasma > Minimal Plasma installation
pkg install plasma6-plasma
pkg install konsole
Desktop Environments > Desktop Environments > Plasma > Configure Plasma
sysrc dbus_enable="YES"
Desktop Environments > Desktop Environments > Plasma > Start Plasma
pkg install sddm
sysrc sddm_enable="YES"
sysrc sddm_lang="es_ES"
echo "exec dbus-launch --exit-with-x11 ck-launch-session startplasma-x11" > ~/.xinitrc
exec dbus-launch ck-launch-session startplasma-wayland
Desktop Environments > Desktop Environments > GNOME > Install GNOME meta package
pkg install gnome
Desktop Environments > Desktop Environments > GNOME > Minimal GNOME installation
pkg install gnome-lite
Desktop Environments > Desktop Environments > GNOME > Configure GNOME
sysrc dbus_enable="YES"
Desktop Environments > Desktop Environments > GNOME > Start GNOME
sysrc gdm_enable="YES"
echo "exec gnome-session" > ~/.xinitrc
Desktop Environments > Desktop Environments > XFCE > Install XFCE
pkg install xfce
Desktop Environments > Desktop Environments > XFCE > Configure XFCE
sysrc dbus_enable="YES"
Desktop Environments > Desktop Environments > XFCE > Start XFCE
pkg install lightdm lightdm-gtk-greeter
sysrc lightdm_enable="YES"
echo '. /usr/local/etc/xdg/xfce4/xinitrc' > ~/.xinitrc
Desktop Environments > Desktop Environments > MATE > Install MATE meta package
pkg install mate
Desktop Environments > Desktop Environments > MATE > Minimal MATE installation
pkg install mate-base
Desktop Environments > Desktop Environments > MATE > Configure MATE
sysrc dbus_enable="YES"
Desktop Environments > Desktop Environments > MATE > Start MATE
pkg install lightdm lightdm-gtk-greeter
sysrc lightdm_enable="YES"
echo "exec dbus-launch --exit-with-x11 ck-launch-session mate-session" > ~/.xinitrc
Desktop Environments > Desktop Environments > Cinnamon > Install Cinnamon
pkg install cinnamon
Desktop Environments > Desktop Environments > Cinnamon > Configure Cinnamon
sysrc dbus_enable="YES"
Desktop Environments > Desktop Environments > Cinnamon > Start Cinnamon
pkg install lightdm lightdm-gtk-greeter
sysrc lightdm_enable="YES"
echo "exec dbus-launch --exit-with-x11 ck-launch-session cinnamon-session" > ~/.xinitrc
Desktop Environments > Desktop Environments > LXQT > Install LXQT
pkg install lxqt
Desktop Environments > Desktop Environments > LXQT > Configure LXQT
sysrc dbus_enable="YES"
Desktop Environments > Desktop Environments > LXQT > Start LXQT
pkg install sddm
sysrc sddm_enable="YES"
sysrc sddm_lang="es_ES"
echo "exec dbus-launch --exit-with-x11 ck-launch-session startlxqt" > ~/.xinitrc
Desktop Environments > Browsers > Firefox
pkg install firefox
pkg install firefox-esr
Desktop Environments > Browsers > Chromium
pkg install chromium
Desktop Environments > Browsers > Iridium browser
pkg install iridium-browser
Desktop Environments > Browsers > Falkon
pkg install falkon
Desktop Environments > Browsers > Konqueror
pkg install konqueror
Desktop Environments > Browsers > Gnome Web (Epiphany)
pkg install epiphany
Desktop Environments > Browsers > qutebrowser
pkg install qutebrowser
Desktop Environments > Browsers > Dillo
pkg install dillo
Desktop Environments > Browsers > Links
pkg install links
Desktop Environments > Browsers > w3m
pkg install w3m
Desktop Environments > Development tools > Visual Studio Code
pkg install vscode
Desktop Environments > Development tools > Qt Creator
pkg install qtcreator
Desktop Environments > Development tools > kdevelop
pkg install kdevelop
Desktop Environments > Development tools > Eclipse IDE
pkg install eclipse
Desktop Environments > Development tools > Vim
pkg install vim
Desktop Environments > Development tools > Neovim
pkg install neovim
Desktop Environments > Development tools > GNU Emacs
pkg install emacs
Desktop Environments > Desktop office productivity > LibreOffice
pkg install libreoffice
pkg install es-libreoffice
Desktop Environments > Desktop office productivity > Calligra
pkg install calligra
Desktop Environments > Desktop office productivity > AbiWord
pkg install abiword
Desktop Environments > Document Viewers > Okular
pkg install okular
Desktop Environments > Document Viewers > Evince
pkg install evince
Desktop Environments > Document Viewers > ePDFView
pkg install epdfview
Desktop Environments > Document Viewers > Xpdf
pkg install xpdf
Desktop Environments > Document Viewers > Zathura
pkg install zathura zathura-pdf-mupdf
Desktop Environments > Finance > KMyMoney
pkg install kmymoney
Desktop Environments > Finance > GnuCash
pkg install gnucash
Multimedia
Multimedia > Setting Up the Sound Card
kldload snd_driver
Multimedia > Setting Up the Sound Card > Testing Sound
dmesg | grep pcm
cat /dev/sndstat
beep
Multimedia > Setting Up the Sound Card > Graphics Card Sound
dmesg | grep pcm
sysctl hw.snd.default_unit=4
Multimedia > Setting Up the Sound Card > Automatically Switching to Headphones
dmesg | grep pcm
Multimedia > Setting Up the Sound Card > Resampling Quality
sysctl hw.snd.feeder_rate_quality=4<.>
sysctl hw.snd.feeder_rate_round=0<.>
Multimedia > Setting Up the Sound Card > Troubleshooting Sound
pacmd
Multimedia > Audio players > Elisa
pkg install elisa
Multimedia > Audio players > GNOME Music
pkg install gnome-music
Multimedia > Audio players > Audacious
pkg install audacious-qt6 audacious-plugins-qt6
Multimedia > Audio players > cmus — C* Music Player
pkg install cmus
Multimedia > Video players > mpv
pkg install mpv
Multimedia > Video players > SMPlayer
pkg install smplayer
Multimedia > Video players > VLC media player
pkg install vlc
Multimedia > Video players > Kodi (XBMC)
pkg install kodi
Multimedia > Conferencing and Meetings > Setting Up the Webcam
pkg install webcamd pwcview
sysrc webcamd_enable=YES
pw groupmod webcamd -m username
kldload cuse
sysrc kld_list+=cuse
webcamd -l
sysrc webcamd_0_flags="-N SunplusIT-Inc-HP-TrueVision-HD-Camera" <.>
service webcamd start
pwcview -f 30 -s vga
Multimedia > Image Scanners > Checking the Scanner
usbconfig list
usbconfig -d 3.2 dump_device_desc
Multimedia > Image Scanners > SANE Configuration
pkg install sane-backends
usbconfig -d 3.2 dump_device_desc
service devd restart
scanimage -L
sysrc saned_enable=YES
Configuring the FreeBSD Kernel
Configuring the FreeBSD Kernel > Finding the System Hardware
pciconf -lv
man -k Atheros
Configuring the FreeBSD Kernel > The Configuration File
cd /usr/src/sys/amd64/conf
cp GENERIC MYKERNEL
mkdir /root/kernels
cp GENERIC /root/kernels/MYKERNEL
ln -s /root/kernels/MYKERNEL
cd /usr/src/sys/arch/conf && make LINT
Configuring the FreeBSD Kernel > Building and Installing a Custom Kernel
cd /usr/src
make buildkernel KERNCONF=MYKERNEL
make installkernel KERNCONF=MYKERNEL
Configuring the FreeBSD Kernel > If Something Goes Wrong
boot _kernel.old_
mv /boot/kernel /boot/kernel.bad
mv /boot/kernel.good /boot/kernel
Printing
Printing > Quick Start
mkdir -p /var/spool/lpd/lp
chown daemon:daemon /var/spool/lpd/lp
chmod 770 /var/spool/lpd/lp
service lpd start
printf "1. This printer can print.\n2. This is the second line.\n" | lpr
lpr textfile.txt
ls -lh | lpr
Printing > Direct Printing
cp sample.txt /dev/unlpt0
nc netlaser 9100 < sample.txt
Printing > LPD (Line Printer Daemon) > Initial Setup
mkdir -p /var/spool/lpd/lp
chown daemon:daemon /var/spool/lpd/lp
chmod 770 /var/spool/lpd/lp
chkprintcap
service lpd start
Printing > LPD (Line Printer Daemon) > Printing with lpr
lpr doc.txt
cat doc.txt | lpr
lpr -Plaser doc.txt
Printing > LPD (Line Printer Daemon) > Filters > Preventing Stairstepping on Plain Text Printers
chmod 555 /usr/local/libexec/lf2crlf
Printing > LPD (Line Printer Daemon) > Filters > Fancy Plain Text on PostScript(R) Printers with print/enscript
chmod 555 /usr/local/libexec/enscript
Printing > LPD (Line Printer Daemon) > Filters > Printing PostScript(R) to PCL Printers
chmod 555 /usr/local/libexec/ps2pcl
printf "%%\!PS \n /Helvetica findfont 18 scalefont setfont \
Printing > LPD (Line Printer Daemon) > Filters > Smart Filters
chmod 555 /usr/local/libexec/psif
Printing > LPD (Line Printer Daemon) > Monitoring and Controlling Printing > lpq
lpq -Plp
lpq -a
Printing > LPD (Line Printer Daemon) > Monitoring and Controlling Printing > lprm
lprm -Plp -
lpq
lprm -Plp 5
Printing > LPD (Line Printer Daemon) > Monitoring and Controlling Printing > lpc
lpc status all
lpc disable lp
lpc enable lp
lpc stop lp
lpc start lp
lpc restart lp
lpc down lp Repair parts will arrive on Monday
lpc up lp
Printing > LPD (Line Printer Daemon) > Shared Printers > Aliases
lpr -Psalesprinter sales-report.txt
lpr -Prepairsprinter repairs-report.txt
Linux Binary Compatibility
Linux Binary Compatibility > Configuring Linux Binary Compatibility
service linux start
ls -l /compat/linux/
Linux Binary Compatibility > Linux userlands
pkg install linux-sublime-text4
Linux Binary Compatibility > Linux userlands > Rocky Linux Base System from FreeBSD Packages
pkg install linux_base-rl9
ls -l /compat/linux/
Linux Binary Compatibility > Linux userlands > CentOS Base System from FreeBSD Packages
pkg install linux_base-c7
ls -l /compat/linux/
Linux Binary Compatibility > Linux userlands > Debian / Ubuntu Base System with debootstrap
pkg install debootstrap
debootstrap jammy /compat/ubuntu
mount -al
chroot /compat/ubuntu /bin/bash
uname -s -r -m
Linux Binary Compatibility > Advanced Topics > Installing Additional Libraries Manually
ldd linuxdoom
Linux Binary Compatibility > Advanced Topics > Branding Linux ELF Binaries
./my-linux-elf-binary
brandelf -t Linux my-linux-elf-binary
Linux Binary Compatibility > Advanced Topics > Installing a Linux RPM Based Application
cd /compat/linux
rpm2cpio < /path/to/linux.archive.rpm | cpio -id
WINE
WINE > Installing WINE on FreeBSD > WINE Prerequisites
pkg install wine-gecko
cd /usr/ports/emulators/wine-gecko
make install
pkg install wine-mono
cd /usr/ports/emulators/wine-mono
WINE > Installing WINE on FreeBSD > Installing WINE via FreeBSD Package Repositories
pkg install wine
cd /usr/ports/emulators/wine
make install
WINE > Running a First WINE Program on FreeBSD > Running a Program from the Command Line
wine program.exe
wine program2.exe -file file.txt
wine /home/user/bin/program.exe
WINE > Configuring WINE Installation > Creating and Using WINE Prefixes
WINEPREFIX="/home/username/.wine-new" winecfg
WINEPREFIX="/home/username/.wine-new" wine program.exe
WINE > WINE Management GUIs > Winetricks > Installing winetricks
pkg install i386-wine winetricks
cd /usr/ports/emulators/i386-wine
make install
cd /usr/ports/emulators/winetricks
WINE > WINE Management GUIs > Winetricks > Using winetricks
winetricks
WINE > WINE Management GUIs > Mizutamari > Installing Mizutamari
pkg install mizuma
cd /usr/ports/games/mizuma
make install
WINE > WINE Management GUIs > Mizutamari > Using Mizutamari
Mizuma
WINE > WINE in Multi-User FreeBSD Installations > Using a Common Installation of WINE
adduser
pkg install sudo
xhost +local:windows
sudo -u windows wine program.exe
Configuration, Services, Logging and Power Management
Configuration, Services, Logging and Power Management > Configuration Files > The sysctl utility
sysctl -a
sysctl kern.maxproc
sysctl net
sysctl kern.maxfiles=5000
Configuration, Services, Logging and Power Management > Configuration Files > The /etc/sysctl.conf file
sysctl -d kern.dfldsiz
Configuration, Services, Logging and Power Management > Managing Services in FreeBSD > Starting Services
sysrc nginx_enable="YES"
service nginx start
service nginx onestart
Configuration, Services, Logging and Power Management > Managing Services in FreeBSD > Status of a Service
service nginx status
Configuration, Services, Logging and Power Management > Cron and Periodic > Creating a User Crontab
crontab -e
crontab -l
crontab -r
Configuration, Services, Logging and Power Management > Cron and Periodic > Enable or Disable Periodic Tasks
ee /etc/periodic.conf
Configuration, Services, Logging and Power Management > Configuring System Logging > Read Log Messages
sysrc syslogd_flags="-vv"
Configuration, Services, Logging and Power Management > Configuring System Logging > Configuring Remote Logging > Log Server Configuration
sysrc syslogd_enable="YES"
sysrc syslogd_flags="-a logclient.example.com -v -v"
touch /var/log/logclient.log
service syslogd restart
pgrep syslog
Configuration, Services, Logging and Power Management > Configuring System Logging > Configuring Remote Logging > Log Client Configuration
sysrc syslogd_enable="YES"
sysrc syslogd_flags="-s -v -v"
service syslogd restart
logger "Test message from logclient"
Configuration, Services, Logging and Power Management > Configuring System Logging > Configuring Remote Logging > Debugging Log Servers
sysrc syslogd_flags="-d -a logclient.example.com -v -v"
service syslogd restart
Configuration, Services, Logging and Power Management > Power and Resource Management > ACPI configuration
ls /boot/kernel | grep acpi
kldload acpi_ibm
backlight decr 10
Configuration, Services, Logging and Power Management > Power and Resource Management > CPU Power Management
sysctl dev.cpu.0 <.>
sysrc powerd_enable=YES
sysrc powerd_flags="-a hiadaptive -i 25 -r 85 -N"
service powerd start
Configuration, Services, Logging and Power Management > Power and Resource Management > Intel(R) Enhanced Speed Step(TM)
sysctl dev.cpufreq.0.freq_driver dev.cpu.0.freq_levels dev.cpu.0.freq
Configuration, Services, Logging and Power Management > Power and Resource Management > Intel Speed Shift(TM)
sysctl dev.cpufreq.0.freq_driver
sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
Configuration, Services, Logging and Power Management > Power and Resource Management > Suspend/Resume > Configuring Suspend/Resume
sysctl hw.acpi.supported_sleep_state
acpiconf -s 3
Configuration, Services, Logging and Power Management > Adding Swap Space > Swap on a New Hard Drive or Existing Partition
swapon /dev/ada1p2
Configuration, Services, Logging and Power Management > Adding Swap Space > Creating a Swap File
dd if=/dev/zero of=/usr/swap0 bs=1m count=512
chmod 0600 /usr/swap0
swapon -aL
The FreeBSD Booting Process
The FreeBSD Booting Process > FreeBSD Boot Process > The Boot Manager
fdisk -B -b /boot/boot0 device
The FreeBSD Booting Process > FreeBSD Boot Process > Stage One and Stage Two
bsdlabel -B diskslice
The FreeBSD Booting Process > FreeBSD Boot Process > Stage Three
boot -s
set kernel="mykernel"
The FreeBSD Booting Process > FreeBSD Boot Process > Last Stage > Single-User Mode
shutdown now
The FreeBSD Booting Process > Device Hints
set hint.driver.unit.keyword=value
The FreeBSD Booting Process > Shutdown Sequence
shutdown -p now
shutdown -r now
Security
Security > Securing Accounts > Preventing Logins
pw lock imani
chsh -s /usr/sbin/nologin imani
Security > Securing Accounts > Password Hashes
grep imani /etc/master.passwd
grep passwd_format /etc/login.conf
cap_mkdb /etc/login.conf
Security > Securing Accounts > Password Policy Enforcement
passwd
cap_mkdb /etc/login.conf
pw usermod -p 30-apr-2025 -n user
Security > Securing Accounts > Shared Administration with sudo
pkg install sudo
sudo /usr/sbin/service webservice start
pw groupadd -g 6001 -n webteam
pw groupmod -m user1 -n webteam
Security > Securing Accounts > Shared Administration with Doas
pkg install doas
doas vi /etc/rc.conf
Security > Intrusion Detection System (IDS)
freebsd-update IDS
Security > Intrusion Detection System (IDS) > Generating the Specification File
mtree -s 123456789 -c -K cksum,sha512 -p /bin > /home/user/.bin_chksum_mtree
Security > Intrusion Detection System (IDS) > Verify the Specification file
mtree -s 123456789 -p /bin < /home/user/.bin_chksum_mtree >> /home/user/.bin_chksum_output
touch /bin/cat
cat /root/.bin_chksum_output
Security > Secure levels > Modify Secure Levels
sysrc kern_securelevel_enable="YES"
sysrc kern_securelevel=2
sysctl -n kern.securelevel
Security > File flags > Work with File Flags
chflags schg ~/important.txt
chflags noschg ~/important.txt
Security > OpenSSH > Using the SSH Client Utilities
ssh user@example.com
scp user@example.com:/COPYRIGHT COPYRIGHT
Security > OpenSSH > Key-based Authentication
ssh-keygen -t rsa -b 4096
Security > OpenSSH > SSH Tunneling
ssh -D 8080 user@example.com
Security > OpenSSH > Enabling the SSH Server
sysrc sshd_enable="YES"
service sshd start
Security > OpenSSH > Configuring publickey auth method
service sshd reload
Security > OpenSSH > SSH Server Security Options
sshd -t
service sshd reload
Security > OpenSSL > Generating Certificates
openssl req -new -nodes -out req.pem -keyout cert.key -sha3-512 -newkey rsa:4096
openssl req -new -x509 -days 365 -sha3-512 -keyout /etc/ssl/private/cert.key -out /etc/ssl/certs/cert.crt
Security > OpenSSL > Configuring the FIPS Provider
echo test | openssl aes-128-cbc -a -provider fips -pbkdf2
openssl fipsinstall -module /usr/lib/ossl-modules/fips.so -out /etc/ssl/fipsmodule.cnf
Security > Kerberos > Setting up a Heimdal KDC
pkg install heimdal
sysrc kdc_enable=yes
sysrc kadmind_enable=yes
kstash
kadmin -l
init EXAMPLE.ORG
add tillman
service kdc start
service kadmind start
kinit tillman
klist
kdestroy
Security > Kerberos > Configuring a Server to Use Kerberos
info heimdal
kadmin -l
add --random-key
kadmin
service sshd restart
Security > Kerberos > Configuring a Client to Use Kerberos
ssh -o GSSAPIAuthentication=yes _hostname_
Security > Kerberos > MIT Differences
sysrc kdc_program="/usr/local/sbin/krb5kdc"
sysrc kadmind_program="/usr/local/sbin/kadmind"
sysrc kdc_flags=""
sysrc kdc_enable="YES"
sysrc kadmind_enable="YES"
Security > Kerberos > Kerberos Tips, Tricks, and Troubleshooting
kinit -l
Security > TCP Wrappers > Initial Configuration
sysrc inetd_enable="YES"
service inetd start
service inetd restart
Security > Access Control Lists > Get ACLs information
getfacl test
Security > Access Control Lists > Working with ACLs
setfacl -d -m u::rwx,g::rx,o::rx,mask::rwx directory
setfacl -m u::rwx,g:mail:rw file
setfacl -m owner@:rwxp::allow,g:mail:rwp::allow file
setfacl -bn file
setfacl -b file
Security > Process Accounting > Enabling and Utilizing Process Accounting
sysrc accounting_enable=yes
service accounting start
lastcomm ls trhodes ttyp1
Security > Resource Limits > Configuring Login Classes
ee /etc/login.conf
cap_mkdb /etc/login.conf
chpass username
Security > Resource Limits > Enabling and Configuring Resource Limits
sysrc rctl_enable="YES"
service rctl start
rctl -a user:username:maxproc:deny=10/user
rctl
Security > Monitoring Third Party Security Issues
pkg audit -F
Jails and Containers
Jails and Containers > Host Configuration > Jail Utility
sysrc jail_enable="YES"
sysrc jail_parallel_start="YES"
sysrc jail_list="www db"
sysrc jail_reverse_stop="YES"
Jails and Containers > Host Configuration > Networking > Where a Jail’s IP Address Comes From
sysrc ifconfig_em0_aliases="inet 192.168.1.151/32"
Jails and Containers > Host Configuration > Networking > Loopback Addresses in Shared-IP Jails
sysrc cloned_interfaces="lo1"
sysrc ifconfig_lo1="inet 127.0.1.1/32"
Jails and Containers > Host Configuration > Networking > Preparing Host Services
sockstat -4 -6 -l
Jails and Containers > Host Configuration > Setting Up the Jail Directory Tree
zfs create -o mountpoint=/usr/local/jails zroot/jails
zfs create zroot/jails/media
zfs create zroot/jails/templates
zfs create zroot/jails/containers
mkdir /usr/local/jails/
mkdir /usr/local/jails/media
mkdir /usr/local/jails/templates
mkdir /usr/local/jails/containers
Jails and Containers > Host Configuration > Jail Configuration Files > Devfs Rulesets
service devfs restart
Jails and Containers > Classic Jail (Thick Jail) > Creating a Classic Jail
fetch https://download.freebsd.org/releases/amd64/amd64/15.1-RELEASE/base.txz -o /usr/local/jails/media/15.1-RELEASE-base.txz
mkdir -p /usr/local/jails/containers/classic
tar -xf /usr/local/jails/media/15.1-RELEASE-base.txz -C /usr/local/jails/containers/classic --unlink
cp /etc/resolv.conf /usr/local/jails/containers/classic/etc/resolv.conf
cp /etc/localtime /usr/local/jails/containers/classic/etc/localtime
freebsd-update -b /usr/local/jails/containers/classic/ fetch install
service jail start classic
Jails and Containers > Classic Jail (Thick Jail) > Obtaining the Jail Userland
bsdinstall jail /usr/local/jails/containers/classic
pkg --rootdir /usr/local/jails/containers/classic install -r FreeBSD-base FreeBSD-set-base-jail
cd /usr/src
make buildworld
make installworld DESTDIR=/usr/local/jails/containers/classic
make distribution DESTDIR=/usr/local/jails/containers/classic
make distribution
etcupdate -D
make delete-old delete-old-libs
Jails and Containers > Classic Jail (Thick Jail) > Cloning a Jail as a Template
zfs create
zfs create -p zroot/jails/containers/classic
service jail stop classic
zfs snapshot zroot/jails/containers/classic@template
zfs clone zroot/jails/containers/classic@template zroot/jails/containers/web1
cp -a /usr/local/jails/containers/classic /usr/local/jails/containers/web1
zfs promote
zfs send
zfs receive
zfs clone
Jails and Containers > Thin Jails > Creating a Thin Jail Using OpenZFS Snapshots
zfs create -p zroot/jails/templates/15.1-RELEASE
fetch https://download.freebsd.org/releases/amd64/amd64/15.1-RELEASE/base.txz -o /usr/local/jails/media/15.1-RELEASE-base.txz
tar -xf /usr/local/jails/media/15.1-RELEASE-base.txz -C /usr/local/jails/templates/15.1-RELEASE --unlink
cp /etc/resolv.conf /usr/local/jails/templates/15.1-RELEASE/etc/resolv.conf
cp /etc/localtime /usr/local/jails/templates/15.1-RELEASE/etc/localtime
freebsd-update -b /usr/local/jails/templates/15.1-RELEASE/ fetch install
zfs snapshot zroot/jails/templates/15.1-RELEASE@base
zfs clone zroot/jails/templates/15.1-RELEASE@base zroot/jails/containers/thinjail
service jail start thinjail
Jails and Containers > Thin Jails > Creating a Thin Jail Using NullFS
zfs create -p zroot/jails/templates/15.1-RELEASE-base
mkdir /usr/local/jails/templates/15.1-RELEASE-base
fetch https://download.freebsd.org/releases/amd64/amd64/15.1-RELEASE/base.txz -o /usr/local/jails/media/15.1-RELEASE-base.txz
tar -xf /usr/local/jails/media/15.1-RELEASE-base.txz -C /usr/local/jails/templates/15.1-RELEASE-base --unlink
cp /etc/resolv.conf /usr/local/jails/templates/15.1-RELEASE-base/etc/resolv.conf
cp /etc/localtime /usr/local/jails/templates/15.1-RELEASE-base/etc/localtime
freebsd-update -b /usr/local/jails/templates/15.1-RELEASE-base/ fetch install
zfs create -p zroot/jails/templates/15.1-RELEASE-skeleton
mkdir /usr/local/jails/templates/15.1-RELEASE-skeleton
mkdir -p /usr/local/jails/templates/15.1-RELEASE-skeleton/home
mkdir -p /usr/local/jails/templates/15.1-RELEASE-skeleton/usr
mv /usr/local/jails/templates/15.1-RELEASE-base/etc /usr/local/jails/templates/15.1-RELEASE-skeleton/etc
mv /usr/local/jails/templates/15.1-RELEASE-base/usr/local /usr/local/jails/templates/15.1-RELEASE-skeleton/usr/local
mv /usr/local/jails/templates/15.1-RELEASE-base/tmp /usr/local/jails/templates/15.1-RELEASE-skeleton/tmp
mv /usr/local/jails/templates/15.1-RELEASE-base/var /usr/local/jails/templates/15.1-RELEASE-skeleton/var
mv /usr/local/jails/templates/15.1-RELEASE-base/root /usr/local/jails/templates/15.1-RELEASE-skeleton/root
cd /usr/local/jails/templates/15.1-RELEASE-base/
mkdir skeleton
ln -s skeleton/etc etc
ln -s skeleton/home home
ln -s skeleton/root root
ln -s ../skeleton/usr/local usr/local
ln -s skeleton/tmp tmp
ln -s skeleton/var var
zfs snapshot zroot/jails/templates/15.1-RELEASE-skeleton@base
zfs clone zroot/jails/templates/15.1-RELEASE-skeleton@base zroot/jails/containers/thinjail
cp -R /usr/local/jails/templates/15.1-RELEASE-skeleton /usr/local/jails/containers/thinjail
mkdir -p /usr/local/jails/thinjail-nullfs-base
service jail start thinjail
Jails and Containers > VNET Jails
ifconfig bridge create
ifconfig bridge0 addm em0 up
ifconfig em0 up
Jails and Containers > VNET Jails > Running a Firewall and DHCP inside a VNET Jail
service devfs restart
Jails and Containers > Linux Jails
sysrc linux_enable="YES"
service linux start
touch /etc/jail.conf
jail -cm \
name=ubuntu \
host.hostname="ubuntu.example.com" \
path="/usr/local/jails/containers/ubuntu" \
interface="em0" \
ip4.addr="192.168.1.155" \
exec.start="/bin/sh /etc/rc" \
exec.stop="/bin/sh /etc/rc.shutdown" \
mount.devfs \
devfs_ruleset=4 \
allow.mount \
allow.mount.devfs \
allow.mount.fdescfs \
allow.mount.procfs \
allow.mount.linprocfs \
allow.mount.linsysfs \
allow.mount.tmpfs \
jexec -u root ubuntu sh
pkg install debootstrap
debootstrap jammy /compat/ubuntu
service jail onestop ubuntu
service jail start ubuntu
jexec ubuntu chroot /compat/ubuntu /bin/bash
Jails and Containers > NAT and Port Forwarding for Jails
sysrc gateway_enable="YES"
sysctl net.inet.ip.forwarding=1
sysrc pf_enable="YES"
service pf start
Jails and Containers > Service Jails
grep _svcj_options /path/to/rc.d/servicename
sysrc servicename_svcj_options=net_basic
service syslogd stop
sysrc syslogd_svcj=YES
service syslogd start
Jails and Containers > Jail Management > List Running Jails
jls
jls --libxo=json
jls -v
jls -h jid name path
jls -j classic path host.hostname ip4.addr
jls -d
Jails and Containers > Jail Management > Start, Restart, and Stop a Jail
service jail start jailname
Jails and Containers > Jail Management > Destroy a Jail
service jail stop classic
chflags -R 0 /usr/local/jails/containers/classic
rm -rf /usr/local/jails/containers/classic
zfs destroy zroot/jails/containers/classic
zfs promote
Jails and Containers > Jail Management > Handle Packages in a Jail
pkg -j classic install nginx-lite
Jails and Containers > Jail Management > Managing Services in a Jail from the Host
sysrc -j classic nginx_enable=YES
service -j classic nginx start
Jails and Containers > Jail Management > Access a Jail
jexec -u root jailname
Jails and Containers > Jail Management > Execute Commands in a Jail
jexec -l jailname service nginx stop
Jails and Containers > Jail Management > Viewing Jailed Processes and Sockets from the Host
ps -J classic
ps -J 0
ps ax -o pid,jail,command
top -J classic
sockstat -4 -6 -l -j classic
Jails and Containers > Jail Management > Managing Jails Directly with the jail Utility
jail -c classic
jail -r classic
jail -m name=classic ip4.addr+=192.168.250.71
jail -e ,
Jails and Containers > Jail Management > Backing Up and Migrating a Jail
service jail stop classic
zfs snapshot -r zroot/jails/containers/classic@migrate
zfs send -R zroot/jails/containers/classic@migrate | ssh newhost zfs receive zroot/jails/containers/classic
tar -cpf classic.tar -C /usr/local/jails/containers classic
tar -xpf
Jails and Containers > Administration from Inside a Jail
sysctl security.jail.jailed
sysctl -d security.jail.param
Jails and Containers > Jail Upgrading
make installworld
make distribution
zfs snapshot zroot/jails/containers/classic@preupgrade
zfs rollback zroot/jails/containers/classic@preupgrade
zfs create
Jails and Containers > Jail Upgrading > Upgrading a Classic Jail or a Thin Jail using OpenZFS Snapshots
freebsd-update -j classic fetch install
service jail restart classic
freebsd-update -j classic -r 15.1-RELEASE upgrade
freebsd-update -j classic install
pkg -j classic upgrade -f
Jails and Containers > Jail Upgrading > Upgrading OpenZFS Thin Jails
freebsd-update -b /usr/local/jails/templates/15.1-RELEASE/ fetch install
uname -r
zfs snapshot zroot/jails/templates/15.1-RELEASE@base-p2
zfs clone zroot/jails/templates/15.1-RELEASE@base-p2 zroot/jails/containers/newjail
Jails and Containers > Jail Upgrading > Upgrading a Thin Jail Using NullFS
freebsd-update -b /usr/local/jails/templates/15.1-RELEASE-base/ fetch install
service jail restart
uname -r
freebsd-update -b /usr/local/jails/templates/14.2-RELEASE-base/ --currently-running 14.2-RELEASE -r 14.3-RELEASE upgrade
freebsd-update -b /usr/local/jails/templates/14.2-RELEASE-base/ install
Jails and Containers > Jail Upgrading > Upgrading pkgbase Jails
pkg -r /usr/local/jails/containers/pkgjail update
pkg -r /usr/local/jails/containers/pkgjail upgrade
service jail restart pkgjail
pkg upgrade
jexec -l pkgjail pkg upgrade
Jails and Containers > Jail Resource Limits
rctl -a jail:classic:memoryuse:deny=2G
rctl -a jail:classic:pcpu:deny=80
rctl -a jail:classic:maxproc:deny=1000
rctl -a jail:classic:openfiles:deny=5000
rctl -a jail:classic:vmemoryuse:deny=4G
rctl -a jail:classic:writebps:throttle=1m
rctl -hu jail:classic
rctl jail:classic
rctl -r jail:classic
Jails and Containers > Jail Resource Limits > CPU Pinning with cpuset
cpuset -l 0-3 -j classic
cpuset -g -j classic
jls -v
Jails and Containers > Jail Resource Limits > Limiting Disk Space
zfs set quota=20G zroot/jails/containers/classic
zfs set reservation=5G zroot/jails/containers/classic
zfs create
Jails and Containers > More Jail Options > Empty and Persistent Jails
jail -c name=test path=/rescue persist
Jails and Containers > More Jail Options > Presenting a Different OS Release
uname -r
uname -K
Jails and Containers > Jails and ZFS
zfs jail
Jails and Containers > Jails and ZFS > Delegating a Dataset Manually
zfs create zroot/jails/data
zfs set jailed=on zroot/jails/data
zfs mount -a
zfs create zroot/jails/data/work
zfs snapshot zroot/jails/data/work@monday
Jails and Containers > Jails and ZFS > Attaching Datasets Automatically
zfs jail
OCI Containers
OCI Containers > Synopsis
jail ..
OCI Containers > Preparing the System for Podman Containers
sed -I .bak -e 's/driver = "zfs"/driver = "vfs"/' \
/usr/local/etc/containers/storage.conf
zfs create -o mountpoint=/var/db/containers zroot/containers
zfs snapshot zroot/containers@empty
mount -t fdescfs fdesc /dev/fd
OCI Containers > Installing Podman
pkg install -r FreeBSD -y podman-suite emulators/qemu-user-static
OCI Containers > Configuring Networking
service pf enable
service pf start
sysctl net.pf.filter_local=1
OCI Containers > Additional Configuration Files
pkg list | grep /etc/containers/
/usr/local/etc/containers/containers.conf.sample
/usr/local/etc/containers/policy.json.sample
/usr/local/etc/containers/registries.conf.sample
/usr/local/etc/containers/storage.conf.sample
/usr/local/etc/containers/pf.conf.sample
OCI Containers > Running Your First Container
podman run -it --rm ghcr.io/freebsd/freebsd-notoolchain:15.1
top -b
exit
OCI Containers > Importing and Running Containers > Importing FreeBSD OCI Images
export OCIBASE=https://download.freebsd.org/releases/OCI-IMAGES/15.1-RELEASE/amd64/Latest
podman load -i=$OCIBASE/FreeBSD-15.1-RELEASE-amd64-container-image-static.txz
podman load -i=$OCIBASE/FreeBSD-15.1-RELEASE-amd64-container-image-dynamic.txz
podman load -i=$OCIBASE/FreeBSD-15.1-RELEASE-amd64-container-image-runtime.txz
podman load -i=$OCIBASE/FreeBSD-15.1-RELEASE-amd64-container-image-notoolchain.txz
podman load -i=$OCIBASE/FreeBSD-15.1-RELEASE-amd64-container-image-toolchain.txz
OCI Containers > Importing and Running Containers > Listing Images
podman images
OCI Containers > Importing and Running Containers > Listing Layers
podman image tree ghcr.io/freebsd/freebsd-runtime:14.2
OCI Containers > Importing and Running Containers > Fetching Containers
podman pull
podman pull ghcr.io/freebsd/freebsd-notoolchain:15.1
OCI Containers > Importing and Running Containers > Running a Container
podman run
podman run -it --rm ghcr.io/freebsd/freebsd-notoolchain:15.1
exit
podman run -it --rm ghcr.io/freebsd/freebsd-notoolchain:15.1 uname -a
podman run -it --rm ghcr.io/freebsd/freebsd-notoolchain:15.0 /bin/sh
freebsd-version -ru
OCI Containers > Useful Variations and Tips
podman run ...
podman build
podman images -a
podman ps -a
OCI Containers > Useful Variations and Tips > Environment Variables
podman run -it --rm ghcr.io/freebsd/freebsd-notoolchain:15.1 /usr/bin/env
podman run --env FOO=BAR -it --rm ghcr.io/freebsd/freebsd-runtime:15.1
echo $FOO
OCI Containers > Useful Variations and Tips > Mounting Files and Volumes
podman run -it --rm ghcr.io/freebsd/freebsd-runtime:15.1
which
/bin/sh: which: not found
podman run -it --rm --volume /usr/bin/which:/usr/bin/which \
which which
/usr/bin/which
podman run -it --rm \
--env ASSUME_ALWAYS_YES=true \
--no-hosts \
--volume /usr/local/sbin/pkg-static:/bin/pkg-static \
--volume /var/cache/pkg \
pkg-static bootstrap -r FreeBSD
--volume /etc/fstab:/etc/fstab \
--volume /tmp:/var/tmp \
--volume /tmp \
OCI Containers > Useful Variations and Tips > Inspecting Image Contents
podman export $(podman create --rm ghcr.io/freebsd/freebsd-static:15.1 /) | tar tf -
pkg info -q
pkg info -ql
podman run --rm \
-v /usr/local/sbin/pkg-static:/pkg \
podman run -it --rm \
--env ASSUME_ALWAYS_YES=true \
--no-hosts \
--volume /usr/local/sbin/pkg-static:/usr/sbin/pkg \
--volume /var/cache/pkg \
pkg bootstrap
OCI Containers > Networking and Name Resolution
podman build
podman run --dns 1.2.3.4 ...
podman build --no-hosts ...
OCI Containers > Building Custom Images > Building from Tarballs
podman import --os freebsd \
--arch amd64 \
--message 'Import FreeBSD 15.1-RELEASE base.txz' \
podman image tag 332bec83a428 localhost/freebsd-base:15.1
podman image ls
OCI Containers > Building Custom Images > Building from Containerfiles
podman build --no-hosts --squash \
-t localhost/freebsd-base:15.1 \
podman build --no-hosts \
-t localhost/python-www:15.1 \
c=$(podman run --detach --rm -p 8888:8000 localhost/python-www:15.1)
fetch -v http://172.16.2.10:8888/
podman inspect -f '{{.NetworkSettings.IPAddress}}' $c
fetch -v http://10.88.0.91:8000/
OCI Containers > Advanced Usage > Daemonising Podman
sysrc podman_enable=YES
sysrc podman_service_enable=YES
sysrc podman_service_flags='--time 0'
service podman start
service podman_service start
podman run --detach --restart=always my-image
OCI Containers > Advanced Usage > Running Linux Containers
service linux onestart
podman run --rm --os=linux docker.io/alpine cat /etc/os-release | head -1
OCI Containers > Advanced Usage > Running a Local Registry
pkg install -r FreeBSD sysutils/docker-registry
zfs create zroot/var/db/registry
chown -R www:www /var/db/registry
sysrc docker_registry_enable=YES
sysrc docker_registry_user=www
sed -i '' -E -e 's,rootdirectory:.+,rootdirectory: /var/db/registry,' \
/usr/local/etc/docker-registry/config.yml
touch /usr/local/etc/docker-registry/htpasswd
chown -R root:www /usr/local/etc/docker-registry/config.yml \
/usr/local/etc/docker-registry/htpasswd
chmod 0640 /usr/local/etc/docker-registry/config.yml \
service registry start
curl -u admin:passwd http://localhost:5000/v2/
OCI Containers > Advanced Usage > Synchronising Registries
skopeo sync --src yaml --dest docker --all sync.yml cr.example.net/freebsd
OCI Containers > Advanced Usage > Working with Container Registries
podman login ghcr.io -u username
podman push localhost/freebsd-runtime:15.1 \
podman pull ghcr.io/freebsd/freebsd-runtime:15.1
OCI Containers > Building Container Images from Sources
podman load
cd /usr/src \
&& make TARGET_ARCH=aarch64 TARGET=arm64 -s -j32 buildworld \
&& make TARGET_ARCH=aarch64 TARGET=arm64 KERNCONF=GENERIC -s -j32 buildkernel \
&& make TARGET_ARCH=aarch64 TARGET=arm64 KERNCONF=GENERIC -s -j32 packages \
&& cd ./release \
&& make TARGET_ARCH=aarch64 TARGET=arm64 -j32 -s clean \
&& make KERNCONF=GENERIC TARGET_ARCH=aarch64 TARGET=arm64 WITH_OCIIMAGES=yes \
&& make TARGET_ARCH=amd64 TARGET=amd64 -s -j32 buildworld \
&& make TARGET_ARCH=amd64 TARGET=amd64 KERNCONF=GENERIC -s -j32 buildkernel \
&& make TARGET_ARCH=amd64 TARGET=amd64 KERNCONF=GENERIC -s -j32 packages \
&& make TARGET_ARCH=amd64 TARGET=amd64 -s -j32 clean \
&& make KERNCONF=GENERIC TARGET_ARCH=amd64 TARGET=amd64 \
OCI Containers > Cross-Architecture Testing
pkg install emulators/qemu-user-static
service qemu_user_static enable
service qemu_user_static start
podman run -it --rm --arch=arm64 \
-v /usr/local/bin/qemu-aarch64-static:/usr/local/bin/qemu-aarch64-static \
OCI Containers > Troubleshooting > Package Upgrades and Mounted Files
podman run --no-hosts --dns 1.1.1.1 -it --rm \
OCI Containers > Troubleshooting > Checking Networking
podman run --no-hosts --dns 1.1.1.1 \
--env ASSUME_ALWAYS_YES=1 \
-it --rm \
ghcr.io/freebsd/freebsd-runtime:15.1 \
/bin/sh
route show 1.1.1.1
route to: 1.1.1.1
ping -c 3 10.88.0.1
ping -c 3 1.1.1.1
fetch -v http://1.1.1.1/
pkg -dd bootstrap -r FreeBSD
set reassemble yes no-df
service pflog onerestart
tcpdump -vvveni pflog0 icmp or net 10.88.0.0/16
OCI Containers > Troubleshooting > MTU Consistency
ifconfig vtnet0 mtu 9000
ifconfig cni-podman0 mtu 9000
ifconfig eth0 mtu 9000
set reassemble yes no-df
Mandatory Access Control
Mandatory Access Control > Understanding MAC Labels
tunefs -l enable /
Mandatory Access Control > Understanding MAC Labels > Label Configuration
setfmac biba/high test
setpmac biba/low setfmac biba/high test
getfmac test
Mandatory Access Control > Understanding MAC Labels > Network Interface Labels
ifconfig bge0 maclabel biba/equal
Mandatory Access Control > Available MAC Policies > The MAC BSD Extended Policy
ugidfw list
ugidfw add subject not uid root new object not uid root mode n
ugidfw set 2 subject uid user1 object uid user2 mode n
ugidfw set 3 subject uid user1 object gid user2 mode n
Mandatory Access Control > Available MAC Policies > The MAC Port Access Control List Policy
sysctl security.mac.portacl.port_high=1023
sysctl net.inet.ip.portrange.reservedlow=0
sysctl net.inet.ip.portrange.reservedhigh=0
sysctl security.mac.portacl.suser_exempt=1
sysctl security.mac.portacl.rules=uid:80:tcp:80
sysctl security.mac.portacl.rules=uid:1001:tcp:110,uid:1001:tcp:995
Mandatory Access Control > Available MAC Policies > The MAC Partition Policy
setpmac partition/13 top
ps Zax
ps -ZU trhodes
Mandatory Access Control > Available MAC Policies > The MAC Multi-Level Security Module
setfmac mls/5 test
getfmac test
Mandatory Access Control > Available MAC Policies > The MAC Biba Module
setfmac biba/low test
getfmac test
Mandatory Access Control > Available MAC Policies > The MAC Low-watermark Module
setfmac /usr/home/trhodes lomac/high[low]
getfmac /usr/home/trhodes lomac/high[low]
Mandatory Access Control > User Lock Down
ps aux
Mandatory Access Control > Nagios in a MAC Jail > Create an Insecure User Class
cap_mkdb /etc/login.conf
Mandatory Access Control > Nagios in a MAC Jail > Configure Users
pw usermod root -L default
/etc/passwd; do pw usermod $x -L default; done;
pw usermod nagios -L insecure
pw usermod www -L insecure
Mandatory Access Control > Nagios in a MAC Jail > Create the Contexts File
setfsmac -ef /etc/policy.contexts /
Mandatory Access Control > Nagios in a MAC Jail > Testing the Configuration
cd /etc/mail && make stop && \
setpmac biba/equal make start && setpmac biba/10\(10-10\) apachectl start && \
setpmac biba/10\(10-10\) /usr/local/etc/rc.d/nagios.sh forcestart
setpmac biba/10 csh
Mandatory Access Control > Troubleshooting the MAC Framework
tunefs -l enable
mount -urw
Security Event Auditing
Security Event Auditing > Audit Configuration
service auditd start
Security Event Auditing > Working with Audit Trails
praudit /var/audit/AUDITFILE
exec arg
auditreduce -u trhodes /var/audit/AUDITFILE | praudit
Security Event Auditing > Working with Audit Trails > Live Monitoring Using Audit Pipes
praudit /dev/auditpipe
Security Event Auditing > Working with Audit Trails > Rotating and Compressing Audit Trail Files
audit -n
Storage
Storage > Adding Disks
gpart delete
gpart create -s GPT ada1
gpart add -t freebsd-ufs -a 1M ada1
gpart show
gpart show ada1
newfs -U /dev/ada1p1
mkdir /newdisk
mount /newdisk
Storage > Resizing and Growing Disks
gpart show ada0
gpart recover ada0
swapoff /dev/ada0p3
gpart delete -i 3 ada0
sysctl kern.geom.debugflags=16
gpart resize -i 2 -s 47G -a 4k ada0
gpart add -t freebsd-swap -a 4k ada0
swapon /dev/ada0p3
growfs /dev/ada0p2
zpool online -e zroot /dev/ada0p2
Storage > USB Storage Devices > Device Configuration
camcontrol devlist
usbconfig
sysctl vfs.usermount=1
mkdir /mnt/username
chown username:usergroup /mnt/username
mount -t msdosfs -o -m=644,-M=755 /dev/da0s1 /mnt/username
umount /mnt/username
Storage > USB Storage Devices > Automounting Removable Media
/media -media -nosuid
service automount restart
service devd restart
service automount start
service automountd start
service autounmountd start
service devd start
automount -fu
Storage > Creating and Using CD Media > Supported Devices
dmesg | grep cd
Storage > Creating and Using CD Media > Burning a CD
cdrecord dev=device imagefile.iso
cdrecord -scanbus
camcontrol devlist
Storage > Creating and Using CD Media > Writing Data to an ISO File System
mkisofs -o imagefile.iso /path/to/tree
mkisofs -R -no-emul-boot -b boot/cdboot -o /tmp/bootable.iso /tmp/myboot
mdconfig -a -t vnode -f /tmp/bootable.iso -u 0
mount -t cd9660 /dev/md0 /mnt
dd if=/dev/cd0 of=file.iso bs=2048
Storage > Creating and Using CD Media > Using Data CDs
mount -t cd9660 /dev/cd0 /mnt
tar xzvf /dev/cd1
Storage > Creating and Using CD Media > Duplicating Audio CDs
cdda2wav -vall -B -Owav
cdrecord -v dev=2,0 -dao -useinfo *.wav
Storage > Creating and Using DVD Media > Burning Data DVDs
growisofs -dvd-compat -Z /dev/cd0 -J -R /path/to/data
growisofs -dvd-compat -Z /dev/cd0=imagefile.iso
mkisofs -R -J -udf -iso-level 3 -o imagefile.iso /path/to/data
growisofs -dvd-compat -udf -iso-level 3 -Z /dev/cd0 -J -R /path/to/data
Storage > Creating and Using DVD Media > Burning a DVD-Video
growisofs -Z /dev/cd0 -dvd-video /path/to/video
Storage > Creating and Using DVD Media > Using a DVD+RW
dvd+rw-format /dev/cd0
growisofs -Z /dev/cd0 -J -R /path/to/newdata
growisofs -M /dev/cd0 -J -R /path/to/nextdata
growisofs -Z /dev/cd0=/dev/zero
Storage > Creating and Using DVD Media > Using a DVD-RW
dvd+rw-format -blank=full /dev/cd0
growisofs -use-the-force-luke=dao -Z /dev/cd0=imagefile.iso
growisofs -Z /dev/cd0 -J -R /path/to/data
dvd+rw-format /dev/cd0
Storage > Creating and Using DVD Media > Multi-Session
growisofs -M /dev/cd0 -J -R /path/to/nextdata
Storage > Creating and Using DVD Media > Using a DVD-RAM
dd if=/dev/zero of=/dev/acd0 bs=2k count=1
bsdlabel -Bw acd0
newfs /dev/acd0
mount /dev/acd0 /mnt
Storage > Creating and Using Floppy Disks
/usr/sbin/fdformat -f 1440 /dev/fd0
/sbin/bsdlabel -B -w /dev/fd0 fd1440
/sbin/newfs_msdos /dev/fd0
Storage > Backup Basics > File System Backups
/sbin/dump -0uan -f - /usr | gzip -2 | ssh -c blowfish \
env RSH=/usr/bin/ssh /sbin/dump -0uan -f targetuser@targetmachine.example.com:/dev/sa0 /usr
Storage > Backup Basics > Directory Backups
tar czvf /tmp/mybackup.tgz .
tar xzvf /tmp/mybackup.tgz
ls -R | cpio -ovF /tmp/mybackup.cpio
pax -wf /tmp/mybackup.pax .
Storage > Backup Basics > Using Data Tapes for Backups
mt -f /dev/nsa0 fsf 3
tar cvf /dev/sa0 file
tar xvf /dev/sa0
dump -0aL -b64 -f /dev/nsa0 /usr
restore -i -f /dev/nsa0
Storage > Backup Basics > Emergency Recovery
gpart show
pkg prime-list
Storage > Memory Disks > Attaching and Detaching Existing Images
mdconfig -f diskimage.iso -u 0
mount -t cd9660 /dev/md0 /mnt
umount /mnt
mdconfig -d -u 0
mdconfig -l
Storage > Memory Disks > Creating a File- or Memory-Backed Memory Disk
mdconfig -a -t swap -s 5m -u 1
newfs -U md1
mount /dev/md1 /mnt
df /mnt
dd if=/dev/zero of=newimage bs=1k count=5k
mdconfig -f newimage -u 0
bsdlabel -w md0 auto
newfs -U md0a
mount /dev/md0a /mnt
mdmfs -F newimage -s 5m md0 /mnt
mdmfs -s 5m md1 /mnt
Storage > File System Snapshots
mount -u -o snapshot /var/snapshot/snap /var
mksnap_ffs /var /var/snapshot/snap
find /var -flags snapshot
mdconfig -a -t vnode -o readonly -f /var/snapshot/snap -u 4
mount -r /dev/md4 /mnt
umount /mnt
mdconfig -d -u 4
Storage > Disk Quotas > Enabling Disk Quotas
sysctl kern.features.ufs_quota
Storage > Disk Quotas > Setting Quota Limits
quota -v
edquota -u test
/usr: kbytes in use: 65, limits (soft = 50, hard = 75)
/usr/var: kbytes in use: 0, limits (soft = 50, hard = 75)
edquota -p test 10000-19999
Storage > Disk Quotas > Checking Quota Limits and Disk Usage
quota -v
Storage > Disk Quotas > Quotas over NFS
service inetd restart
Storage > Encrypting Disk Partitions > Disk Encryption with gbde
kldload geom_bde
ls /dev/ad*
/dev/ad0 /dev/ad0s1b /dev/ad0s1e /dev/ad4s1
/dev/ad0s1 /dev/ad0s1c /dev/ad0s1f /dev/ad4s1c
/dev/ad0s1a /dev/ad0s1d /dev/ad4
mkdir /etc/gbde
gbde init /dev/ad4s1c -i -L /etc/gbde/ad4s1c.lock
gbde attach /dev/ad4s1c -l /etc/gbde/ad4s1c.lock
/dev/ad0s1a /dev/ad0s1d /dev/ad4 /dev/ad4s1c.bde
newfs -U /dev/ad4s1c.bde
mkdir /private
mount /dev/ad4s1c.bde /private
df -H
/devfs 1.0K 1.0K 0B 100% /dev
Storage > Encrypting Disk Partitions > Disk Encryption with geli
kldload geom_eli
dd if=/dev/random of=/root/da2.key bs=64 count=1
geli init -K /root/da2.key -s 4096 /dev/da2
cat keyfile1 keyfile2 keyfile3 | geli init -K - /dev/da2
geli attach -k /root/da2.key /dev/da2
ls /dev/da2*
/dev/da2 /dev/da2.eli
dd if=/dev/random of=/dev/da2.eli bs=1m
newfs /dev/da2.eli
mount /dev/da2.eli /private
df -H
/devfs 1.0K 1.0K 0B 100% /dev
umount /private
geli detach da2.eli
Storage > Encrypting Swap > Configuring Encrypted Swap
dd if=/dev/random of=/dev/ada0s1b bs=1m
geom eli onetime -d /dev/ada0s1b
Storage > Encrypting Swap > Encrypted Swap Verification
swapinfo
Storage > Highly Available Storage (HAST) > HAST Configuration
hastctl create test
service hastd onestart
hastctl role primary test
hastctl role secondary test
hastctl status test
hastctl status
newfs -U /dev/hast/test
mkdir /hast/test
mount /dev/hast/test /hast/test
Storage > Highly Available Storage (HAST) > HAST Configuration > Failover Configuration
service devd restart
Storage > Highly Available Storage (HAST) > Troubleshooting > Recovering from the Split-brain Condition
hastctl role init test
hastctl create test
hastctl role secondary test
GEOM: Modular Disk Transformation Framework
GEOM: Modular Disk Transformation Framework > RAID0 - Striping
kldload geom_stripe
gstripe label -v st0 /dev/ad2 /dev/ad3
bsdlabel -wB /dev/stripe/st0
newfs -U /dev/stripe/st0a
mount /dev/stripe/st0a /mnt
mkdir /stripe
echo "/dev/stripe/st0a /stripe ufs rw 2 2" \
echo 'geom_stripe_load="YES"' >> /boot/loader.conf
GEOM: Modular Disk Transformation Framework > RAID1 - Mirroring > Metadata Issues
gpart destroy -F ada8
gmirror remove gm4 ada8
gmirror clear
gmirror clear ada8
GEOM: Modular Disk Transformation Framework > RAID1 - Mirroring > Creating a Mirror with Two New Disks
gmirror load
gmirror label -v gm0 /dev/ada1 /dev/ada2
gpart create -s MBR mirror/gm0
gpart add -t freebsd -a 4k mirror/gm0
gpart show mirror/gm0
gpart create -s BSD mirror/gm0s1
gpart add -t freebsd-ufs -a 4k -s 2g mirror/gm0s1
gpart add -t freebsd-swap -a 4k -s 4g mirror/gm0s1
gpart add -t freebsd-ufs -a 4k -s 1g mirror/gm0s1
gpart add -t freebsd-ufs -a 4k mirror/gm0s1
gpart show mirror/gm0s1
gpart bootcode -b /boot/mbr mirror/gm0
gpart set -a active -i 1 mirror/gm0
gpart bootcode -b /boot/boot mirror/gm0s1
newfs -U /dev/mirror/gm0s1a
newfs -U /dev/mirror/gm0s1d
newfs -U /dev/mirror/gm0s1e
newfs -U /dev/mirror/gm0s1f
mount /dev/mirror/gm0s1a /mnt
dump -C16 -b64 -0aL -f - / | (cd /mnt && restore -rf -)
mount /dev/mirror/gm0s1d /mnt/var
mount /dev/mirror/gm0s1e /mnt/tmp
mount /dev/mirror/gm0s1f /mnt/usr
dump -C16 -b64 -0aL -f - /var | (cd /mnt/var && restore -rf -)
dump -C16 -b64 -0aL -f - /tmp | (cd /mnt/tmp && restore -rf -)
dump -C16 -b64 -0aL -f - /usr | (cd /mnt/usr && restore -rf -)
GEOM: Modular Disk Transformation Framework > RAID1 - Mirroring > Creating a Mirror with an Existing Drive
gmirror load
diskinfo -v ada0 | head -n3
/dev/ada0
geom zero load
gnop create -s 1000204821504 gzero
gmirror label -v gm0 gzero.nop ada1
gmirror forget gm0
gpart show ada0
gpart backup
gpart restore
gpart backup ada0 > table.ada0
gpart backup ada0s1 > table.ada0s1
cat table.ada0
cat table.ada0s1
gpart restore mirror/gm0 < table.ada0
gpart restore mirror/gm0s1 < table.ada0s1
gpart show
gpart show mirror/gm0
gpart show mirror/gm0s1
newfs -U /dev/mirror/gm0s1a
newfs -U /dev/mirror/gm0s1d
newfs -U /dev/mirror/gm0s1e
newfs -U /dev/mirror/gm0s1f
newfs -U /dev/mirror/gm0s1g
gpart bootcode -b /boot/mbr mirror/gm0
gpart set -a active -i 1 mirror/gm0
gpart bootcode -b /boot/boot mirror/gm0s1
cp /etc/fstab /etc/fstab.orig
dump -L
mount /dev/mirror/gm0s1a /mnt
dump -C16 -b64 -0aL -f - / | (cd /mnt && restore -rf -)
mount /dev/mirror/gm0s1d /mnt/var
mount /dev/mirror/gm0s1e /mnt/usr
mount /dev/mirror/gm0s1f /mnt/data1
mount /dev/mirror/gm0s1g /mnt/data2
dump -C16 -b64 -0aL -f - /usr | (cd /mnt/usr && restore -rf -)
dump -C16 -b64 -0aL -f - /var | (cd /mnt/var && restore -rf -)
dump -C16 -b64 -0aL -f - /data1 | (cd /mnt/data1 && restore -rf -)
dump -C16 -b64 -0aL -f - /data2 | (cd /mnt/data2 && restore -rf -)
gmirror insert gm0 ada0
gmirror status
GEOM: Modular Disk Transformation Framework > RAID1 - Mirroring > Troubleshooting
gmirror load
mount /dev/mirror/gm0s1a /mnt
cp /etc/fstab.orig /etc/fstab
shutdown -r now
GEOM: Modular Disk Transformation Framework > RAID1 - Mirroring > Recovering from Disk Failure
diskinfo -v
gmirror forget gm0
gmirror insert gm0 /dev/ada4
gmirror status
GEOM: Modular Disk Transformation Framework > RAID3 - Byte-level Striping with Dedicated Parity > Creating a Dedicated RAID3 Array
graid3 load
kldload geom_raid3
mkdir /multimedia
graid3 label -v gr0 /dev/ada1 /dev/ada2 /dev/ada3
gpart create -s GPT /dev/raid3/gr0
gpart add -t freebsd-ufs /dev/raid3/gr0
newfs -j /dev/raid3/gr0p1
mount /dev/raid3/gr0p1 /multimedia/
GEOM: Modular Disk Transformation Framework > Software RAID Devices
graid load
GEOM: Modular Disk Transformation Framework > Software RAID Devices > Creating an Array
graid label
graid label Intel gm0 RAID1 ada0 ada1
graid status
sysctl kern.geom.raid.name_format=1
GEOM: Modular Disk Transformation Framework > Software RAID Devices > Multiple Volumes
graid label -S 40G Intel gm0 RAID1 ada0 ada1
graid add -S 20G gm0 RAID0
GEOM: Modular Disk Transformation Framework > Software RAID Devices > Converting a Single Drive to a Mirror
graid label Intel gm0 RAID1 ada0 NONE
graid insert raid/r0 ada1
GEOM: Modular Disk Transformation Framework > Software RAID Devices > Inserting New Drives into the Array
graid insert raid/r0 ada1
GEOM: Modular Disk Transformation Framework > Software RAID Devices > Removing Drives from the Array
graid remove raid/r0 ada1
GEOM: Modular Disk Transformation Framework > Software RAID Devices > Stopping the Array
graid stop raid/r0
GEOM: Modular Disk Transformation Framework > Software RAID Devices > Checking Array Status
graid status
graid status -ga
GEOM: Modular Disk Transformation Framework > Software RAID Devices > Deleting Arrays
graid delete raid/r0
GEOM: Modular Disk Transformation Framework > Software RAID Devices > Deleting Unexpected Arrays
set kern.geom.raid.enable=0
boot
graid status
graid delete raid/r0
GEOM: Modular Disk Transformation Framework > GEOM Gate Network
ggated
ggatec create -o rw 192.168.1.1 /dev/da0s4d
mount /dev/ggate0 /mnt
GEOM: Modular Disk Transformation Framework > Labeling Disk Devices > Label Types and Examples
glabel label
glabel create
tunefs -L home /dev/da3
mount /home
glabel destroy home
glabel label rootfs /dev/ad0s1a
glabel label var /dev/ad0s1d
glabel label usr /dev/ad0s1f
glabel label tmp /dev/ad0s1e
glabel label swap /dev/ad0s1b
exit
mount
glabel status
GEOM: Modular Disk Transformation Framework > UFS Journaling Through GEOM
gjournal load
gjournal label /dev/da4
newfs -O 2 -J /dev/da4.journal
mount /dev/da4.journal /mnt
The Z File System (ZFS)
The Z File System (ZFS) > Quick Start Guide
sysrc zfs_enable="YES"
service zfs enable
service zfs start
The Z File System (ZFS) > Quick Start Guide > Single Disk Pool
gpart create -s gpt ada1
gpart add -t freebsd-zfs ada1
zpool create example /dev/ada1p1
df /example
cd /example
ls
touch testfile
ls -al
zfs create example/compressed
zfs set compression=gzip example/compressed
zfs set compression=off example/compressed
zfs umount
zfs umount example/compressed
df
zfs mount
zfs mount example/compressed
mount
zfs create example/data
zfs set copies=2 example/data
zfs destroy example/compressed
zfs destroy example/data
zpool destroy example
The Z File System (ZFS) > Quick Start Guide > RAID-Z
gpart create -s gpt ada0
gpart add -t freebsd-zfs ada0
gpart create -s gpt ada1
gpart add -t freebsd-zfs ada1
gpart create -s gpt ada2
gpart add -t freebsd-zfs ada2
zpool create storage raidz ada0p1 ada1p1 ada2p1
zfs create storage/home
zfs set copies=2 storage/home
zfs set compression=gzip storage/home
cp -rp /home/* /storage/home
rm -rf /home /usr/home
ln -s /storage/home /home
ln -s /storage/home /usr/home
zfs snapshot storage/home@2026-07-11
zfs rollback storage/home@2026-07-11
ls /storage/home/.zfs/snapshot
zfs destroy storage/home@2026-07-11
zfs set mountpoint=/home storage/home
mount
df
The Z File System (ZFS) > Quick Start Guide > Recovering RAID-Z
zpool status -x
zpool offline storage ada1p1
zpool replace storage ada1p1
zpool status storage
The Z File System (ZFS) > Quick Start Guide > Data Verification
zpool scrub storage
zpool status
zpool status storage
The Z File System (ZFS) > zpool Administration > Creating and Destroying Storage Pools
zpool create mypool mirror /dev/ada1p1 /dev/ada2p1
zpool status
zpool create mypool mirror /dev/ada1p1 /dev/ada2p1 mirror /dev/ada3p1 /dev/ada4p1
zpool create mypool raidz2 /dev/ada0p1 /dev/ada1p1 /dev/ada2p1 /dev/ada3p1 /dev/ada4p1 /dev/ada5p1
zpool create -o ashift=12 mypool mirror /dev/ada1p1 /dev/ada2p1
zpool add
zpool attach
The Z File System (ZFS) > zpool Administration > Pool Properties
zpool get all _mypool_
zpool get health,capacity mypool
zpool set
zpool set comment="Backup pool" mypool
zpool get comment mypool
zpool create
The Z File System (ZFS) > zpool Administration > Adding and Removing Devices
zpool attach
zpool add
gpart backup
gpart restore
zpool status
zpool attach mypool ada0p3 ada1p3
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1
zpool add mypool mirror ada2p3 ada3p3
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada2
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada3
zpool add mypool log mirror ada4p2 ada5p2
zpool add mypool cache nda0p2
zpool status mypool
zpool detach
zpool detach mypool ada2p3
zpool remove
zpool remove -n
zpool remove mypool mirror-1
zpool remove -s
The Z File System (ZFS) > zpool Administration > RAID-Z Expansion
zpool upgrade
zpool attach
zpool status
zpool attach mypool raidz2-0 ada6p3
zpool status mypool
zpool status mypool | grep expand:
zfs rewrite
The Z File System (ZFS) > zpool Administration > dRAID Pools
zpool create mypool draid2:8d:24c:2s ada0 ada1 ada2 ada3 ada4 ada5 ada6 ada7 ada8 ada9 ada10 ada11 ada12 ada13 ada14 ada15 ada16 ada17 ada18 ada19 ada20 ada21 ada22 ada23
zpool status
The Z File System (ZFS) > zpool Administration > Special Allocation Classes
zfs list
zpool add mypool special mirror nda0 nda1
zfs set special_small_blocks=16K mypool/projects
zpool remove
The Z File System (ZFS) > zpool Administration > Checking the Status of a Pool
zpool status
The Z File System (ZFS) > zpool Administration > Clearing Errors
zpool clear _mypool_
The Z File System (ZFS) > zpool Administration > Replacing a Functioning Device
zpool replace
zpool status
zpool replace mypool ada1p3 ada2p3
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada2
zpool attach
zpool resilver _mypool_
The Z File System (ZFS) > zpool Administration > Dealing with Failed Devices
zpool replace
zpool status
zpool replace mypool 316502962686821739 ada2p3
The Z File System (ZFS) > zpool Administration > Hot Spares and Automatic Replacement with zfsd
zpool create _mypool_ mirror _ada0p3_ _ada1p3_ spare _ada3p3_
zpool add
zpool add mypool spare ada3p3
zpool status
zpool replace
zpool replace mypool ada1p3 ada3p3
zpool detach _mypool_ _ada3p3_
zpool detach _mypool_ _ada1p3_
zpool set autoreplace=on mypool
sysrc zfsd_enable="YES"
service zfsd start
zpool events
The Z File System (ZFS) > zpool Administration > Scrubbing a Pool
zpool scrub mypool
zpool status
zpool scrub -p _mypool_
zpool scrub _mypool_
zpool scrub -s _mypool_
zpool scrub -w _mypool_
zpool scrub -e _mypool_
The Z File System (ZFS) > zpool Administration > Self-Healing
zpool create healer mirror /dev/ada0p1 /dev/ada1p1
zpool status healer
zpool list
cp /some/important/data /healer
sha1 /healer > checksum.txt
cat checksum.txt
zpool export healer
dd if=/dev/random of=/dev/ada1p1 bs=1m count=200
zpool import healer
sha1 /healer >> checksum.txt
zpool scrub healer
zpool status
zpool clear
zpool clear healer
The Z File System (ZFS) > zpool Administration > TRIM and Initialization
zpool trim
zpool trim mypool
zpool trim mypool nda0p3
zpool trim -w
zpool trim --secure
zpool status -t
zpool status -t mypool
zpool set autotrim=on mypool
zpool initialize
zpool initialize mypool
The Z File System (ZFS) > zpool Administration > Pool Checkpoints
zpool checkpoint
zpool checkpoint mypool
zpool list
zpool list mypool
zpool export mypool
zpool import --rewind-to-checkpoint mypool
zpool checkpoint -d -w mypool
zpool remove
zpool attach
zpool detach
zpool split
zpool reguid
The Z File System (ZFS) > zpool Administration > Growing a Pool
zpool set autoexpand=on mypool
zpool online -e
The Z File System (ZFS) > zpool Administration > Importing and Exporting Pools
zpool export -f
zpool export mypool
zpool import -N
zpool import -o
zpool import -o altroot=
zpool import -f
zpool import -a
zpool import -F
zpool import -m
zpool import -o readonly=on
zpool import -R /mnt
zpool import
zpool import -o altroot=/mnt mypool
zfs list
The Z File System (ZFS) > zpool Administration > Importing and Exporting Pools > Importing a GELI-Encrypted Pool
zpool import
geli attach ada0p4
zpool import -f -R /mnt zroot
gpart show
geli attach -k /path/to/encryption.key
The Z File System (ZFS) > zpool Administration > Upgrading a Storage Pool
zpool status
zpool status mypool
zpool upgrade
zpool upgrade -v
zpool upgrade mypool
zpool create
zpool create -o compatibility=openzfs-2.1-freebsd mypool mirror /dev/ada0p1 /dev/ada1p1
zpool set
gpart bootcode
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1
mount -t msdosfs /dev/ada1p1 /boot/efi
cp /boot/loader.efi /boot/efi/efi/boot/BOOTX64.efi
cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
The Z File System (ZFS) > zpool Administration > Displaying Recorded Pool History
zpool history
zfs list
zpool history -i
zpool history -l
The Z File System (ZFS) > zpool Administration > Performance Monitoring
zpool iostat
zpool iostat -v
zpool iostat -lv data
zpool status
zpool wait
zpool wait -t scrub,resilver mypool
zpool list
zpool get
zfs list
The Z File System (ZFS) > zfs Administration > Creating and Destroying Datasets
zfs list
zfs create -o compress=lz4 mypool/usr/mydataset
zfs destroy mypool/usr/mydataset
zfs destroy
zpool get freeing _poolname_
zpool wait -t free _poolname_
The Z File System (ZFS) > zfs Administration > Creating and Destroying Volumes
zfs create -V 250m -o compression=on tank/fat32
zfs list tank
newfs_msdos -F32 /dev/zvol/tank/fat32
mount -t msdosfs /dev/zvol/tank/fat32 /mnt
df -h /mnt | grep fat32
mount | grep fat32
zfs create -s -V 250g tank/bigdisk
The Z File System (ZFS) > zfs Administration > Renaming a Dataset
zfs rename
zfs list
zfs rename mypool/usr/mydataset mypool/var/newname
zfs list -t snapshot
zfs rename mypool/var/newname@first_snapshot new_snapshot_name
The Z File System (ZFS) > zfs Administration > Setting Dataset Properties
zfs set _property=value dataset_
zfs get
zfs inherit
zfs set custom:costcenter=1234 tank
zfs get custom:costcenter tank
zfs inherit -r custom:costcenter tank
zfs get all tank | grep custom:costcenter
The Z File System (ZFS) > zfs Administration > Setting Dataset Properties > Getting and Setting Share Properties
zfs get sharenfs mypool/usr/home
zfs set sharenfs=on mypool/usr/home
zfs set sharenfs="-alldirs,-maproot=root,-network=192.168.1.0/24" mypool/usr/home
The Z File System (ZFS) > zfs Administration > NFSv4 ACLs
getfacl /usr/home/alice/notes.txt
setfacl -m u:bob:rwp::allow /usr/home/alice/notes.txt
The Z File System (ZFS) > zfs Administration > Managing Snapshots > Creating Snapshots
zfs snapshot _dataset_@_snapshotname_
zfs list -t all
zfs snapshot -r mypool@my_recursive_snapshot
zfs list -t snapshot
zfs list
zfs list -rt all mypool/usr/home
cp /etc/passwd /var/tmp
zfs snapshot mypool/var/tmp@after_cp
zfs list -rt all mypool/var/tmp
The Z File System (ZFS) > zfs Administration > Managing Snapshots > Comparing Snapshots
zfs diff
zfs list -rt all mypool/var/tmp
zfs diff mypool/var/tmp@my_recursive_snapshot
cp /var/tmp/passwd /var/tmp/passwd.copy
zfs snapshot mypool/var/tmp@diff_snapshot
zfs diff mypool/var/tmp@my_recursive_snapshot mypool/var/tmp@diff_snapshot
zfs diff mypool/var/tmp@my_recursive_snapshot mypool/var/tmp@after_cp
The Z File System (ZFS) > zfs Administration > Managing Snapshots > Snapshot Rollback
zfs rollback _snapshotname_
zfs list -rt all mypool/var/tmp
ls /var/tmp
passwd passwd.copy vi.recover
rm /var/tmp/passwd*
zfs rollback mypool/var/tmp@diff_snapshot
zfs list -rt snapshot mypool/var/tmp
zfs rollback mypool/var/tmp@my_recursive_snapshot
zfs rollback -r mypool/var/tmp@my_recursive_snapshot
zfs list -t snapshot
zfs rollback -r
The Z File System (ZFS) > zfs Administration > Managing Snapshots > Restoring Individual Files from Snapshots
ls -a
zfs get snapdir mypool/var/tmp
ls -a /var/tmp
zfs set snapdir=visible mypool/var/tmp
rm /var/tmp/passwd
ls /var/tmp/.zfs/snapshot
ls /var/tmp/.zfs/snapshot/after_cp
passwd vi.recover
cp /var/tmp/.zfs/snapshot/after_cp/passwd /var/tmp
ls .zfs/snapshot
cp /etc/rc.conf /var/tmp/.zfs/snapshot/after_cp/
zfs destroy _dataset_@_snapshot_
The Z File System (ZFS) > zfs Administration > Managing Snapshots > Snapshot Holds
zfs destroy
zfs hold _tag_ _snapshot_
zfs hold keepme mypool/var/tmp@my_recursive_snapshot
zfs destroy mypool/var/tmp@my_recursive_snapshot
zfs holds
zfs holds mypool/var/tmp@my_recursive_snapshot
zfs release
zfs release keepme mypool/var/tmp@my_recursive_snapshot
The Z File System (ZFS) > zfs Administration > Bookmarks
zfs send
zfs bookmark
zfs snapshot mypool/data@snap1
zfs send mypool/data@snap1 | zfs receive backup/data
zfs bookmark mypool/data@snap1 mypool/data#snap1bm
zfs destroy mypool/data@snap1
zfs list -t bookmark
zfs list -t bookmark mypool/data
zfs snapshot mypool/data@snap2
zfs send -i mypool/data#snap1bm mypool/data@snap2 | zfs receive backup/data
The Z File System (ZFS) > zfs Administration > Managing Clones
zfs clone
zfs promote
zfs list -rt all camino/home/joe
zfs clone camino/home/joe@backup camino/home/joenew
ls /usr/home/joe*
/usr/home/joe:
/usr/home/joenew:
df -h /usr/home
zfs get origin camino/home/joenew
zfs promote camino/home/joenew
zfs destroy
zfs rename
cp /boot/defaults/loader.conf /usr/home/joenew
zfs destroy -f camino/home/joe
zfs rename camino/home/joenew camino/home/joe
ls /usr/home/joe
The Z File System (ZFS) > zfs Administration > Block Cloning
sysctl vfs.zfs.bclone_enabled=1
cp /var/tmp/database.dump /var/tmp/database.copy
zpool list -o name,bcloneused,bclonesaved,bcloneratio mypool
The Z File System (ZFS) > zfs Administration > Replication
zfs send
zfs receive
zpool list
zfs snapshot mypool@backup1
zfs list -t snapshot
zfs send mypool@backup1
zfs send mypool@backup1 > /backup/backup1
zfs snapshot mypool@replica1
zfs send -v mypool@replica1 | zfs receive backup/mypool
The Z File System (ZFS) > zfs Administration > Replication > Incremental Backups
zfs send
zfs snapshot mypool@replica2
zfs list -t snapshot
zpool list
zfs send -i
zfs send -v -i mypool@replica1 mypool@replica2 | zfs receive backup/mypool
zfs list
The Z File System (ZFS) > zfs Administration > Replication > Send Stream Options
zfs send
zfs send -Lec
zfs receive
The Z File System (ZFS) > zfs Administration > Replication > Resumable Transfers
zfs receive -s
zfs send -v mypool@replica1 | zfs receive -s backup/mypool
zfs send -t
zfs get -H -o value receive_resume_token backup/mypool
zfs send -t $(zfs get -H -o value receive_resume_token backup/mypool) | zfs receive -s backup/mypool
zfs receive -A
zfs receive -A backup/mypool
The Z File System (ZFS) > zfs Administration > Replication > Sending Encrypted Backups over SSH
zfs send
zfs allow -u someuser send,snapshot mypool
sysctl vfs.usermount=1
echo vfs.usermount=1 >> /etc/sysctl.conf
zfs create recvpool/backup
zfs allow -u someuser create,mount,receive recvpool/backup
chown someuser /recvpool/backup
zfs snapshot -r mypool/home@monday
zfs send -R mypool/home@monday | ssh someuser@backuphost zfs recv -dvu recvpool/backup
zfs send -R
zfs receive
zfs recv
The Z File System (ZFS) > zfs Administration > Replication > Corrective Receive
zfs receive -c
zpool status -v mypool
/mypool/reports/summary-2026.db
zfs send backup/mypool@replica2 | zfs receive -c mypool@replica2
zpool scrub -w mypool
zpool status mypool | grep errors:
The Z File System (ZFS) > zfs Administration > Dataset, User, and Group Quotas
zfs set quota=10G storage/home/bob
zfs set refquota=10G storage/home/bob
zfs set quota=none storage/home/bob
zfs set userquota@joe=50G storage/home/joe
zfs set userquota@joe=none storage/home/joe
zfs get all
zfs set groupquota@firstgroup=50G storage/home
zfs set groupquota@firstgroup=none storage/home
zfs userspace
zfs groupspace
zfs get quota storage/home/bob
The Z File System (ZFS) > zfs Administration > Dataset, User, and Group Quotas > Project Quotas
zfs project
zfs project -s -p 42 -r /storage/proj
zfs set projectquota@42=100G storage
zfs projectspace
zfs projectspace -o name,used,quota storage
zfs project -d
zfs project -C
The Z File System (ZFS) > zfs Administration > Reservations
zfs set reservation=10G storage/home/bob
zfs set reservation=none storage/home/bob
zfs get reservation storage/home/bob
zfs get refreservation storage/home/bob
The Z File System (ZFS) > zfs Administration > Compression
zfs get used,compressratio,compression,logicalused mypool/compressed_dataset
The Z File System (ZFS) > zfs Administration > Rewriting Existing Data
zfs rewrite
zfs set compression=zstd mypool/archive
zfs rewrite -r /mypool/archive
The Z File System (ZFS) > zfs Administration > Deduplication
zfs set dedup=on pool
zfs rewrite
zpool list
mkdir $d && cp -R /usr/bin $d &
zdb -S pool
zdb -S
zpool ddtprune -p 30 pool
zpool status -DD pool
The Z File System (ZFS) > zfs Administration > ZFS and Jails
zfs jail
zfs jail _jailid_
zfs unjail
zfs create mypool/jaildata
zfs set jailed=on mypool/jaildata
zfs jail myjail mypool/jaildata
zfs list
zfs unjail myjail mypool/jaildata
The Z File System (ZFS) > Delegated Administration > Delegating Dataset Creation
zfs allow _someuser_ create _mydataset_
The Z File System (ZFS) > Delegated Administration > Delegating Permission Delegation
zfs allow _someuser_ allow _mydataset_
The Z File System (ZFS) > ZFS Native Encryption
zpool scrub
The Z File System (ZFS) > ZFS Native Encryption > Creating an Encrypted Dataset
zfs create
zfs create -o encryption=on -o keyformat=passphrase -o keylocation=prompt zroot/secretdata
zfs set mountpoint=/secretdata zroot/secretdata
echo "Hello FreeBSD!" > /secretdata/message
cat /secretdata/message
The Z File System (ZFS) > ZFS Native Encryption > Properties of Encrypted Datasets
zfs get encryption,keylocation,keyformat zroot/secretdata
zfs set
The Z File System (ZFS) > ZFS Native Encryption > Unloading the Encryption Key
zfs unload-key
zfs unmount zroot/secretdata
zfs unload-key zroot/secretdata
The Z File System (ZFS) > ZFS Native Encryption > Loading the Encryption Key
zfs get keystatus zroot/secretdata
zfs mount zroot/secretdata
zfs load-key
zfs load-key zroot/secretdata
mount|grep secretdata
The Z File System (ZFS) > ZFS Native Encryption > Changing the Encryption Key
zfs change-key zroot/secretdata
zfs change-key
zfs send
zfs receive
zpool trim --secure
zpool initialize
The Z File System (ZFS) > ZFS Native Encryption > Sending Encrypted Datasets
zfs snapshot zroot/secretdata@snap1
zfs send
zfs send -w zroot/secretdata@snap1 | zfs recv backup/secret
The Z File System (ZFS) > ZFS Native Encryption > Loading Encryption Keys at Boot
zfs load-key
dd if=/dev/random of=/root/secretdata.key bs=32 count=1
chmod 600 /root/secretdata.key
zfs change-key -o keyformat=raw -o keylocation=file:///root/secretdata.key zroot/secretdata
sysrc zfskeys_enable="YES"
sysrc zfskeys_datasets="zroot/secretdata"
The Z File System (ZFS) > Boot Environments
bectl create beforeupgrade
bectl list
bectl activate beforeupgrade
bectl activate -t _beName_
bectl mount beforeupgrade
/tmp/be_mount.c1Xk
bectl umount beforeupgrade
bectl destroy beforeupgrade
The Z File System (ZFS) > Boot Environments > Boot Environments and Applications
zfs create -o mountpoint=/var/db/postgres zroot/pgdata
The Z File System (ZFS) > Advanced Topics > ARC Sizing and Monitoring
sysctl kstat.zfs.misc.arcstats.size kstat.zfs.misc.arcstats.c_max kstat.zfs.misc.arcstats.hits kstat.zfs.misc.arcstats.misses
The Z File System (ZFS) > Advanced Topics > Synchronous Writes, the ZIL, and SLOG
zpool add mypool log mirror nda0 nda1
The Z File System (ZFS) > Advanced Topics > recordsize and volblocksize
zfs rewrite
The Z File System (ZFS) > ZFS Features and Terminology
zpool create
zpool attach
zpool replace
zfs send
zfs bookmark
zfs release
zpool ddtprune
zpool scrub -p
zpool scrub
zpool import --rewind-to-checkpoint
zpool trim
zpool attach -s
zpool replace -s
Other File Systems
Other File Systems > Linux(R) File Systems > Extended File System (EXT)
mount -t ext2fs /dev/ada1s1 /mnt
Other File Systems > Windows(R) File Systems > FAT File System
mount -t msdosfs /dev/ada0s1 /mnt
Other File Systems > Windows(R) File Systems > exFAT File System
pkg install fusefs-exfat
kldload fusefs
sysrc kld_list+=fusefs
mount.exfat /dev/ada0s1 /mnt
Other File Systems > Windows(R) File Systems > NTFS File System
pkg install fusefs-ntfs
kldload fusefs
sysrc kld_list+=fusefs
ntfs-3g /dev/ada0s1 /mnt
Other File Systems > MacOS(R) File Systems > HFS/HFS+ File System
pkg install fusefs-hfsfuse
kldload fusefs
sysrc kld_list+=fusefs
hfsfuse /dev/ada0s1 /mnt
Virtualization
Virtualization > FreeBSD as a Guest on VMware Fusion for macOS(R) > Configuring FreeBSD on VMware Fusion
pkg install xf86-video-vmware xf86-input-vmmouse open-vm-tools
Virtualization > FreeBSD as a Guest on VirtualBox(TM)
cd /usr/ports/emulators/virtualbox-ose-additions && make install clean
vboxmanage sharedfolder add 'BSDBox' --name myshare --hostpath /mnt/bsdboxshare
mount_vboxvfs -w myshare /mnt
Virtualization > FreeBSD as a Host with VirtualBox(TM) > Installing VirtualBox(TM)
cd /usr/ports/emulators/virtualbox-ose
make install clean
kldload vboxdrv
pw groupmod vboxusers -m username
chown root:vboxusers /dev/vboxnetctl
chmod 0660 /dev/vboxnetctl
VirtualBox
Virtualization > FreeBSD as a Host with VirtualBox(TM) > VirtualBox(TM) USB Support
pw groupmod operator -m username
service devfs restart
Virtualization > FreeBSD as a Host with VirtualBox(TM) > VirtualBox(TM) Host DVD/CD Access
service devfs restart
Virtualization > Virtualization with QEMU on FreeBSD > Installing QEMU Software
pkg install qemu
ln -s /usr/local/bin/qemu-system-x86_64 /usr/local/bin/qemu
qemu
Virtualization > Virtualization with QEMU on FreeBSD > Virtual Machine Install
mkdir -p ~/QEMU ~/QEMU/SCRIPTS ~/QEMU/ISO ~/QEMU/VM
cd ~/QEMU/ISO
fetch https://download.freebsd.org/releases/ISO-IMAGES/14.1/FreeBSD-14.1-RELEASE-amd64-bootonly.iso
ln -s FreeBSD-14.1-RELEASE-amd64-bootonly.iso fbsd.iso
cd ~/QEMU/VM
qemu-img create -f raw left.img 15G
qemu-img create -f qcow2 -o preallocation=full,cluster_size=512K,lazy_refcounts=on right.qcow2 20G
du -Ah right.qcow2
ifconfig tap0 create
ifconfig tap1 create
sysctl net.link.tap.up_on_open=1
sysctl net.link.tap.user_open=1
ifconfig bridge0 create
ifconfig bridge0 addm tap0 addm tap1 addm em0
ifconfig bridge0 up
freebsd-update fetch
freebsd-update install
shutdown -r now
Virtualization > Virtualization with QEMU on FreeBSD > Usage Tips > Using the X Window System
startx
Virtualization > Virtualization with QEMU on FreeBSD > QEMU User Mode Emulation > Setting up a SPARC64 Guest VM on an x86_64 Host
cd ~/QEMU/ISO
fetch https://mirror.planetunix.net/pub/OpenBSD-archive/6.8/sparc64/install68.iso
cd ~/QEMU/VM
qemu-img create -f qcow2 -o preallocation=full,lazy_refcounts=on sparc64.qcow2 16G
Virtualization > Virtualization with QEMU on FreeBSD > Using the QEMU Monitor > Adding a New Disk to the VM
cd ~/QEMU/VM
qemu-img create -f raw new10G.img 10G
Virtualization > Virtualization with QEMU on FreeBSD > Using the QEMU Monitor > Using the QEMU Monitor to Manage Snapshots
info snapshots
cd ~/QEMU/VM
rm left.img
qemu-img create -f qcow2 left.qcow2 16G # Clean file for a new FreeBSD installation.
cd ../SCRIPTS
/bin/sh left.sh # See the below program listing.
Virtualization > Virtualization with QEMU on FreeBSD > Using Host USB Devices via Passthrough
info usbhost
pkg install fusefs-ntfs
kldload fusefs
gpart show da1
ntfs-3g /dev/da1s1 /mnt
umount /mnt
Virtualization > FreeBSD as a Host with bhyve > Preparing the Host
kldload vmm
ifconfig tap0 create
sysctl net.link.tap.up_on_open=1
ifconfig bridge0 create
ifconfig bridge0 addm igb0 addm tap0
ifconfig bridge0 up
Virtualization > FreeBSD as a Host with bhyve > Creating a FreeBSD Guest
truncate -s 16G guest.img
fetch https://download.freebsd.org/releases/ISO-IMAGES/14.0/FreeBSD-14.0-RELEASE-amd64-bootonly.iso
sh /usr/share/examples/bhyve/vmrun.sh -h
sh /usr/share/examples/bhyve/vmrun.sh -c 1 -m 1024M -t tap0 -d guest.img \
sh /usr/share/examples/bhyve/vmrun.sh -c 4 -m 1024M -t tap0 -d guest.img guestname
Virtualization > FreeBSD as a Host with bhyve > Creating a Linux(R) Guest
truncate -s 16G linux.img
grub-bhyve -m device.map -r cd0 -M 1024M linuxguest
ls
ls (cd0)/isolinux
linux (cd0)/isolinux/vmlinuz
initrd (cd0)/isolinux/initrd.img
boot
bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap0 \
-s 3:0,virtio-blk,./linux.img -s 4:0,ahci-cd,./somelinux.iso \
bhyvectl --destroy --vm=linuxguest
grub-bhyve -m device.map -r hd0,msdos1 -M 1024M linuxguest
ls (hd0,msdos1)/
linux (hd0,msdos1)/vmlinuz-2.6.32-431.el6.x86_64 root=/dev/mapper/VolGroup-lv_root
initrd (hd0,msdos1)/initramfs-2.6.32-431.el6.x86_64.img
Virtualization > FreeBSD as a Host with bhyve > Booting bhyve Virtual Machines with UEFI Firmware
bhyve -AHP -s 0:0,hostbridge -s 1:0,lpc \
-s 2:0,virtio-net,tap1 -s 3:0,virtio-blk,./disk.img \
-s 4:0,ahci-cd,./install.iso -c 4 -m 1024M \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
cp /usr/local/share/uefi-firmware/BHYVE_UEFI_VARS.fd /path/to/vm-image/BHYVE_UEFI_VARS.fd
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd,/path/to/vm-image/BHYVE_UEFI_VARS.fd \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CSM.fd \
Virtualization > FreeBSD as a Host with bhyve > Graphical UEFI Framebuffer for bhyve Guests
bhyve -AHP -s 0:0,hostbridge -s 31:0,lpc \
-s 2:0,virtio-net,tap1 -s 3:0,virtio-blk,./disk.img \
-s 4:0,ahci-cd,./install.iso -c 4 -m 1024M \
-s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \
-s 30,xhci,tablet \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
Virtualization > FreeBSD as a Host with bhyve > Creating a Microsoft Windows(R) Guest ===
bhyve \
-c 2 \
-s 0,hostbridge \
-s 3,nvme,windows2016.img \
-s 4,ahci-cd,install.iso \
-s 10,virtio-net,tap0 \
-s 31,lpc \
-s 30,xhci,tablet \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
-m 8G -H -w \
Virtualization > FreeBSD as a Host with bhyve > Using ZFS with bhyve Guests
zfs create -V16G -o volmode=dev zroot/linuxdisk0
bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap0 \
-s3:0,virtio-blk,/dev/zvol/zroot/linuxdisk0 \
zfs set primarycache=metadata <name>
Virtualization > FreeBSD as a Host with bhyve > Creating a Virtual Machine Snapshot === > ZFS Snapshots ====
zfs snapshot zroot/path/to/zvol@snapshot_name
Virtualization > FreeBSD as a Host with bhyve > Creating a Virtual Machine Snapshot === > Memory and CPU Snapshots (Experimental Feature) ====
cd /usr/src
make cleanworld
bhyvectl --usage
bhyvectl --vm=vmname --suspend=/path/to/snapshot/filename
bhyve -r /path/to/snapshot/filename
Virtualization > FreeBSD as a Host with bhyve > Jailing bhyve === > Creating a Jail for bhyve ====
mkdir -p /jails/bhyve
zfs create zroot/jails
zfs create zroot/jails/bhyve
zfs create zroot/vms
zfs create -V 20G -o volmode=dev zroot/vms/bhyvevm0
mkdir /jails/bhyve/vms
truncate -s 20G /jails/bhyve/vms/bhyvevm0
cd /jails
fetch -o base.txz http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/13.2-RELEASE/base.txz
tar -C /jails/bhyve -xvf base.txz
service devfs restart
Virtualization > FreeBSD as a Host with bhyve > Jailing bhyve === > Configuring the Jail ====
cp /etc/resolv.conf /jails/bhyve/etc
service jail onestart bhyve
jexec bhyve
sysrc ifconfig_jail0="inet 192.168.168.2/27"
sysrc defaultrouter="192.168.168.1"
sysrc sendmail_enable=NONE
sysrc cloned_interfaces="tap100"
exit
sysrc jail_enable=YES
service jail restart bhyve
cd /vms
fetch -o freebsd.iso https://download.freebsd.org/releases/ISO-IMAGES/14.0/FreeBSD-14.0-RELEASE-amd64-bootonly.iso
Virtualization > FreeBSD as a Host with bhyve > Jailing bhyve === > Creating a Virtual Machine Inside the Jail ====
jexec bhyve
bhyvectl --create --vm=bhyvevm0
sh /usr/share/examples/bhyve/vmrun.sh -c 1 -m 1024M \
pkg -j bhyve install bhyve-firmware
bhyve -A -c 4 -D -H -m 2G \
-s 0,hostbridge \
-s 1,lpc \
-s 2,virtio-net,tap100 \
-s 3,virtio-blk,/dev/zvol/zroot/vms/bhyvevm0 \
-s 4,ahci-cd,/vms/FreeBSD-14.0-RELEASE-amd64-bootonly.iso \
-s 31,fbuf,tcp=127.0.0.1:5900,w=1024,h=800,tablet \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
-l com1,/dev/nmdbbhyve0A \
Virtualization > FreeBSD as a Host with bhyve > Virtual Machine Consoles
kldload nmdm
bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap0 -s 3:0,virtio-blk,./linux.img \
cu -l /dev/nmdm0B
Virtualization > FreeBSD as a Host with bhyve > Managing Virtual Machines
ls -al /dev/vmm
bhyvectl --destroy --vm=guestname
ps ax | grep bhyve
kill 17424
Virtualization > FreeBSD as a Host with bhyve > Persistent Configuration
sysrc cloned_interfaces+="bridge0 tap0"
sysrc ifconfig_bridge0="inet <ipaddr>/<netmask> addm igb0 addm tap0"
sysrc kld_list+="nmdm vmm"
sysrc ifconfig_igb0="up"
sysrc ifconfig_bridge0="inet 10.10.10.1/24 addm igb0 addm tap0"
Virtualization > FreeBSD as a Xen(TM)-Host > Xen(TM) Dom0 Control Domain Setup
echo 'vm.max_wired=-1' >> /etc/sysctl.conf
sed -i '' -e 's/memorylocked=64K/memorylocked=unlimited/' /etc/login.conf
cap_mkdb /etc/login.conf
echo 'xc0 "/usr/libexec/getty Pc" xterm onifconsole secure' >> /etc/ttys
echo 'hw.pci.mcfg=0' >> /boot/loader.conf
echo 'if_tap_load="YES"' >> /boot/loader.conf
echo 'xen_kernel="/boot/xen"' >> /boot/loader.conf
echo 'xen_cmdline="dom0_mem=8192M dom0_max_vcpus=4 dom0pvh=1 console=com1,vga com1=115200,8n1 guest_loglvl=all loglvl=all"' >> /boot/loader.conf
echo 'xen_cmdline="dom0_mem=8192M dom0_max_vcpus=4 dom0=pvh console=com1,vga com1=115200,8n1 guest_loglvl=all loglvl=all"' >> /boot/loader.conf
sysrc xencommons_enable=yes
sysrc cloned_interfaces="bridge0"
sysrc ifconfig_bridge0="addm em0 SYNCDHCP"
sysrc ifconfig_em0="up"
shutdown -r now
xl list
Virtualization > FreeBSD as a Xen(TM)-Host > Xen(TM) DomU Guest VM Configuration
fetch https://download.freebsd.org/releases/ISO-IMAGES/14.0/FreeBSD-14.0-RELEASE-amd64-bootonly.iso -o freebsd.iso
zfs create -V20G -o volmode=dev zroot/xendisk0
cat freebsd.cfg
xl create
xl create freebsd.cfg
xl list
xl destroy
xl destroy freebsd
Virtualization > FreeBSD as a Xen(TM)-Host > Troubleshooting > Host Boot Troubleshooting
echo 'boot_verbose="YES"' >> /boot/loader.conf
Virtualization > FreeBSD as a Xen(TM)-Host > Troubleshooting > Guest Creation Troubleshooting
xl -vvv create freebsd.cfg
Localization - i18n/L10n Usage and Setup
Localization - i18n/L10n Usage and Setup > Using Localization
locale -a | more
locale
Localization - i18n/L10n Usage and Setup > Using Localization > Setting Locale for Login Shell > Login Classes Method
cap_mkdb /etc/login.conf
Localization - i18n/L10n Usage and Setup > Using Localization > Setting Locale for Login Shell > Login Classes Method > Utilities Which Change Login Classes
adduser -class language
pw useradd user_name -L language
chpass user_name
Localization - i18n/L10n Usage and Setup > Using Localization > Console Setup
ls /usr/share/syscons/fonts
ls /usr/share/syscons/scrnmaps
ls /usr/share/syscons/keymaps
Updating and Upgrading FreeBSD
Updating and Upgrading FreeBSD > FreeBSD Update > Applying Security Patches
freebsd-update fetch
freebsd-update install
freebsd-version -k
uname -r
freebsd-update rollback
Updating and Upgrading FreeBSD > FreeBSD Update > Performing Minor and Major Version Upgrades
freebsd-update fetch
freebsd-update install
freebsd-update -r 13.2-RELEASE upgrade
nextboot -k GENERIC
shutdown -r now
Updating and Upgrading FreeBSD > FreeBSD Update > Performing Minor and Major Version Upgrades > Custom Kernels with FreeBSD 9.X and Later
mount /media
cd /media/usr/freebsd-dist
tar -C/ -xvf kernel.txz boot/kernel/kernel
cd /usr/src
make buildkernel __MAKE_CONF=/dev/null SRCCONF=/dev/null
make installkernel __MAKE_CONF=/dev/null SRCCONF=/dev/null
Updating and Upgrading FreeBSD > FreeBSD Update > Performing Minor and Major Version Upgrades > Upgrading Packages After a Major Version Upgrade
pkg upgrade
pkg-static upgrade -f
portmaster -af
freebsd-update install
Updating and Upgrading FreeBSD > FreeBSD Update > System State Comparison
freebsd-update IDS
freebsd-update IDS >> outfile.ids
cat outfile.ids | awk '{ print $1 }' | more
Updating and Upgrading FreeBSD > Updating the Documentation Set > Updating Documentation from Source
git clone https://git.FreeBSD.org/doc.git /usr/doc
git pull
cd /usr/doc
make
Updating and Upgrading FreeBSD > Tracking a Development Branch > The N-number
uname -v
git rev-list
git rev-list --first-parent --count 031260d64c18 <.>
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Quick Start
etcupdate extract <.>
etcupdate diff <.>
git -C /usr/src pull <.>
cd /usr/src <.>
make -j4 buildworld <.>
make -j4 kernel <.>
shutdown -r now <.>
etcupdate -p <.>
make installworld <.>
etcupdate -B <.>
make buildkernel installkernel
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Updating the Source
cd /usr/src
git remote --v
git -C /usr/src pull
uname -r
mv /usr/src /usr/src.bak <.>
git clone --branch releng/13.2 https://git.FreeBSD.org/src.git /usr/src <.>
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Building from Source
cd /usr/src
make buildworld
make buildkernel
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Building from Source > Performing a Clean Build
make cleanworld
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Building from Source > Setting the Number of Jobs
sysctl hw.ncpu
make -j4 buildworld buildkernel
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Building from Source > Building Only the Kernel
cd /usr/src
make buildkernel
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Building from Source > Building a Custom Kernel
uname -m
cp /usr/src/sys/amd64/conf/GENERIC /root/STORAGESERVER
cd /usr/src/sys/amd64/conf
ln -s /root/STORAGESERVER .
make buildkernel KERNCONF=STORAGESERVER
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Installing the Compiled Code
cd /usr/src
make installkernel
shutdown -r now
make installworld
make installkernel KERNCONF=STORAGESERVER
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Completing the Update > Merging Configuration Files with etcupdate
etcupdate diff
etcupdate resolve
etcupdate extract <.>
etcupdate diff <.>
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Completing the Update > Checking for Outdated Files and Libraries
make check-old
make delete-old
make check-old-libs
make delete-old-libs
make BATCH_DELETE_OLD_FILES=yes delete-old-libs
Updating and Upgrading FreeBSD > Updating FreeBSD from Source > Completing the Update > Restarting After the Update
shutdown -r now
Updating and Upgrading FreeBSD > Updating FreeBSD with packages > Upgrading a Host using freebsd-base
mkdir -p /usr/local/etc/pkg/repos/
pkg update -r FreeBSD-base
pkg upgrade -r FreeBSD-base
shutdown -r now
Updating and Upgrading FreeBSD > Updating FreeBSD with packages > Upgrading a Host using freebsd-base > Major Upgrades > Preparations
pkg -c /mnt/upgrade lock pkg
pkg prime-origins | sort -u > /var/tmp/pkg-prime-origins.txt
Updating and Upgrading FreeBSD > Updating FreeBSD with packages > Upgrading a Host using freebsd-base > Major Upgrades > Major Upgrade With ZFS
bectl create 15.0-RELEASE
mkdir /mnt/upgrade
bectl mount 15.0-RELEASE /mnt/upgrade
env ABI=FreeBSD:15:amd64 pkg-static -c /mnt/upgrade upgrade -r FreeBSD-base
freebsd-version -ku
chroot /mnt/upgrade
exit
bectl activate -t 15.0-RELEASE
shutdown -r now
bectl activate 15.0-RELEASE
Updating and Upgrading FreeBSD > Updating FreeBSD with packages > Upgrading a Host using freebsd-base > Major Upgrades > Major Upgrade Without ZFS
env ABI=FreeBSD:15:amd64 pkg-static upgrade -r FreeBSD-base
freebsd-version -ku
Updating and Upgrading FreeBSD > Updating FreeBSD with packages > Upgrading a Host using freebsd-base > Major Upgrades > Post-upgrade tasks
pkg unlock pkg
pkg upgrade
Updating and Upgrading FreeBSD > Updating FreeBSD with packages > Manually building pkgbase and publishing it to the local network
cd /usr/src
git clone https://github.com/freebsd/freebsd-src.git /usr/src
git checkout releng/14.3
make -j8 buildworld && make -j8 buildkernel && make -j8 packages
Updating and Upgrading FreeBSD > Tracking for Multiple Machines
make buildworld
make buildkernel
shutdown now
Updating and Upgrading FreeBSD > Building on non-FreeBSD Hosts
MAKEOBJDIRPREFIX=/tmp/obj tools/build/make.py -j 8 TARGET=arm64 TARGET_ARCH=aarch64 buildworld
DTrace
DTrace > Implementation Differences
kldload dtraceall
DTrace > Enabling DTrace Support
kldload dtraceall
DTrace > Using DTrace
dtrace -l | more
cd /usr/local/share/dtrace-toolkit
./hotkernel
./hotkernel -m
./procsystime -n csh
USB Device Mode / USB OTG
USB Device Mode / USB OTG > USB Virtual Serial Ports > Configuring USB Device Mode Serial Ports
service devd restart
kldload umodem
sysctl hw.usb.template=3
USB Device Mode / USB OTG > USB Virtual Serial Ports > Connecting to USB Device Mode Serial Ports from FreeBSD
cu -l /dev/ttyU0
USB Device Mode / USB OTG > USB Virtual Serial Ports > Connecting to USB Device Mode Serial Ports from macOS
cu -l /dev/cu.usbmodemFreeBSD1
USB Device Mode / USB OTG > USB Virtual Serial Ports > Connecting to USB Device Mode Serial Ports from Linux
minicom -D /dev/ttyACM0
USB Device Mode / USB OTG > USB Device Mode Network Interfaces
kldload if_cdce
sysctl hw.usb.template=1
USB Device Mode / USB OTG > USB Virtual Storage Device > Configuring USB Mass Storage Target Using the cfumass Startup Script
service cfumass start
USB Device Mode / USB OTG > USB Virtual Storage Device > Configuring USB Mass Storage Using Other Means
kldload cfumass
ctladm create -b block -o file=/data/target0
service ctld start
service ctld reload
Serial Communications
Serial Communications > Serial Terminology and Hardware > Serial Port Configuration
grep uart /var/run/dmesg.boot
stty -a -f /dev/ttyu1
stty -f /dev/ttyu5.init clocal cs8 ixon ixoff
stty -f /dev/ttyu5.lock 57600
Serial Communications > Terminals
cu -l /dev/cuauN
Serial Communications > Terminals > Terminal Configuration
kill -HUP 1
Serial Communications > Terminals > Troubleshooting the Connection
ps -axww|grep ttyu
kill -HUP 1
Serial Communications > Dial-in Service > Modem Configuration
kill -HUP 1
stty -f /dev/ttyu1.init crtscts
stty -f /dev/cuau1.init crtscts
Serial Communications > Dial-in Service > Troubleshooting
ps ax
Serial Communications > Dial-out Service > Using AT Commands
tip cuau0
cu -lline -sspeed
Serial Communications > Dial-out Service > Dialing from the Command Line
tip -115200 5551234
cu 5551234 -s 115200
Serial Communications > Dial-out Service > Accessing a Number of Hosts Through a Terminal Server
tip pain
tip muffin
tip deep13
Serial Communications > Setting Up the Serial Console > Quick Serial Console Configuration
echo 'console="comconsole"' >> /boot/loader.conf
Serial Communications > Setting Up the Serial Console > In-Depth Serial Console Configuration
/boot.config: -P
Serial Communications > Setting Up the Serial Console > Setting a Faster Serial Port Speed
cd /sys/boot
make clean
make
make install
PPP
PPP > Configuring PPP > Advanced Configuration
set dns
PPP > Configuring PPP > Using ppp
ppp
ppp -auto provider
PPP > Troubleshooting PPP Connections > Check the Device Nodes
dmesg | grep uart
PPP > Troubleshooting PPP Connections > Connecting Manually
ppp
set device /dev/cuau1
set speed 115200
enable dns
term
PPP > Troubleshooting PPP Connections > Debugging
set ctsrts off
set accmap
set parity even
set authname myusername
set authkey mypassword
add default HISADDR
PPP > Using PPP over Ethernet (PPPoE)
ppp -ddial name_of_service_provider
PPP > Using PPP over Ethernet (PPPoE) > Using a PPPoE Service Tag
set device
PPP > Using PPP over Ethernet (PPPoE) > PPPoE with a 3Com(R) HomeConnect(TM) ADSL Modem Dual Link
sysctl net.graph.nonstandard_pppoe=1
PPP > Using PPP over ATM (PPPoA) > Using mpd
mpd -b adsl
ifconfig ng0
PPP > Using PPP over ATM (PPPoA) > Using pptpclient
chown root:wheel /etc/ppp/ppp.conf
chmod 600 /etc/ppp/ppp.conf
pptp address adsl
ifconfig tun0
Electronic Mail
Electronic Mail > DragonFly Mail Agent (DMA) > Configuring DragonFly Mail Agent (DMA) > Using DMA to Route Outgoing Mail through Gmail (STARTTLS:SMTP example)
echo this is a test | mail -v -s testing-email username@gmail.com
Electronic Mail > DragonFly Mail Agent (DMA) > Configuring DragonFly Mail Agent (DMA) > Using DMA to Route Outgoing Mail through Fastmail (SSL/TLS example)
echo this is a test | mail -v -s testing-email username@fastmail.com
Electronic Mail > DragonFly Mail Agent (DMA) > Configuring DragonFly Mail Agent (DMA) > Using DMA to Route Outgoing Mail through a Custom Mail Host
echo this is a test | mail -v -s testing-email username@example.org
Electronic Mail > Sendmail > Configuration Files
makemap hash /etc/mail/access < /etc/mail/access
service sendmail restart
makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable
Electronic Mail > Changing the Mail Transfer Agent > Replacing Sendmail with Other MTA
sysrc sendmail_enable="NO"
sysrc sendmail_submit_enable="NO"
sysrc sendmail_outbound_enable="NO"
sysrc sendmail_msp_queue_enable="NO"
service sendmail onestop
pkg install dma
sysrc dma_flushq_enable="YES"
Electronic Mail > Changing the Mail Transfer Agent > Replacing DragonFly Mail Agent (DMA) with Other MTA
pkg install postfix
sysrc postfix_enable="YES"
mv /usr/local/etc/mail/mailer.conf /usr/local/etc/mail/mailer.conf.old
Electronic Mail > Mail User Agents > mail
mail
Electronic Mail > Mail User Agents > Mutt
mutt
Electronic Mail > Mail User Agents > alpine
alpine
Electronic Mail > Advanced Topics > Basic Configuration
hostname
host example.FreeBSD.org
Electronic Mail > Advanced Topics > Setting Up to Send Only
cd /usr/ports/mail/ssmtp
make install replace clean
Electronic Mail > Advanced Topics > SMTP Authentication in Sendmail
sysrc saslauthd_enable="YES"
service saslauthd start
cd /usr/src/lib/libsmutil
make cleandir && make obj && make
cd /usr/src/lib/libsm
cd /usr/src/usr.sbin/sendmail
make cleandir && make obj && make && make install
make install restart
Network Servers
Network Servers > The inetd Super-Server > Configuration File
service inetd start
service inetd reload
Network Servers > The inetd Super-Server > Command-Line Options
service inetd restart
Network Servers > Network File System (NFS) > Configuring the Server
service nfsd start
service mountd reload
Network Servers > Network File System (NFS) > Configuring the Client
service nfsclient start
mount server:/home /mnt
Network Servers > Network File System (NFS) > Locking
sysrc rpc_lockd_enable="YES"
service lockd start
Network Servers > Network File System (NFS) > Automating Mounts with autofs
showmount -e
showmount -e foobar
/usr 10.10.10.0
/a 10.10.10.0
cd /net/foobar/usr
service automount start
service automountd start
service autounmountd start
Network Servers > Network Information System (NIS) > Configuring the NIS Master Server
service ypserv start
Network Servers > Network Information System (NIS) > Configuring the NIS Master Server > Initializing the NIS Maps
cp /etc/master.passwd /var/yp/master.passwd
cd /var/yp
vi master.passwd
ypinit -m test-domain
done with the list, type a <control D>.
Network Servers > Network Information System (NIS) > Configuring the NIS Master Server > Adding New Users
pw useradd jsmith
cd /var/yp
make test-domain
adduser jsmith
pw useradd smith
Network Servers > Network Information System (NIS) > Setting up a NIS Slave Server
ypinit -s ellington test-domain
Network Servers > Network Information System (NIS) > Setting Up an NIS Client
/etc/netstart
service ypbind start
ypcat passwd
Network Servers > Network Information System (NIS) > NIS Security > Barring Some Users
cat /etc/master.passwd
Network Servers > Network Information System (NIS) > Using Netgroups
cd /var/yp
make
ypcat -k netgroup
ypcat -k netgroup.byhost
ypcat -k netgroup.byuser
cd ~_user_
ls -l
find . -user joe -print
Network Servers > Network Information System (NIS) > Password Formats
cap_mkdb /etc/login.conf
Network Servers > Lightweight Directory Access Protocol (LDAP) > LDAP Terminology and Structure
ldapsearch -xb "uid=trhodes,ou=users,o=example.com"
Network Servers > Lightweight Directory Access Protocol (LDAP) > Configuring an LDAP Server
pkg install openldap-server
pkg info openldap-server
mkdir /usr/local/etc/openldap/private
openssl req -days 365 -nodes -new -x509 -keyout ca.key -out ../ca.crt
openssl req -days 365 -nodes -new -keyout server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -out ../server.crt -CA ../ca.crt -CAkey ca.key -CAcreateserial
openssl req -days 365 -nodes -new -keyout client.key -out client.csr
openssl x509 -req -days 3650 -in client.csr -out ../client.crt -CA ../ca.crt -CAkey ca.key
mkdir /usr/local/etc/openldap/slapd.d/
/usr/local/sbin/slapadd -n0 -F /usr/local/etc/openldap/slapd.d/ -l /usr/local/etc/openldap/slapd.ldif
/usr/local/libexec/slapd -F /usr/local/etc/openldap/slapd.d/
ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts
pkg install openssl
c_rehash .
openssl verify -verbose -CApath . server.crt
cat domain.ldif
ldapadd -W -D "cn=mdbadmin,dc=domain,dc=example" -f domain.ldif
cat global_mod
ldapmodify -f global_mod -x -D "cn=config" -W
rm -rf /usr/local/etc/openldap/slapd.d/
Network Servers > Dynamic Host Configuration Protocol (DHCP) > Installing and Configuring a DHCP Server
service isc-dhcpd start
Network Servers > Domain Name System (DNS) > DNS Server Configuration
drill -S FreeBSD.org @192.168.1.1
service local_unbound onestart
drill -S FreeBSD.org
Network Servers > Zero-configuration Networking (mDNS/DNS-SD) > Configuring and Starting Avahi
pkg install avahi-app nss_mdns
grep -q '^hosts:.*\<mdns\>' /etc/nsswitch.conf || sed -i "" 's/^hosts: .*/& mdns/' /etc/nsswitch.conf
service dbus enable
service avahi-daemon enable
service dbus start
service avahi-daemon start
Network Servers > Apache HTTP Server > Configuring and Starting Apache
apachectl configtest
service apache24 start
service apache24 configtest
Network Servers > Apache HTTP Server > Apache Modules
make config
Network Servers > Apache HTTP Server > Apache Modules > mod_php
pkg search php
pkg install mod_php74
pkg install php74-xml php74-openssl
apachectl graceful
pkg install php74
php -i | less
Network Servers > Apache HTTP Server > Apache Modules > HTTP2 Support
grep "HTTP/2.0" /var/log/httpd-access.log
Network Servers > Apache HTTP Server > Dynamic Websites > Django
make config
Network Servers > File Transfer Protocol (FTP) > Configuration
service ftpd start
ftp localhost
Network Servers > File and Print Services for Microsoft(R) Windows(R) Clients (Samba) > Server Configuration > Samba Users
pdbedit -a -u username
Network Servers > File and Print Services for Microsoft(R) Windows(R) Clients (Samba) > Starting Samba
service samba_server start
service samba_server stop
Network Servers > Clock Synchronization with NTP > NTP Configuration > NTP entries in /etc/rc.conf
service ntpd start
Network Servers > iSCSI Initiator and Target Configuration > Configuring an iSCSI Target
service ctld start
service ctld reload
Network Servers > iSCSI Initiator and Target Configuration > Configuring an iSCSI Initiator
service iscsid start
Network Servers > iSCSI Initiator and Target Configuration > Configuring an iSCSI Initiator > Connecting to a Target Without a Configuration File
iscsictl -A -p 10.10.10.10 -t iqn.2012-06.com.example:target0
iscsictl -A -p 10.10.10.10 -t iqn.2012-06.com.example:target0 -u user -s secretsecret
Network Servers > iSCSI Initiator and Target Configuration > Configuring an iSCSI Initiator > Connecting to a Target with a Configuration File
iscsictl -An t0
iscsictl -Aa
Firewalls
Firewalls > PF > Enabling PF
sysrc pf_enable=yes
sysrc pflog_enable=yes
service pf start
service pflog start
pfctl -e
pfctl -d
pfctl -F all -f /etc/pf.conf
pfctl -s [ rules \| nat \| states ]
pfctl -vnf /etc/pf.conf
Firewalls > PF > PF Rulesets
pfctl -e ; pfctl -f /etc/pf.conf
pfctl -f /etc/pf.conf
pfctl -nf /etc/pf.conf
Firewalls > PF > PF Rulesets > A Simple Gateway with NAT
sysctl net.inet.ip.forwarding=1
sysctl net.inet6.ip6.forwarding=1
sysrc gateway_enable=yes
sysrc ipv6_gateway_enable=yes
Firewalls > PF > PF Rulesets > Creating an FTP Proxy
service ftp-proxy start
pfctl -f /etc/pf.conf
Firewalls > PF > PF Rulesets > Using Tables
pfctl -t clients -T add 192.168.1.0/16
pfctl -t clients -T replace -f /etc/clients
Firewalls > PF > PF Rulesets > Using Overload Tables to Protect SSH
pfctl -t bruteforce -T expire 86400
Firewalls > PF > PF Rulesets > Protecting Against SPAM
service obspamd start
Firewalls > IPFW > Enabling IPFW
sysrc firewall_enable="YES"
sysrc firewall_type="open"
sysrc firewall_script="/etc/ipfw.rules"
sysrc firewall_logging="YES"
echo "net.inet.ip.fw.verbose_limit=5" >> /etc/sysctl.conf
sysrc firewall_logif="YES"
tcpdump -t -n -i ipfw0
service ipfw start
sysctl net.inet.ip.fw.verbose_limit=5
Firewalls > IPFW > IPFW Rule Syntax
ipfw add
allow | accept | pass | permit
ipfw resetlog
Firewalls > IPFW > Example Ruleset
ipfw add
Firewalls > IPFW > The IPFW Command
ipfw list
ipfw -t list
ipfw -a list
ipfw -d list
ipfw -d -e list
ipfw zero
ipfw zero NUM
Firewalls > IPFW > The IPFW Command > Building a Rule Script
sh /etc/ipfw.rules
ipfw -q -f flush
ipfw -q add check-state
ipfw -q add deny all from any to any frag
ipfw -q add deny tcp from any to any established
ipfw -q add allow tcp from any to any 80 out via tun0 setup keep-state
ipfw -q add allow tcp from any to 192.0.2.11 53 out via tun0 setup keep-state
ipfw -q add 00611 allow udp from any to 192.0.2.11 53 out via tun0 keep-state
Firewalls > IPFILTER (IPF) > Enabling IPF
ipf -Fa -f /etc/ipf.rules
Firewalls > IPFILTER (IPF) > Configuring NAT
ipnat -CF -f /etc/ipnat.rules
ipnat -s
ipnat -l
ipnat -v
Firewalls > IPFILTER (IPF) > Viewing IPF Statistics
ipf -Z
Firewalls > IPFILTER (IPF) > IPF Logging
service ipmon start
touch /var/log/ipfilter.log
service syslogd reload
Firewalls > Blocklistd > Enabling Blocklistd
sysrc blocklistd_enable=yes
service blocklistd start
Firewalls > Blocklistd > Blocklistd Management
blocklistctl dump -b
blocklistctl dump -br
Firewalls > Blocklistd > Removing Hosts from the Block List
pfctl -a blocklistd/22 -t port22 -T show
pfctl -a blocklistd/22 -t port22 -T delete 213.0.123.128/25
Advanced Networking
Advanced Networking > Gateways and Routes > Routing Basics
netstat -r
route add default 10.20.30.1
Advanced Networking > Gateways and Routes > Configuring a Router with Static Routes
netstat -nr
route add -net 192.168.2.0/24 192.168.1.2
Advanced Networking > Virtual Hosts
sysrc ifconfig_fxp0_alias0="inet xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx"
sysrc ifconfig_fxp0="inet 10.1.1.1 netmask 255.255.255.0"
sysrc ifconfig_fxp0_alias0="inet 10.1.1.2 netmask 255.255.255.255"
sysrc ifconfig_fxp0_alias1="inet 10.1.1.3 netmask 255.255.255.255"
sysrc ifconfig_fxp0_alias2="inet 10.1.1.4 netmask 255.255.255.255"
sysrc ifconfig_fxp0_alias3="inet 10.1.1.5 netmask 255.255.255.255"
sysrc ifconfig_fxp0_alias4="inet 202.0.75.17 netmask 255.255.255.240"
sysrc ifconfig_fxp0_alias5="inet 202.0.75.18 netmask 255.255.255.255"
sysrc ifconfig_fxp0_alias6="inet 202.0.75.19 netmask 255.255.255.255"
sysrc ifconfig_fxp0_alias7="inet 202.0.75.20 netmask 255.255.255.255"
sysrc ifconfig_fxp0_aliases="inet 10.1.1.1-5/24 inet 202.0.75.17-20/28"
Advanced Networking > Wireless Advanced Authentication > WPA with EAP-TLS
service netif start
Advanced Networking > Wireless Advanced Authentication > WPA with EAP-TTLS
service netif start
Advanced Networking > Wireless Advanced Authentication > WPA with EAP-PEAP
service netif start
Advanced Networking > Wireless Ad-hoc Mode
ifconfig wlan0 create wlandev ath0 wlanmode adhoc
ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 ssid freebsdap
ifconfig wlan0
ifconfig wlan0 up scan
ifconfig wlan0 inet 192.168.0.2 netmask 255.255.255.0 ssid freebsdap
Advanced Networking > Wireless Ad-hoc Mode > FreeBSD Host Access Points > Basic Settings
ifconfig wlan0 create wlandev ath0
ifconfig wlan0 list caps
ifconfig wlan0 destroy
ifconfig wlan0 create wlandev ath0 wlanmode hostap
ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 ssid freebsdap mode 11g channel 1
ifconfig wlan0
Advanced Networking > Wireless Ad-hoc Mode > FreeBSD Host Access Points > Host-based Access Point Without Authentication or Encryption
ifconfig wlan0 create wlandev ath0
ifconfig wlan0 up scan
ifconfig wlan0 inet 192.168.0.2 netmask 255.255.255.0 ssid freebsdap
ifconfig wlan0
Advanced Networking > Wireless Ad-hoc Mode > FreeBSD Host Access Points > WPA2 Host-based Access Point > WPA2-PSK
service hostapd forcestart
ifconfig wlan0
ifconfig _wlan0_ list sta
Advanced Networking > USB Tethering
kldload if_urndis
kldload if_cdce
kldload if_ipheth
Advanced Networking > Bluetooth > Loading Bluetooth Support
kldload ng_ubt
service bluetooth start ubt0
Advanced Networking > Bluetooth > Finding Other Bluetooth Devices
hccontrol -n ubt0hci inquiry
hccontrol -n ubt0hci remote_name_request 00:80:37:29:19:a4
hccontrol -n ubt0hci create_connection BT_ADDR
hccontrol -n ubt0hci read_connection_list
hccontrol -n ubt0hci disconnect 41
hccontrol help
Advanced Networking > Bluetooth > Network Access with PPP Profiles
rfcomm_pppd -a 00:80:37:29:19:a4 -c -C dun -l rfcomm-dialup
rfcomm_pppd -s -C 7 -l rfcomm-server
Advanced Networking > Bluetooth > Bluetooth Protocols > Logical Link Control and Adaptation Protocol (L2CAP)
l2ping -a 00:80:37:29:19:a4
l2control -a 00:02:72:00:d4:1a read_channel_list
l2control -a 00:02:72:00:d4:1a read_connection_list
btsockstat
Advanced Networking > Bluetooth > Bluetooth Protocols > Service Discovery Protocol (SDP)
sdpcontrol -a 00:01:03:fc:6e:ec browse
sdpcontrol -a 00:01:03:fc:6e:ec search OPUSH
service sdpd start
sdpcontrol -l browse
Advanced Networking > Bluetooth > Bluetooth Protocols > OBEX Object Push (OPUSH)
obexapp -a 00:80:37:29:19:a4 -C IrMC
get telecom/devinfo.txt devinfo-t39.txt
put new.vcf
di
obexapp -s -C 10
Advanced Networking > Bluetooth > Bluetooth Protocols > Serial Port Profile (SPP)
rfcomm_sppd -a 00:07:E0:00:0B:CA -t
/dev/pts/6
cu -l /dev/pts/6
Advanced Networking > Bluetooth > Troubleshooting
hccontrol -n ubt0hci write_node_role_switch 0
Advanced Networking > Bridging > Enabling the Bridge
ifconfig bridge create
ifconfig bridge0
id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
ifconfig bridge0 addm fxp0 addm fxp1 up
ifconfig fxp0 up
ifconfig fxp1 up
ifconfig bridge0 inet 192.168.0.1/24
Advanced Networking > Bridging > Enabling Spanning Tree
ifconfig bridge0 stp fxp0 stp fxp1
id 00:01:02:4b:d4:50 priority 32768 hellotime 2 fwddelay 15
id 00:13:d4:9a:06:7a priority 32768 hellotime 2 fwddelay 15
Advanced Networking > Bridging > Bridge Interface Parameters
ifconfig bridge0 span fxp4
ifconfig bridge0 addm vlan100 sticky vlan100 addm vlan101 sticky vlan101
ifconfig bridge0 inet 192.168.0.1/24
ifconfig bridge0 private vlan100 private vlan101
ifconfig bridge0 ifmaxaddr vlan100 10
ifconfig bridge0 addm fxp0 addm fxp1 addm fxp2 addm fxp3 monitor up
tcpdump -i bridge0
Advanced Networking > Bridging > SNMP Monitoring
service bsnmpd start
snmpwalk -v 2c -c public bridge1.example.com mib-2.dot1dBridge
snmpwalk -v 2c -c public bridge1.example.com
snmpset -v 2c -c private bridge1.example.com
Advanced Networking > Link Aggregation and Failover > Configuration Examples
ifconfig fxp0 up
ifconfig fxp1 up
ifconfig lagg0 create
ifconfig lagg0 up laggproto lacp laggport fxp0 laggport fxp1 10.0.0.3/24
ifconfig lagg0
show lacp neighbor
show lacp neighbor detail
ifconfig lagg0 up laggproto failover laggport fxp0 laggport fxp1 10.0.0.15/24
ifconfig wlan0 create wlandev ath0 country FR ssid my_router up
ifconfig wlan0
ifconfig re0 ether b8:ee:65:5b:32:59
ifconfig re0 up
ifconfig lagg0 up laggproto failover laggport re0 laggport wlan0
dhclient lagg0
Advanced Networking > Diskless Operation with PXE > Setting Up the PXE Environment
export NFSROOTDIR=/b/tftpboot/FreeBSD/install
mkdir -p ${NFSROOTDIR}
service nfsd start
service inetd start
make installkernel
make installworld
tftp localhost
get FreeBSD/install/boot/pxeboot
chroot ${NFSROOTDIR}
passwd
mkdir -p conf/base
tar -c -v -f conf/base/etc.cpio.gz --format cpio --gzip etc
tar -c -v -f conf/base/var.cpio.gz --format cpio --gzip var
Advanced Networking > Diskless Operation with PXE > Configuring the DHCP Server
service isc-dhcpd start
Advanced Networking > Diskless Operation with PXE > Debugging PXE Problems
tftp 192.168.0.1
get FreeBSD/install/boot/pxeboot
mount -t nfs 192.168.0.1:/b/tftpboot/FreeBSD/install /mnt
chroot ${NFSROOTDIR}
mv boot/pxeboot boot/pxeboot.original
cp boot/loader.efi boot/pxeboot
Advanced Networking > Common Address Redundancy Protocol (CARP) > Using CARP
kldload carp
ifconfig em0 vhid 1 state backup
Advanced Networking > VLANs
ifconfig em0.5 create vlan 5 vlandev em0 inet 192.168.20.20/24
ifconfig em0 up
ifconfig em0.5 create vlan 5 vlandev em0 name cameras inet 192.168.20.20/24
ifconfig video.5 create vlan 5 vlandev video name cameras inet 192.168.20.20/24
Obtaining FreeBSD
Obtaining FreeBSD > Mirrors
pkg audit
Obtaining FreeBSD > Using Git > Installation
pkg install git
Obtaining FreeBSD > Using Git > Running Git
git clone
git clone -o freebsd https://git.FreeBSD.org/src.git /usr/src
cd /usr/src
git checkout stable/13
git pull
git pull --rebase
Comandos y demonios citados en el texto (referencias man)
Xorg
amd
apropos
at
auditd
automountd
autounmountd
boot0cfg
bsdconfig
bsnmpd
chat
chfn
cpio
cron
csh
ctfconvert
ctfmerge
ctld
dbus-daemon
ddb
devd
dhclient-script
diff
diskless
dma
efivar
fdformat
fingerd
fsck
ftp-proxy
ftpd
fwget
getty
gptboot
gptzfsboot
halt
hastd
hcsecd
hcseriald
hostapd
hostapd_cli
httpd
inetd
ipfstat
iscontrol
iscsid
kadmind
kbdcontrol
kbdmap
kenv
kldunload
ksu
ld
less
lldb
loader
loader.efi
local-unbound
login
logout
lpd
m4
mergemaster
mgetty
mixer
mount_cd9660
mount_msdosfs
mount_nfs
mount_nullfs
mount_udf
mountd
named
natd
newsyslog
nfsiod
nologin
nscd
ntpd
ntpdate
openssl-fipsinstall
pam_passwdqc
periodic
pkg-audit
pkg-autoremove
pkg-delete
pkg-fetch
pkg-info
pkg-install
pkg-lock
pkg-search
pkg-unlock
pkg-upgrade
pkgbasify
podman-build
podman-import
podman-run
postfix
poudriere-image
powerd
pppctl
procstat
quotacheck
quotaoff
quotaon
rc
rc.subr
rdump
reboot
repquota
rescue
resizewin
routed
rpc.lockd
rpc.rquotad
rpc.yppasswdd
rpcbind
rrestore
rtadvd
sa
samba-tool
screen
sdpd
sendmail
setxkbmap
sftp
sha256
sha512
sha512sum
sshfs
stat
sync
syslog
syslogd
tcsh
telnet
tftpd
tmux
traceroute
truss
twm
uefi
unlink
vigr
vipw
vmstat
winecfg
wlandebug
wpa_supplicant
xz
yp
ypbind
ypchfn
ypchpass
ypchsh
yppasswd
ypserv
zfs-bookmark
zfs-hold
zfs-jail
zfs-project
zfs-receive
zfs-rewrite
zfs-rollback
zfs-send
zfs-set
zfs-share
zfs-userspace
zfsd
zip
zpool-checkpoint
zpool-create
zpool-import
zpool-initialize
zpool-status
zpool-trim
zpool-wait
Comentarios