OpenBSD

Bigdata

How to Process Large Files … ? Large is a variable Term, 700 GB is large for me, while it could be a small peace for others. Assuming you need to count the lines … this simple Task can take minutes ! Size [user@host /tmp]$ du -sh bigfile 745G bigfile Wordcount -> 10 min if you need to count the lines, use the wordcount command and you get the exact number … but you have to wait for minutes, depending in your disk subsystem and the file size of course

Git

Some Git Commands Merge two Repos “merge unrelated histories” git pull origin master --allow-unrelated-histories git push git pull ###¬†Find deleted File git log --diff-filter=D --summary commit abcecadce91af3814662fa6a04d0f12e361f0574 Date: Sun May 31 23:19:59 2020 +0200 update delete mode 100644 master/sed.tcpdump commit 81ae58d70c27d02eb2f65beed4fe0b571073f087 Date: Fri May 29 16:06:14 2020 +0200 update Restore deleted File git checkout 81ae58d70c27d02eb2f65beed4fe0b571073f087 sed.tcpdump

OpenBSD 6.7

OpenBSD 6.7 appeared today OpenBSD has two new releases every year. historically, on 1. Mai and 1. November. With a few small execptions in the past Check Wikipedia so, then latest OS appeared today: OpenBSD 6.7 Perform a Full Upgrade (incl. X Stuff) sysupgrade -r Run the Script (on your own risk !) doas su - mkdir /root/bin ftp -o /root/bin/upgrade_to_67.sh https://puffy.nolink.ch/scripts/upgrade_to_67.sh chmod 740 /root/bin/upgrade_to_67.sh # /root/bin/upgrade_to_67.sh or use some custom Script (just Xbase and not other X Stuff) doas su - mkdir /root/bin cat <<'EOF' > /root/bin/upgrade_to_67.

OpenBSD Add Storage

you’ve got a maschine and you’re running out of disk space. attach a new disk like this: # fdisk -i sd1 Note: Substitue sd1 for your disk. ... # disklabel -E sd1 > p m > a a > quit # newfs sd1a # mkdir /data # mount /dev/sd1a /data/ and make permament in /etc/fstab

Sqlite

Do you like SQLite ? just started using it a bit more often … https://www.sqlitetutorial.net/ Query sqlite3 /path/to/db “select date,time,ip from table where ip='1.2.3.4’ limit 100; .schema show the database schema and indexes sqlite> .schema CREATE TABLE attack( "date" TEXT, "time" TEXT, "ip" TEXT, "asnr" TEXT, "ascountry" TEXT, "asdesc" TEXT, "port" TEXT, "proto" TEXT, "server" TEXT, "type" TEXT, "method" TEXT, "pass" TEXT, "user" TEXT, "ver" TEXT ); CREATE UNIQUE INDEX id on attack(date,time,ip,user,pass); Insert INSERT INTO table (column1,column2 ,.

Cron & Environment

Sometimes you run into problem because you’re not aware of the environment of cron. So, let’s dump and check the environment. Add Cronjob * * * * * env > /tmp/env.log Dump Content puffy200# cat /tmp/env.log LOGNAME=root HOME=/var/log PWD=/var/log PATH=/bin:/sbin:/usr/bin:/usr/sbin SHELL=/bin/sh USER=root

OpenBSD nginx cgi

… and you thought that cgi is dead … nginx.conf cat << 'EOF' > /etc/nginx/nginx.conf worker_processes 1; worker_rlimit_nofile 1024; events { worker_connections 800; } http { include mime.types; default_type application/octet-stream; index index.html index.htm; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; access_log syslog:server=unix:/dev/log,severity=notice main; keepalive_timeout 65; server_tokens off; server { listen 80; listen [::]:80; server_name localhost; root /var/www/htdocs; # FastCGI to CGI wrapper server # location /cgi-bin/ { #error_log /var/log/slowcgi/errors; fastcgi_pass unix:run/slowcgi.

OpenBSD httpd cgi

… and you thought that cgi is dead … httpd.conf cat << 'EOF' > /etc/httpd.conf types { include "/usr/share/misc/mime.types" } ## A minimal default server ## server "default" { listen on * port 80 log { access "default-access.log", error "default-error.log" } location "/cgi-bin/*" { fastcgi socket "/run/slowcgi.sock" root "/" } } EOF chmod 644 /etc/httpd.conf rcctl enable httpd rcctl start httpd Slowcgi rcctl enable slowcgi rcctl start slowcgi CGI cat << 'EOF' > /var/www/cgi-bin/test.

OpenBSD Current

OpenBSD Current Active OpenBSD development is known as the -current branch. These sources are frequently compiled into releases known as snapshots FAQ Assuming, you can’t wait for the next release, or you wanna test features, find bugs and so participate on the community, this little script will help you: Upgrade to Current and remove game*,comp*,xf* and xs* Packages before reboot cat << 'EOF' > upgrade_to_current.sh #!/bin/sh echo "let's check for news .

Doas

doas, an alternative to sudo Everybody knows sudo … right ? the bsd guys just hacked an alternative tool calleed doas … simple, secure and clever example follow later, here a good and quick tutorial. Introduction to doas on OpenBSD Quick and Dirty, Full Permission for group wheel su - if [ -f /etc/doas.conf ]; then echo "permit nopass :wheel" >> /etc/doas.conf else echo "permit nopass :wheel" > /etc/doas.conf fi chmod 600 /etc/doas.