OpenBSD stuff - Home

Using mini PCs for home networking tasks

OpenBSD bridging firewall

OpenBSD DNS, DHCP and HTTP server

Shell Basics & Handy Commands

echo $0
echo $SHELL

which ksh

Ctrl K = cut everything from the cursor to the end of the line
Ctrl U = cut everything from the cursor back to the start of the line
Ctrl W = cut the word before the cursor
Ctrl Y = paste

Ctrl L = clear the screen
Ctrl E = move cursor to the end of the line
Ctrl A = move cursor to the beginning of the line
Ctrl D = log out if the line is empty, otherwise delete character under the cursor
Ctrl C = cancel the current command line
Ctrl ← / Ctrl → = move cursor one word left / right

File sizes

d = depth

du -h -d 1 /path/to/directory | sort -hr

Let's make a USB drive

Plug in the USB flash drive

sd2 is the USB drive in this example

dmesg | grep ^sd

# disklabel sd2
# disklabel -E sd2

Interactive disk label session

sd2> a a          |
offset: [64]      |
size: [*]         |
FS type: [4.2BSD] |
sd2*> w           |
sd2> q            |
# disklabel sd2
# newfs sd2a
# mkdir -p /mnt/usb
# mount /dev/sd2a /mnt/usb
# umount /mnt/usb

Picture 1

shyster

Random shit

$ systat -ahN netstat

$ pkg_info -a -Q py3 | grep -i requests
$ pkg_add -s py3-requests

# tcpdump -n -e -ttt -i pflog0
# pfctl -vvsr | grep ^@
# tcpdump -l -e -n -ttt -r /var/log/pflog | grep "rule 11"

Picture 2

shyster

tmux basics

" tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached. "

tmux                    # start a new session with a default name
tmux new -s mysession   # start a named session

Detach (leave the session running in the background):
Press Ctrl-b then d.

List sessions

tmux ls

Re‑attach to a session:

tmux attach -t mysession

Re‑attach last session:

tmux a

Windows

Ctrl-b c New window
Ctrl-b w List windows
Ctrl-b n Switch to next/previous window
Ctrl-b p Switch to previous window
Ctrl-b N Jump to window N (where N is 0-9)
Ctrl-b , Rename current window (type the name)
Ctrl-d   Close current window

Panes (splits within a window)

Ctrl-b " Split horizontally (top/bottom)
Ctrl-b % Split vertically (left/right)
Ctrl-b o Cycle through panes
Ctrl-b ↑ Move to pane (arrow keys)
Ctrl-b x Close pane


Heikki Vuojolahti

www.ghr.fi