My first steps with FreeBSD¶
Introduction¶
This page describes the few things I’ve done with FreeBSD after installing a FreeBSD 12.1 virtual machine.
Shutting down FreeBSD¶
You can trigger the FreeBSD shut down and power down with the following command (as root):
halt -p # As root.
Tweaking SSH server configuration¶
You may need to tweak the SSH server configuration, for example to allow root
password login (although it’s not recommended in the general case).
Edit /etc/ssh/sshd_config
as instructed in the SSH page and restart the sshd
service (as root) with:
service sshd restart # If sshd_enable is set to YES in /etc.rc.conf.
or:
service sshd onerestart # If sshd_enable is not set to YES in /etc.rc.conf.
Fixing a slow boot issue (“unqualified host name; sleeping for retry”)¶
If you have provided an unqualified host name during the installation, you probably have the FreeBSD slow boot issue described here.
Just edit /etc/rc.conf
and make sure the hostname value is fully qualified
(i.e. contains a dot).
You can output the host name with:
hostname
Having root’s shell history stored to file¶
On FreeBSD, root’s shell is tcsh. The command history
is not stored to file by default. The following two commands add lines to the
~/.cshrc
file which should cause the command history to be stored to file
~/.shell_history
:
echo "set histfile = ~/.shell_history" >> ~/.cshrc # As root.
echo "alias precmd 'history -S; history -M'" >> ~/.cshrc # As root.
(It is assumed that variables history
and savehist
were already set by
.cshrc
.)
Installing Bash¶
For non root users, the default shell on FreeBSD is /bin/sh
. Linux users
may feel more comfortable with Bash instead.
The following command shows that Bash is available on FreeBSD:
pkg search bash
(If you’re running a pkg
command for the first time, make sure to run it
as root because it will fetch and install the package management tool and
this will fail if you are not root.)
Install Bash as root with:
pkg install bash bash-completion # As root.
Changing user’s shell to Bash¶
As a “normal” (non root) user, you can change your shell to Bash with:
chsh -s /usr/local/bin/bash
Create a ~/.bashrc
file with the following content to enable the Bash
completion library:
Making it possible for a “normal” user to change user to root (with su -
)¶
On FreeBSD, only users who are in the wheel
are allowed to change user to
root. You can add (as root) a user in the wheel
group with:
pw usermod <username> -G wheel # As root
Searching / installing binary packages¶
You can install binary packages (for example GNU make and Git) with commands like (as root):
pkg install gmake git # As root.
After the installation of a package, a message is sometimes displayed. You can view this message later with a command like:
pkg info -D git
You can search the package repository catalogues with commands like:
pkg search vim