Install FreeBSD operating system
FreeBSD operating system
Topics covered:
- 1.1FreeBSD installer media
- 1.2FreeBSD system install
- 1.2.1FreeBSD boot menu
- 1.2.2FreeBSD installer
- 1.3FreeBSD System Setup
- 1.3.1Sudoers
- 1.3.2Software update
- 1.3.3Bash shell
- 1.3.4System time
Affiliate links
Running a custom FreeBSD web server requires a VPS or a cloud server with root access. Use our affiliate links to purchase a VPS or cloud server from third-party vendors. The affiliate commissions we earn facilitate, Free website access for everyone.
- Cloudways WordPress VPS hosting
- Linode VPS hosting $100 credit
- Tastytrade invest in US markets
- Vultr VPS hosting $100 credit
The affiliate links are listed in alphabetical order without any favor. Users are encouraged to refer to the Global Webdynamics LLP Terms of Service governing the Third-party vendors.
1.1FreeBSD installer media
The
amd64
is the popular desktop, laptop, and server processor architecture. Visit the official FreeBSD website and download the FreeBSD operating system installer file
FreeBSD-<version>-RELEASE-amd64-memstick.img
to the download directory. Replace
<version>
tag with the operating system version that you intend to download. FreeBSD also supports
arm64
machine architecture.
The FreeBSD USB memory stick image file doesn't contain the pre-built packages and software applications required for offline installation. For offline installation, use the FreeBSD DVD ISO image file.
On a Unix-like machine, use the
dd
command-line utility to burn the
memstick.img
file onto the USB flash drive. Use an Image to USB burner application on a non-Unix-like system to burn the
memstick.img
file onto the USB flash drive.
1.2FreeBSD system install
Plugin the bootable USB flash drive. Power-on or restart the system. On startup, press the system boot option key (e.g.,
F10
,
F11
, or
F12
) a couple of times until the system switch to the BIOS menu. Configure the system BIOS to boot from the USB flash drive. Save the changes and exit the system BIOS to start the FreeBSD installation.
1.2.1FreeBSD boot menu
By default, the FreeBSD boot menu starts with the
Boot Multi user
option selected. Press the
Enter
key to start the installation process or wait until the timer countdown for the installation process to auto start.
1.2.2FreeBSD installer
The
FreeBSD Installer
application will ask for multiple configuration questions during the installation process to configure the FreeBSD operating system. With the default
Install
option selected on the
Welcome
screen, press the
Enter
key to start the installation process.
Following are some of the system configuration questions that a user needs to answer to complete the system installation:
1.2.2-1Keymap Selection
Press
Enter
key to
Continue with default keymap
. FreeBSD selects the US keyboard as the default keymap. To choose a different keymap, the user can navigate the
Keymap Selection
menu using the
Up
and
Down
arrow keys to browse the options and select the particular option by pressing the
Spacebar
key.
1.2.2-2Set hostname
The user must choose the hostname that uniquely identifies a machine (desktop or server) on the network. The hostname can be a fully qualified domain name (FQDN), e.g.,
dev1.example.com
. If the machine is for personal use or application development, the user can name the machine as
localhost
.
1.2.2-3Distribution select
Select the
lib32
libraries and
ports
tree options for any generic installation. Optionally select the
src
(kernel and userland source code) component if the user needs to develop the kernel modules or device drivers.
1.2.2-4Partitioning
Select
Auto (UFS)
(Guided Disk Setup) for the disk space allocation. UFS stands for Unix Files System. If there is more than one disk on the system, choose the FreeBSD installation disk.
-
Partition:
SelectEntire Disk
and pressEnter
. On theConfirmation
window, selectYes
. This action will erase the entire disk. -
Partition Scheme:
SelectGPT
(GUID Partition Table) as the disk partition schema. The older systems that are not compatible withGPT
must chooseMBR
(DOS Partitions). -
Partition Editor:
Review the disk partition schema setup. Select theFinish
and pressEnter
. On theConfirmation
window, selectCommit
. The installation process will start by fetching the distribution files and installing them on the system.
1.2.2-5Set root password
The FreeBSD system, by default, has a
root
user. The
root
user will have all the superuser privileges for conducting any system transaction. In this step, set the
root
user password.
1.2.2-6Network configuration
Choose either Ethernet or Wireless network interface to configure. Select
OK
, and press
Enter
. If the wireless network interface is selected, then in the next
Network Selection
window, select the wireless network
SSID
. In the
WPA Setup
window, type the
WPA2
password for the
SSID
.
-
IPv4:
Choose the IPv4 network interface by selectingYes
and pressingEnter
key. -
DHCP:
SelectYes
and pressEnter
to enable DHCP. The DHCP server will dynamically configure the IPv4 network configurations. -
IPv6:
SelectNo
to disable the IPv6 network interface.
1.2.2-7Time zone selector
Use the
Up
and
Down
arrow keys to select a region and then a country. Next, confirm the country's Time Zone code by selecting
Yes
and pressing
Enter
. In the next
Time & Date
window, choose a current date (month, year, and day), select
Set Date
, and press
Enter
. You may skip the
Set Time
section by selecting
Skip
.
1.2.2-8System configuration
Navigate the system services list using arrow keys and select the services that need to start on system boot by pressing
Spacebar
. Select the following services:
sshd
,
moused
,
ntpd
,
powerd
, and
dumpdev
. Select
OK
, and press
Enter
.
1.2.2-9System hardening
The user may choose one or more system hardening (security) options to enhance FreeBSD system security. Select
disable_sendmail
(Disable Sendmail service). Select
OK
, and press
Enter
.
1.2.2-10Add user accounts
To add a new user to a system (this user will have fewer privileges than the root user), select
Yes
and press
Enter
. Except for the following fields, choose the default value by pressing
Enter
.
-
Username:
freebsd -
Full name:
Global Webdynamics -
Login group is freebsd. Invite freebsd into other groups? []:
wheel -
Enter password:
**** -
Enter password again:
**** -
OK? (yes/no):
yes -
Add another user? (yes/no):
no
The Username
is a unique user id required to log in to the system. The Username is case-sensitive and cannot contain spaces. The convention is to choose the lowercase Username (e.g., freebsd).
The Full name
is a user's system-wide display name. The Full name can contain spaces. The convention is to format the Full name as a title case (e.g., Global Webdynamics).
1.2.2-11Final configuration
In this step, the user can modify the list of system configuration settings, or if the user is satisfied with the current configurations, select
Exit
(Apply configuration and existing installer) to apply system configurations.
1.2.2-12Manual configuration
Before the reboot, if no additional system configurations are required, select
No
and press
Enter
.
1.2.2-13Complete
Congratulations! FreeBSD installation is complete. Time to reboot the system. Select
Reboot
and press
Enter
. On system reboot, the user should slip into the BIOS menu to change the boot option so that the system will boot from the hard disk drive (HDD).
1.3FreeBSD System Setup
On the first system reboot, log in as a root user. The hash (
#
) sign at the command prompt indicates that the user logged in as a
root
user. The following topics describe the FreeBSD basic system setup before installing the GUI (Graphical User Interface) desktop environment.
1.3.1Add freebsd user
Add the
freebsd
user if still not added to the system using the
adduser
command.
# adduser
Username: freebsd
Full name: FreeBSD
Uid (Leave empty for default):
Login group [freebsd]:
Login group is freebsd. Invite freebsd into other groups? []: wheel
Login class [default]:
Shell (sh csh tcsh bash rbash nologin) [sh]:
Home directory [/home/freebsd]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password: ****
Enter password again: ****
Lock out the account after creation? [no]:
Username : freebsd
Password : *****
Full Name : FreeBSD
Uid : 1001
Class :
Groups : freebsd wheel
Home : /home/freebsd
Home Mode :
Shell : /usr/local/bin/bash
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (freebsd) to the user database.
Add another user? (yes/no): no
Goodbye!
1.3.2Sudoers
Executing commands as a
root
user has unintended consequences if the user is not being careful. The safe and convenient way to execute commands with
root
privileges is by using
sudo
(superuser do) command.
Install the following applications: Bash shell, Nano editor, Rsync (file-copying tool), and Sudoers using a FreeBSD package (
pkg
) management utility.
# pkg install bash nano rsync sudo
View the list of system users that belong to the
wheel
group in the
/etc/group
file. Users that are members of the
wheel
group are allowed to use
sudo
. If the
freebsd
user has not yet been part of the
wheel
group, add the user to the
wheel
group by executing the following command.
# pw groupmod wheel -m freebsd
# Check wheel group users
# nano -w -c /etc/group
...
wheel:*:0:root,freebsd
...
Uncommenting the following line in the sudoers file will enable all users belonging to the
wheel
group to use
sudo
without entering a password.
# nano -w -c /usr/local/etc/sudoers
...
## Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL
...
Finally, switch the user to
freebsd
. Now
freebsd
user can execute commands with
root
privileges without entering a password every time. The dollar (
$
) sign at the command prompt indicates that the user logged in as a
freebsd
(non-root) user.
# su freebsd
freebsd@dev1:/root $
1.3.3Software update
Make sure the system is up to date. Update installed software (applications and libraries) from the package manager.
# Update installed software
$ sudo pkg update
# Upgrade installed software
$ sudo pkg upgrade
# Get kernel version
$ freebsd-version -k
13.0-RELEASE-p12
# Get userland version
$ freebsd-version -u
13.0-RELEASE-p12
1.3.4Bash shell
The user's current login shell (command interpreter) is in the password file
/etc/passwd
under the username (
freebsd
).
$ sudo nano -w -c /etc/passwd
...
freebsd:*:1001:1001:FreeBSD:/home/freebsd:/bin/sh
Change the
freebsd
user's current login shell to
bash
(Bourne-Again SHell).
$ sudo chsh -s /usr/local/bin/bash freebsd
chsh: user information updated
# Again, check the login shell
$ sudo nano -w -c /etc/passwd
...
freebsd:*:1001:1001:FreeBSD:/home/freebsd:/usr/local/bin/bash
1.3.5System time
The system sets the current date and time information from the time zone info file
/etc/localtime
. The zone info directory
/usr/share/zoneinfo
consists of a collection of zone info files for different regions (zones/cities).
The user can set a system time zone by copying the zone info file to
/etc/localtime
.
# List zone info files
$ ls -l /usr/share/zoneinfo
total 608
drwxr-xr-x 2 root wheel 1024 Aug 10 13:48 Africa
drwxr-xr-x 6 root wheel 3072 Aug 10 13:48 America
drwxr-xr-x 2 root wheel 512 Aug 10 13:48 Antarctica
drwxr-xr-x 2 root wheel 512 Apr 9 2021 Arctic
drwxr-xr-x 2 root wheel 2048 Aug 10 13:48 Asia
...
# To set the time to IST
$ sudo cp /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
# To set the time to UTC
$ sudo cp /usr/share/zoneinfo/UTC /etc/localtime
Affiliate links
Running a custom FreeBSD web server requires a VPS or a cloud server with root access. Use our affiliate links to purchase a VPS or cloud server from third-party vendors. The affiliate commissions we earn facilitate, Free website access for everyone.
- Cloudways WordPress VPS hosting
- Linode VPS hosting $100 credit
- Tastytrade invest in US markets
- Vultr VPS hosting $100 credit
The affiliate links are listed in alphabetical order without any favor. Users are encouraged to refer to the Global Webdynamics LLP Terms of Service governing the Third-party vendors.