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

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

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

On-demand activation of Docker containers with systemd

On-demand activation of Docker containers with systemd One of the features of systemd is its ability to defer the start-up of networked applications until their services are actually requested, a process referred to as socket activation. This isn’t really a new an idea; systemd borrowed the idea from launchd which has been in OS X since Tiger’s release in 2005, and the venerable Unix inetd has implemented a simpler version of it since the 1980s.
One minute to read

Fu-rch GUI Arch Linux Installer Ready For Testing! | Jeff’s Home Served Linux Powered Blog

http://www.jeffstory.org/wordpress/?p=1070 This is the first time in the history of Arch Linux that a GUI installer has been available! Fu-rch is an “authentic” Arch Linux installer, it does not install a distro derived from Arch! The live CD comes loaded with the Fu-rch GUI installer, gparted for editing the partitions your HDD prior to installing Arch, pacaur AUR, a command line AUR package installation helper, and pkgbrowser, a GUI Arch repo and AUR package browser.
2 minutes to read

Start page – collectd – The system statistics collection daemon

http://collectd.org/ collectd gathers statistics about the system it is running on and stores this information. Those statistics can then be used to find current performance bottlenecks (i.e. performance analysis) and predict future system load (i.e. capacity planning). Or if you just want pretty graphs of your private server and are fed up with some homegrown solution you’re at the right place, too ;).
One minute to read