Skip to content
Basim Ramadhan edited this page Jun 1, 2017 · 24 revisions

Welcome to the lovelace-website wiki!

Setting up a FreeBSD server from scratch

  1. Create a FreeBSD 11.0 server on DigitalOcean.
  2. Log into the server: ssh freebsd@<server_ip>
  3. Set up a password for the root user: su root then passwd
  4. Set up a password for the freebsd user: as root, run passwd freebsd then exit
  5. Disable SSH access for the root user:
    • open the SSHd condig: sudo vim /etv/ssh/sshd_config
    • update the following line to read: PermitRootLogin without-password
    • restart SSHd: sudo service sshd restart
  6. Change default shell to tcsh: chsh
  7. Basic shell setup:
    • get a starter shell config file: cp /usr/share/skel/dot.cshrc ~/.cshrc
    • open the shell config file: vim ~/.cshrc
    • choose a default editor (ex: vim, ee): setenv EDITOR vim
    • choose a default pager (ex: less): setenv PAGER less
    • without closing the file, append the following to the bottom for navigation key support in the shell:
if ($term == "xterm" || $term == "vt100" \
            || $term == "vt102" || $term !~ "con*") then
          # bind keypad keys for console, vt100, vt102, xterm
          bindkey "\e[1~" beginning-of-line  # Home
          bindkey "\e[7~" beginning-of-line  # Home rxvt
          bindkey "\e[2~" overwrite-mode     # Ins
          bindkey "\e[3~" delete-char        # Delete
          bindkey "\e[4~" end-of-line        # End
          bindkey "\e[8~" end-of-line        # End rxvt
endif
  1. Update shell config: source ~/.cshrc
  2. Check for base operating system updates: sudo freebsd-update fetch install, restarting with sudo shutdown -r now if kernel updates were installed
  3. Set up automatic checking for base operating system software updates:
    • open the crontab file: sudo vim /etc/crontab
    • append the following line: @daily root freebsd-update -t freebsd cron
    • that will check for updates daily and notify the freebsd user
    • check for notifications with: mail
    • if there are updates available, install them with sudo freebsd-update install
    • remember to restart after kernel updates!
  4. Fetch the ports tree: sudo portsnap fetch extract (one-time setup)
  5. Check for package updates:
    • update the ports tree: sudo portsnap fetch update
    • fetch most recent package database information: sudo pkg update
    • run pkg version -vRL= for available package updates
    • check the notes before updating: less /usr/ports/UPDATING
    • proceed with updating packages: sudo pkg upgrade
  6. Package management:
    • finding packages: pkg search <name>
    • installing packages: `sudo pkg install
    • after installing package a package, run rehash to update PATH
    • viewing package information: pkg info <name>
    • removing packages: sudo pkg delete <name>
    • removing unused dependencies: sudo pkg autoremove
    • list installed packages: pkg info
    • check for security vulnerabilities in installed packages: pkg audit -F
  7. Service management:
    • enabling services: sudo sysrc <name>_enable=yes (this will append to /etc/rc.conf)
    • to enable a service means auto-starting on boot, as well as allowing users to manually start it
    • starting services: sudo service <name> start (service must have been enabled first)
Clone this wiki locally