Hi I lost my usb sticks to reinstall Freebsd. I lost my X so I need to delete /usr/local/ and start again from there. I don't care about /usr/local/etc
pkg prime-origins > /root/mypackagelist.txt
cp -axfvR /usr/local/etc /root/backup_usr_local_etc
rm -vfR /usr/local
mkdir /usr/local
pkg update -f
pkg upgrade -f
This will delete all files that were installed by package/port installation, and also the package database. So it will be as if you never installed any software other than the base installation.
pkg clean
pkg clean -a
pkg info | awk '{print $1}' | grep -v "pkg-" | xargs -I {} pkg remove -f -y {}
pkg remove -f pkg
cd /usr/local
#rm -vfR bin include lib libexec man sbin zap