Find files with ack and replace string with sed

ack is a nice to tool to search in files in your current directory and subdirectores, but ack won't do search and replace. Luckily, we can easily combine ack and sed using xargs.

ack -l "app.kubernetes.io/name: myapp" | xargs sed -i 's|app.kubernetes.io/name: myapp|app …

Continue reading »

OpenWRT hourly speedtest maximum bandwidth delivered by ISP

Work in progress, place holder, these are the commands required to run the python code that I wrote

opkg install python3-light opkg install python3-email

opkg install python3-openssl opkg install python3-codecs

opkg install ca-certificates

Continue reading »

Setup IPv6 in Tsinghua on Linux(ArchLinux))

Tsinghua university uses ISATAP to provide IPv6 connectivity to students. In Linux you can use the isatapd program to create an ISATAP tunnel based on an IPv4 device.

You can use the isatapd command as follows to establish an ISATAPD tunnel:

isatapd --router isatap.tsinghua.edu.cn

After connecting check …

Continue reading »

Create Linux bridge without losing existing connection

The dillemma: You're accessing your server via SSH through interface eth1.102 with the ip 10.20.0.2/24 and gateway 10.20.0.1. Now you want to add eth1 to a linux bridge so you can hookin VMs on a vlan trunk.

Solution: Create a script which …

Continue reading »

Docker get private ip address of container

In order to access other containers from a container it's needed to get the private IP address of the other containers. The following command is able to get the private ip address of the container.

$ docker inspect --format="{{.NetworkSettings.IPAddress}}" $CONTAINER_ID_OR_NAME
172.17.0.15

Continue reading »

Docker Multiple websites/domains on single ip/host tutorial using a HAproxy as reverse proxy

This post will describe how to expose multiple docker containers running websites on port 80 using HAproxy as a reverse proxy. This makes it possible to run multiple websites on different domains on a single public ip of the host.

The basic setup is to create 1 container for haproxy …

Continue reading »

Move first word to end of line (Linux/awk)

Move the first word of a line to the end of line on Linux using AWK. We first store the first column(first word) in the variable t. Then we set the first column to be empty. At last we add a new column after the last column of the …

Continue reading »

SSH to server behind a firewall via an SSH tunnel

A server behind a firewall was unaccesible from my home, but another server which is on the same local network had public SSH access from my home. So we can create an SSH tunnel via this public server to the server behind a firewall.

For example the public ssh server …

Continue reading »

Using nested tmux over ssh and how to detach a nested tmux

Today I logged in to my laptop at home from work which was already running a tmux session, so thought yea just attach cool can continue with what I was looking at at home. I forgot that the keys would be the same ofcourse, and was unable to use the …

Continue reading »

Remove/detach a PCI device linux (kvm VGA passthrgough Nvidia Quadro 2000)

Answer:

echo -n "1" > /sys/bus/pci/devices/0000:02:00.0/remove

Where 0000:02:00.0 is related to your pci device address which can be obtained from the command lspci

Related story:
Was working on KVM vga passthrough and encountered problems with the graphics card nvidia Quadro …

Continue reading »