Files
Command_Line_Cheat_Sheet/FreeBSD.md
T
2026-10-30 15:17:46 +01:00

128 lines
2.4 KiB
Markdown

# FreeBSD Cheat Sheet
A collection of commands I use frequently and still don't remember.
## pkg
### Display the message after first installing the application
```sh
pkg show -D <pkg_name>
```
## iocage
### Setup a new jail with vnet
```sh
iocage create -n <jailname> ip4_addr="10.192.0.28/24" defaultrouter="10.192.0.1" allow_raw_sockets=1 vnet=on boot=on interfaces="vnet0:em0bridge" -r 13.2-RELEASE
```
## zfs
### Show holds on a specific snapshot
If snapshots return as dataset is busy upon deletion, they are either dependent or use a tag that prevents them from being deleted. The command below will display any holds on a snapshot.
```sh
zfs holds -r <snapshot_name>
```
To release the snapshot from a tag
```sh
zfs release -r <tag_name> <snapshot_name>
```
### Migrate dataset to new pool
```sh
zfs snapshot -r old_pool/<dataset_name>@relocate
zfs send -Rv old_pool/<dataset_name>@relocate | zfs receive -d new_pool/<new_dataset_name>
```
## tcsh
### Execute command from history
```sh
history | grep <command>
!<id command>
```
### For loop to copy files and rename in destination
```sh
foreach f (*.jpg)
cp "$f" /destination/newname-"$f"
end
```
Use quotes if filenames have spaces
## Bind
### Adding a new Zone with DNSSEC to bind
Add the new zone to named.conf in /usr/local/etc/named
``` sh
zone "example.com" {
type master;
file "/etc/bind/zones/db.example.com";
#dnssec-policy default; // Uses the built-in default policy
#inline-signing yes; // Required for automatic signing
};
```
Check configuration
```sh
named-checkconf
named-checkzone example.com /etc/bind/zones/db.example.com
rndc reload
```
Sign the zone by setting policy and type of signing
``` sh
zone "example.com" {
type master;
file "/etc/bind/zones/db.example.com";
dnssec-policy default; // Uses the built-in default policy or create / apply one
inline-signing yes; // Required for automatic signing
};
```
Create the folder under keys/ if needed
``` sh
mkdir keys/example.com
```
Check DNSSEC records
``` sh
named-checkconf
rndc reload
dig @localhost DNSKEY example.com
```
Add created DS key to registrar
```
dnssec-dsfromkey Kexample.com.+013+<key_id>.key
```
On secondary node do following:
``` sh
zone "example.com" {
type secondary;
primaries { 192.168.1.10; }; // Primary server IP
file "/var/cache/bind/db.example.com"; // Slave zone files usually stored in cache directory
};
```