Skip to content

Instantly share code, notes, and snippets.

@sfloess
Last active May 13, 2024 18:32
Show Gist options
  • Save sfloess/a4e6599e42bfeee0a91697db56844897 to your computer and use it in GitHub Desktop.
Save sfloess/a4e6599e42bfeee0a91697db56844897 to your computer and use it in GitHub Desktop.
FreeBSD

FreeBSD

Tips and Tricks for FreeBSD.

How To

  • Set

    • timezone: cp /usr/share/zoneinfo/EST5EDT /etc/localtime
    • Shell: bash: chsh -s /usr/local/bin/bash
  • Errors

  • Bash Completion

    • pkg install bash-completion
    • . /usr/local/share/bash-completion/bash_completion.sh
  • NFS

    • Ensure lock.d enabled: /etc/rc.conf: rpc_lockd_enable="YES"
  • NIS

    • Client
      • /etc/rc.conf
        • nisdomainname="[domain name]"
        • nis_client_enable="YES"
        • nis_client_flags="-S [nis server]"
      • /etc/master.passwd: +:::::::::
      • /etc/group: +:*::
  • Single User Mode:

    • mount -o rw /
    • ZFS: mount -u / ; mount -a -t zfs
  • What's using swap space?

    • top -oswap -w
  • Boot X11 mode

    • /etc/ttys: ttyv8 "/usr/local/bin/xdm -nodaemon" xterm on secure
  • Packages

    • List contents: pkg info -l [package]. Example: pkg info -l tigervnc-server
  • Install via Cobbler

  • Print ip address: ifconfig

  • Enable a service: sysrc [enable var]=YES. Example: sysrc grafana_enable=YES.

  • Format USB

    • Examples:
      • gpt/freebsd-ufs:
        • gpart destroy -F /dev/da0
        • gpart create -s gpt /dev/da0
        • gpart add -t freebsd-ufs /dev/da0
        • newfs /dev/da0p1
      • mbr/fat32
        • gpart destroy -F /dev/da0
        • gpart create -s mbr /dev/da0
        • gpart add -t fat32 /dev/da0
        • newfs_msdos -L FILES -F 32 /dev/da0s1
  • Run Linux Browsers (for example Vivaldi).

    • git clone https://github.com/mrclksr/linux-browser-installer.git
    • cd linux-browser-installer
    • ./linux-browser-installer install vivaldi
  • freebsd-update fetch
  • freebsd-update install
  • pkg update
  • pkg upgrade

Some base apps:

  • pkg install -y openjdk8 openjdk11 openjdk17 htop vim rsync terminator bash bash-completion libreoffice postfix git firefox chromium virt-manager

Some desktops:

  • pkg install -y xorg sddm fvwm lxde-meta lxqt kde5

Unattended Installation

  • /boot/loader.conf: vfs.root.mountfrom="cd9660:/dev/cd0"
  • /etc/installerconfig:
PARTITIONS="vtbd0"                                                                                                     
DISTRIBUTIONS="kernel.txz base.txz"                                                                                    
                                                                                                                       
#!/bin/sh                                                                                                              
                                                                                                                       
# Set up Networking                                                                                                    
#hostname vanilla-vm                                                                                                   
                                                                                                                       
env > /var/log/sfloess.env                                                                                             
                                                                                                                       
#echo 'hostname="vanilla-vm"'  >> /etc/rc.conf                                                                         
echo 'ifconfig_vtnet0="DHCP"' >> /etc/rc.conf                                                                          
echo 'sshd_enable=YES'        >> /etc/rc.conf                                                                          
                                                                                                                       
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config                                                                     
                                                                                                                       
# Set Time Zone                                                                                                        
/bin/cp /usr/share/zoneinfo/EST5EDT /etc/localtime                                                                     
/usr/bin/touch /etc/wall_cmos_clock                                                                                    
/sbin/adjkerntz -a                                                                                                     
/usr/sbin/ntpdate -u ntp.flossware.com                                                                                 
                                                                                                                       
#Set Default Root Password                                                                                             
# 1. echo  into -h 0                                                                                                   
# 2. echo  into -H 0                                                                                                   
# Use one or the other. Ex:                                                                                            
echo cobbler | pw usermod root -h 0                                                                                    
                                                                                                                       
poweroff

ActiveMQ

/usr/local/etc/rc.d/activemq:

#!/bin/sh
#
# PROVIDE: activemq
# REQUIRE: DAEMON
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable activemq:
# activemq_enable="YES"
# activemq_flags="<set as needed>"

. /etc/rc.subr

name="activemq"
rcvar=activemq_enable

export JAVACMD=/usr/local/openjdk14/bin/java
export JAVA_HOME=/usr/local/openjdk14

client="/usr/local/opt/apache-activemq/bin/activemq"

load_rc_config ${name}

activemq_enable=${activemq_enable-"NO"}
pidfile=${activemq_pidfile-"/usr/local/opt/apache-activemq/data/activemq.pid"}

start_cmd="${client} start"
stop_cmd="${client} stop"
reload_cmd="${client} reload"
status_cmd="${client} status"

run_rc_command "$1"

Nexus

/usr/local/etc/rc.d/nexus:

#!/bin/sh
#
# PROVIDE: nexus
# REQUIRE: DAEMON
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable activemq:
# nexus_enable="YES"
# nexus_flags="<set as needed>"

. /etc/rc.subr

name="nexus"
rcvar=nexus_enable

export JAVACMD=/usr/local/openjdk8/bin/java
export JAVA_HOME=/usr/local/openjdk8

client="/usr/local/nexus/bin/nexus"

load_rc_config ${name}

nexus_enable=${nexus_enable-"NO"}
#pidfile=${nexus_pidfile-"/usr/local/opt/apache-activemq/data/activemq.pid"}

start_cmd="${client} start"
stop_cmd="${client} stop"
reload_cmd="${client} reload"
status_cmd="${client} status"

run_rc_command "$1"

Raspberry PI-3

FreeBSD Instructions

Creds upon install: freebsd/freebsd or root/root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment