How to Install Unrar on FreeBSD
This guide provides a straightforward walkthrough for installing the
unrar utility on FreeBSD to extract RAR archive files. It
covers the two primary installation methods supported by FreeBSD: the
binary package manager (pkg) for a quick and standard
setup, and the FreeBSD Ports Collection for compiling the tool directly
from source.
Method 1:
Installing via the Package Manager (pkg)
Using the binary package manager is the fastest and recommended method for most users because it downloads and installs pre-compiled binaries.
- Open your terminal and switch to root (or use
sudo). - Update the local package repository catalog:
pkg update - Install the
unrarpackage:pkg install unrar - When prompted to proceed with fetching and installing the package,
type
yand press Enter.
Method 2: Installing via the Ports Collection
If you prefer to compile software from source or need custom build options, you can use the FreeBSD Ports Collection.
- Ensure your ports tree is up to date. If not already extracted,
fetch it using:
(Or
portsnap fetch extractportsnap fetch updateif previously extracted). - Navigate to the
unrarport directory:cd /usr/ports/archivers/unrar - Compile and install the port:
make install clean
Verifying the Installation
After completing either installation method, verify that
unrar is properly installed by checking its version and
help menu:
unrarBasic Usage
To extract a RAR archive while preserving the internal directory structure, run:
unrar x archive_name.rarTo extract files into the current directory without subdirectories, run:
unrar e archive_name.rar