tmux cheat sheet

Tmux cheat sheet Intro I am trying to use tmux more than screen, but a cheat sheet could be usefull. Quick and dirty tmux detach from window ctrl-b d list sessions tmux ls connect to session tmux at -t create session tmux new -s “session_name” “command” create detached sessioni tmux new -d Extra info split window in multiple pane split horizontal ==== ctrl-b " split vertical || ctrl-b % move to other pane ctrl-b cursor-key-direction
One minute to read

Vim things i forget all the time

Introduction I try to put here some VIM keybindings, that i forget all the time so that i can find them easily, and maybe it will also help someone else. Recording Start recording press q in normal mode followed by a letter ( a to z) Stop recodring press q in normal mode again Replay recording @ Replay the last replay @@ More info you can find on Vim Tips Wiki Or sudo stuff Sudo TIps
One minute to read

Opyrator instant python web function

How to test opyrator in linux Introduction With opyrator you can create a web function from any python function, it used fastapi, streamlit and pydantic. For this example i just wanted to test what is posible also using pydantic to change some input and output field Setup Start by creating your python virtual environment and activating it python3 -m venv opyrator cd opyrator source bin/activate After that you can install opyrator and what is more needed
One minute to read

loop device mount partitions

If you have a disk image with multiple partitions, this type of image is used a lot for the raspberry pi, you can easily mount them using kpartx, you can install kpartx as follows

arch linux / manjaro sudo pacman -S multipath-tools # ubuntu 24.04 sudo apt install kpartx # centos 8 / oracle sudo yum install kpartx Maybe you need to insert the loop module, if so you can do that like this

One minute to read

Selinux Short

I few shorts remarks about selinux, more like a reminder for myself Restore directory permissions, exmple authorized keys files that doesn’t work restorecon -R -v ~/.ssh How to temporarily disable selinux, i use this for debugging to see if the problem is selinux echo 0 >/selinux/enforce # or setenforce 0 And to enable them again use echo 1 >/selinux/enforce # or setenforce 1
One minute to read

Split a mysql dump in databases

Hello, I once needed to split a mysql dump in to multiple files, one per database so i used this awk one liner. awk -F'`' '{if ($0 ~ /^– Current Database:/) db=$2; print >> db"-split.sql"}' mysql_dump.sql If you need to split one table from one database you can try the following bash scripts !/bin/bash export DATABASE="$1" export TABLE="$2" echo $DATABASE echo $TABLE awk '/Table structure for table .'$TABLE'.$/,/UNLOCK TABLES/{print}' $DATABASE-split.sql
One minute to read

Control cec_client as daemon on pi4

I wanted to control the my television and blu ray player/receiver from my pi, so i installed the client on my raspbian pi installation. Everytime cec_client start it’s does some initializing, so i wanted to run is as some kind of daemon, i thought about a fire options, like maybe some expect kind of script without daemoniziing or a python with python expect to run it and control it, with mayne a socket.
2 minutes to read

reattach ssh or script to new tty

Once in a will you need you have a lang running script that you started into a shell but you want to transfer it to a screen. For this i am using the reptyr program which i installed with sudo pacman -S reptyr or sudo apt-get install reptyr find pid ps ax | grep ssh # find pid 34177 (for example) # start a screen screen -S my_screen_name # in de screen start reptyr reptyr 34177 if you get a issue with ptrace scope just change this value echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
One minute to read

Screen or Daemontools

If you want to start some daemon in the background you can install daemontools and user supervise, but i like to use screen to start daemons in the background, so that i can easily see the output.

check screen if ! /usr/bin/screen -ls | awk '{print $1}' | grep ".${SCREEN_NAME}$" >/dev/null; then echo "starting $SCREEN_NAME" screen -S "${SCREEN_NAME}" -d -m "$COMMAND_SCRIPT" fi I use this snippet, to check of a screen with a given name exists and if not start it up, i run a script i call screen-ls.

4 minutes to read

Boot Raspberry Pi over NFS

The Raspberry Pi is typically booted from an SD card which contains the bootloader and the root partition. This can be limiting from a space and speed perspective,and writes to the card will slowly cause it’s death. SD media doesn’t typically use the same wear leveling technology that goes into a solid state drive. Today I’ll take a quick look at how you can boot your Pi from an NFS server.
One minute to read