FreeBSD s a complete operating system with a large collection of tools in the base system. FreeBSD also provides two ways for installing third-party software: the FreeBSD Ports Collection, for installing from source, and packages, for installing from pre-built binaries.
I am not going to go into how to set up packages or ports, this is well documented at About FreeBSD ports and Installing Applications: Packages and Ports.
When you start installing third party applications on FreeBSD you must decide if you will use ports or packages. It is a really bad idea to mix binary packages and self compiled ports on the same system. Everything will go well for a while and suddenly you do an update that breaks everything. Stick with one way of installing third party software, if you decide you need to compile a single port yourself on a system with packages rather bite the bullit and move everything to ompiling ports.
You can search for available software at Searching FreeBSD Ports or Freshports. Freshports also allows you to create a watchlist for changes to software you are interested in.
To keep all third part software separate from the base system it will be installed in /usr/local
.
If you are not into fine tuning everything and are OK with the default options of packages you should use the binary packages provided by FreeBSD.
For both binary packages and ports you have to decide if you will follow the Quaterly or Latest branch of the software. The Quaterly branch is meant to be stable and does not receive feature updates of software but does receive security updates. The Latest branch will have the latest versions of the software available on FreeBSD.
If you are not happy with the options used by the FreeBSD packages or just like to finetune everything, or if you really need different options you can compile the ports yourself.
Again you are faced with choices, you can use poudriere, portmaster or simply use ports without any management software (don’t do the last one). Note: portmaster generates a package that is immediatly installed on your system. You can use pkg to manage those packages if you wish.
One thing that you must do if you compile ports yourself is read the /usr/ports/UPDATING file everytime you do updates.
If you have to manage more than one FreeBSD system it is highly recommended to use poudriere. Poudriere creates a local repository of packages you want. You can then install them on all your systems without recompiling the ports on every machine.
If you only have single machine to manage poudriere seems to me like a bit of an overkill and in this case I recommend using portmaster. If you use portmaster it is even more important to read /usr/ports/UPDATING.
Some Useful commands
If you delete a package the packages it depends on, that were automatically installed, do not get deleted. If you do a lot of experimenting with software your system may become littered with software you do not need anymore. Install the package/port pkg_rmleaves
to help you get rid of unneeded software. pkg autoremove
does a similar job but pkg_rmleaves
is more flexible.
pkg help
Gives you general help for the pkg command.
pkg help <command>
Gives you help for pkg <command>.
pkg info -l <package>
lists the files installed by <package>.
pkg info -r <package>
list the packages that require <package>.
pkg info -d <package>
lists the packages that <package> depends on.
pkg set -A 0 <package>
sets a <package> as not automatically installed to prevent pkg autoremove
from uninstalling it if there are no more packages dpending on it.
pkg lock <package>
prevents any changes to an installed <package>.
pkg unlock <package>
allows you to modify a previously locked <package>.
Create a repository of all packages on your system:
cd /path/with/enough/space
# pkg create -a
# pkg repo .
pkg query
is an advanced command to find information about packages. Read man pkg-query
for details.
Here are some examples from man pkg-query
pkg query %n-%v
List all installed packages by name-version.
pkg query %do <package>
List all dependencies for a package by origin.
pkg query %dn-%dv <package>
List all dependencies by package name-version.
pkg query %ro <package>
List all reverse dependencies for a <package>.
pkg query '%Fp %Fs' <package>
List all files and their known checksums for a <package>.
pkg query '%o: %Fp'
List all files for all packages.
pkg query -e '%#r = 0' %o
List all packages with no reverse dependencies.
pkg query -e '%a = 0' %o
List non-automatic packages.
pkg query -e '%a = 1' %o
List automatic packages.
pkg query -e '%m = [email protected]' %o
List unmaintained packages.