OpenBSD bridging firewall
OpenBSD DNS, DHCP and HTTP server
$ 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
d = depth
du -h -d 1 /path/to/directory | sort -hr
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
$ 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" $ ls -lahF | grep "^d" && ls -lahF | grep "^-" && ls -lahF | grep "^l"
ls -lahF and ls -lhF with colors
Add the following to .kshrc in home folder.
ll() {
local target="${1:-.}"
ls -lahF "$target" | awk '/^d/ { print "\033[34m" $0 "\033[m"; next }
/^-/ { print $0; next; }
/^l/ { print "\033[36m" $0 "\033[0m"; next }
{ print $0 }
'
}
l() {
local target="${1:-.}"
ls -lhF "$target" | awk '/^d/ { print "\033[34m" $0 "\033[m"; next }
/^-/ { print $0; next; }
/^l/ { print "\033[36m" $0 "\033[0m"; next }
{ print $0 }
'
}
Following version groups and sorts output by file type (directories → files → links).
ll() {
local target="${1:-.}"
ls -lahF "$target" | awk '
/^d/ { dirs[dir_count++] = "\033[34m" $0 "\033[m"; next }
/^-/ { files[file_count++] = $0; next }
/^l/ { links[link_count++] = "\033[36m" $0 "\033[0m"; next }
END {
for (i = 0; i < dir_count; i++) print dirs[i]
for (i = 0; i < file_count; i++) print files[i]
for (i = 0; i < link_count; i++) print links[i]
}
'
}
l() {
local target="${1:-.}"
ls -lhF "$target" | awk '
/^d/ { dirs[dir_count++] = "\033[34m" $0 "\033[m"; next }
/^-/ { files[file_count++] = $0; next }
/^l/ { links[link_count++] = "\033[36m" $0 "\033[0m"; next }
END {
for (i = 0; i < dir_count; i++) print dirs[i]
for (i = 0; i < file_count; i++) print files[i]
for (i = 0; i < link_count; i++) print links[i]
}
'
}
Keyboard layout
$ cat /etc/kbdtype # kbd -l # wsconsctl keyboard.encoding=sv
sv is the same as Finnish layout
Picture 2
" 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
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
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