# FreeBSD

## Files

The `/etc/master.passwd` file stores both the user account info and their hashed passwords (is the merged version of `passwd` and `shadow` files in Linux). FreeBSD uses tools like `vipw` or `pw` to manage the `/etc/master.passwd` file:

> *The `wheel` group is the equivalent Linux `sudo` group.*

```bash
# Create the user bob and add him to the wheel group
sudo pw useradd bob -m -s /bin/tcsh -G wheel
# Set the user's password
sudo passwd bob
# Add an existing user to an existing group
pw groupmod wheel -m bob
```

## Networking

{% tabs %}
{% tab title="Network Info" %}
General networking information, such as interfaces, IP addresses, and DNS:

```bash
ifconfig
```

{% endtab %}

{% tab title="ARP Table" %}
Check recent communications via the ARP table:

```bash
arp -a
```

{% endtab %}

{% tab title="Active Connections" %}
List active connections:

```bash
# List active sockets
$ sockstat -4l
```

{% endtab %}

{% tab title="Routes" %}
List recent and persistent routes:

```bash
netstat -rn
route -n
```

{% endtab %}
{% endtabs %}

## Doas

`doas` is a simplified alternative to `sudo`, originally from OpenBSD, and available on FreeBSD via ports/packages. Its job is to let users run commands as another user (often `root`) with fine-grained permissions defined in `/usr/local/etc/doas.conf`.

```bash
# Enumerate doas permissions
$ cat /usr/local/etc/doas.conf
...
# Permit members of the wheel group to perform actions as root.
permit nopass :wheel

# Add an existing user to an existing group
doas pw groupmod wheel -m bob
```
