Post-installation Setup and Configuration

Post-installation Setup and Configuration

Last Updated on 2025-01-27 17:52 by Sture

Colorized Directory Listings

Description:

Enable display of colors to directory contents listing for command ls and ll.

Configuration

Add two alias commands to file .profile for the user user with:

user@freebsdsrv:~ $ echo 'alias ll="ls -lGF"' | tee -a .profile ; sudo echo 'alias ls="ls -GF"' | tee -a .profile [enter]
alias ll="ls l-GF"
alias ls="ls -GF"
user@freebsdsrv:~ $

…and for root with:

user@freebsdsrv:~ $ sudo echo 'alias ll="ls -lGF"' | sudo tee -a /root/.profile ; sudo echo 'alias ls="ls -GF"' | sudo tee -a /root/.profile [enter]
alias ll="ls l-GF"
alias ls="ls -GF"
user@freebsdsrv:~ $
Log off your system with:
user@freebsdsrv:~ $ exit [enter]

…and then log in to the FreeBSD server and see colors as in this example:

user@freebsdsrv:~ $ ls -l /usr/local [enter]
drwxr-xr-x   2 root wheel 11 Jan 26 17:20 bin
drwxr-xr-x   6 root wheel 14 Jan 26 17:22 etc
drwxr-xr-x   3 root wheel  7 Jan 26 17:20 include
drwxr-xr-x   3 root wheel 14 Jan 26 17:20 lib
drwxr-xr-x   4 root wheel  4 Jan 26 17:20 libdata
drwxr-xr-x   3 root wheel  3 Jan 26 17:20 libexec
drwxr-xr-x   2 root wheel  7 Jan 26 17:20 sbin
drwxr-xr-x  10 root wheel 10 Jan 26 17:20 share
user@freebsdsrv:~ $

/boot/loader.conf

The file loader.conf contains descriptive information on bootstrapping the system. Through it, you can specify the kernel to be booted, parameters to be passed to it, and additional modules to be loaded; generally, set all variables described in loader(8).

By default, the delay before automatically booting is set to 10 seconds.
In this example, the delay is set to zero seconds with:

autoboot_delay=”0″!
Reset content and add autoboot_delay=”0″ to file /boot/loader.conf and verify entries to file /mnt/boot/loader.conf with:

user@freebsdsrv:~ $ sudo sh -c 'echo -e "autoboot_delay=\"0\"" >> /boot/loader.conf' ; cat /boot/loader.conf [enter]
geom_mirror_load="YES"
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
cryptodev_load="YES"
zfs_load="YES"
autoboot_delay="0"
user@freebsdsrv:~ $

/etc/hosts

The host file /etc/hosts contains information regarding the known hosts on the network.
This file provides a backup used when the name server is not running.
Only a few addresses should be included in this file. These include addresses for the local interfaces that ifconfig needs at boot time and a few machines on the local network.

user@freebsdsrv:~ $ sudo sh -c 'cat <<EOF > /etc/hosts
#
# Host Database
#
::1           localhost localhost.local.lan
127.0.0.1     localhost localhost.local.lan
192.168.1.50  freebsdsrv freebsdsrv.local.lan
EOF' ; cat /etc/hosts [enter]
#
# Host Database
#
::1           localhost localhost.local.lan
127.0.0.1     localhost localhost.local.lan
192.168.1.50  freebsdsrv freebsdsrv.local.lan
user@freebsdsrv:~ $

/etc/resolv.conf

The resolver configuration file contains information that is read by the resolver routines the first time a process invokes them. The file is designed to be human-readable and contains a list of keywords with values that provide various types of resolver information.

To configure the FreeBSD server as a DNS client, you need to edit or modify the /etc/resolv.conf file to define which name servers should use.

Display content of file /etc/resolv.conf with:

user@freebsdsrv:~ $ sudo sh -c 'cat <<EOF > /etc/resolv.conf
#
# Resolver Database
#
domain local.lan
nameserver 192.168.1.1
nameserver 208.67.222.222
nameserver 208.67.220.220
EOF' ; cat /etc/resolv.conf [enter]
#
# Resolver Database
#
domain local.lan
nameserver 192.168.1.1
nameserver 208.67.222.222
nameserver 208.67.220.220
user@freebsdsrv:~ $

Verify Configuration with:

ping

ping – send ICMP or ICMPv6 ECHO_REQUEST packets to network hosts.

user@freebsdsrv:~ $ ping -c 3 freebsdsrv.local.lan [enter]
PING freebsdsrv (192.168.1.50): 56 data bytes
64 bytes from 192.168.1.50: icmp_seq=0 ttl=64 time=0.036 ms
64 bytes from 192.168.1.50: icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from 192.168.1.50: icmp_seq=2 ttl=64 time=0.026 ms

--- freebsdsrv ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.026/0.031/0.036/0.004 ms
user@freebsdsrv:~ $
user@freebsdsrv:~ $ ping -c 3 freebsdsrv [enter]
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.072 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.056 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.047 ms

--- localhost ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.047/0.058/0.072/0.010 ms
user@freebsdsrv:~ $
drill

drill is a tool designed to get all sorts of information out of the DNS.

user@freebsdsrv:~ $ drill freebsd.org [enter]
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 31073
;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 
;; QUESTION SECTION:
;; freebsd.org.	IN	A

;; ANSWER SECTION:
freebsd.org.	3600	IN	A	96.47.72.84

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 37 msec
;; SERVER: 192.168.1.1
;; WHEN: Fri Oct 28 13:35:22 2022
;; MSG SIZE  rcvd: 45
user@freebsdsrv:~ $

Networking restart

Network interface setup is done using the netif, and routing setup is done using the routing.

N.B.: Always restart the netif and routing services together to avoid lockdown issues!

The right way to restart networking services on FreeBSD is:

user@freebsdsrv:~ $ sudo service netif restart ; sudo service routing restart [enter]
Stopping Network: lo0 em0.
...
Starting Network: lo0 em0.
...
delete host 127.0.0.1: gateway lo0 fib 0: gateway uses the same route
delete net default: gateway 192.168.1.1 fib 0: not in table
delete host ::1: gateway lo0 fib 0: gateway uses the same route
delete net fe80::: gateway ::1
delete net ff02::: gateway ::1
delete net ::ffff:0.0.0.0: gateway ::1
delete net ::0.0.0.0: gateway ::1
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add net default: gateway 192.168.1.1
add host ::1: gateway lo0 fib 0: route already in table
add net fe80::: gateway ::1
add net ff02::: gateway ::1
add net ::ffff:0.0.0.0: gateway ::1
add net ::0.0.0.0: gateway ::1
user@freebsdsrv:~ $
user@freebsdsrv:~ $

Log Console Messages To File

Configuration:

Enable all writes to /dev/console during boot to be logged to file /var/log/console.log with:

user@freebsdsrv:~ $ sudo sed -e 's/#console.info/console.info/' -i "" /etc/syslog.conf && cat /etc/syslog.conf | grep console.info [enter]
console.info					/var/log/console.log
user@freebsdsrv:~ $

Create file /var/log/console.log and then change file modes to mode 600 with:

user@freebsdsrv:~ $ sudo touch /var/log/console.log && sudo chmod -vv 600 /var/log/console.log [enter]
/var/log/console.log: 0100644 [-rw-r--r-- ] -> 0100600 [-rw------- ]
user@freebsdsrv:~ $

Restart syslogd to log all new console messages to file /var/log/console.log with:

user@freebsdsrv:~ $ sudo service syslogd restart [enter]
Stopping syslogd.
Waiting for PIDS: 808.
Starting syslogd.
user@freebsdsrv:~ $

A reboot is required to record all console messages on the system boot.
Reboot the system with:

user@freebsdsrv:~ $ sudo reboot [enter]
Connection to 192.168.1.50 closed by remote host.
Connection to 192.168.1.50 closed.

Wait for the system to reboot, then log back in with a remote SSH client session.

Display file /var/log/console.log with:

user@freebsdsrv:~ $ sudo cat /var/log/console.log [enter]

…and look for ERRORs and WARNINGs.

Display lines with word warning, error or critical in file /var/log/console.log with:

user@freebsdsrv:~ $ sudo cat /var/log/console.log | grep -E -wi 'warning|error|critical' [enter]
user@ freebsdsrv:~ $

If any errors and warnings are found, fix the problem and restart service syslogd as described above.

Comments are closed.