Test color support in bash

for i in {0..255} ; do printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i" if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then printf "\n"; fi done

November 18, 2017  |  🏷️Bash

Simple reverse proxy with socat

Open local port 5901 to be reached from anyone by connecting to localhost:8080 socat TCP4-LISTEN:8080,fork TCP4:localhost:5901

April 28, 2017  |  🏷️Socat

Debian: Unattended upgrades

Description: Install unattended-upgrades. The server should run unattended upgrades every night, and reboot at 4 am if required by any application. Implementation: Login as root Install packages unattended-upgrades and cron-apt Set the following values in /etc/apt/apt.conf.d/50unattended-upgrades Unattended-Upgrade::Origins-Pattern { "o=Debian,a=stable"; }; Unattended-Upgrade::MinimalSteps "true"; Unattended-Upgrade::InstallOnShutdown "true"; Unattended-Upgrade::Mail "root"; Unattended-Upgrade::MailOnlyOnError "true"; Unattended-Upgrade::Remove-Unused-Dependencies "false"; Unattended-Upgrade::Automatic-Reboot "true"; Unattended-Upgrade::Automatic-Reboot-Time "04:00"; Unattended-Upgrade::InstallOnShutdown "false"; Set the following values in /etc/apt/apt.conf.d/02periodic APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; APT::Periodic::AutocleanInterval "30"; Verification: Run unattended-upgrade --dry-run --debug as root....

Expect: Simulating ssh login

Clean #! /usr/bin/env expect set host [lindex $argv 0]; set user [lindex $argv 1]; set passwd [lindex $argv 2]; set timeout 5 spawn ssh $user@$host expect { "yes/no" { send "yes\r" exp_continue } "password:" { send "$passwd\r" exp_continue } "$user@$host:~? " { exit 0 } timeout { exit 2 } } exit 1 Wrapped inside bash #! /usr/bin/env bash assert_ssh_login() { local host="${1}" local user="${2}" local passwd="${3}" local details="$(echo -e "\ set timeout 5 \n\ spawn ssh ${user}@${host} \n\ expect { \n\ \"yes/no\" { \n\ send \"yes\r\" \n\ exp_continue \n\ } \n\ \n\ \"password:\" { \n\ send \"${passwd}\r\" \n\ exp_continue \n\ } \n\ \n\ \"${user}@${host}:~?...

October 20, 2015  | 

Configure static eth0 in /etc/network/interfaces

Description: The first step is to establish basic network connectivity for your router/gateway. This will allow you to connect to the installation server on the distribution network, from which you can install the routing software needed in later steps. Your router needs three network interfaces: the loopback interface (lo; which is used for network connections within the gateway) the interface connected to the distribution network (eth1) the interface connected to your network (eth0)....

Configure static wlan0 in /etc/network/interfaces

Get wpa-psk by running wpa_passphrase MyNetwork MyPassphrase. /etc/network/interfaces should be chmod 0600 if you put the wpa-psk there source /etc/network/interfaces.d/* # The loopback network interface auto lo wlan0 iface lo inet loopback iface wlan0 inet dhcp wpa-ssid MyNetwork wpa-psk a2d024861ef90117c47083c9252d1e9c107c7cc6ab938cd08349c9192d444d2f

Enabling read/write to USBHID

Add read/write for group plugdev echo 'KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", GROUP="plugdev"' | sudo tee /etc/udev/rules.d/99-hidraw-permissions.rules # Check that you have the group plugdev groups # If you cannot see plugdev there, type this: sudo usermod -aG plugdev $USER # Now it should work (otherwise reboot or replug usbhid device)

Archlinux: Installing from AUR

Links Official Guide Before you start Make sure you’ve configured /etc/makepkg.conf Download the package’s PKGBUILD-file from AUR (under View PKGBUILD under Package Actions on the right side) Making Put the PKGBUILD-file in a separate folder, maybe $HOME/tmp cd to the folder run makepkg -s a. Does it want you to install any application? Press yes b. Does it need some other package from AUR? Install that first You should now have a pkg....

Building debian packages

Links Official Manual Example building sudo-1.8.11p1-2 # Download the source files curl -O http://ftp.de.debian.org/debian/pool/main/s/sudo/sudo_1.8.11p1-2.dsc curl -O http://ftp.de.debian.org/debian/pool/main/s/sudo/sudo_1.8.11p1.orig.tar.gz curl -O http://ftp.de.debian.org/debian/pool/main/s/sudo/sudo_1.8.11p1-2.debian.tar.xz # Extract the tarballs: tar xf sudo_1.8.11p1-2.debian.tar.xz # Creates folder sudo-1.8.11p1 tar xf sudo_1.8.11p1.orig.tar.gz # Creates folder debian # Move the debian file to the source mv debian sudo-1.8.11p1 # Cd to the folder cd sudo-1.8.11p1 # Build dpkg-buildpackage -us -uc

October 27, 2014  |  🏷️Curl 🏷️Tar 🏷️Dpkg

Android Studio: Install Android Studio on Ubuntu

Download android studio Untar it to /opt/android-studio Symlink /opt/android-studio/bin/studio.sh to /usr/local/bin/android-studio Download oracle’s java Untar it to /opt/oracle-java (Ubuntu) Symlink /opt/oracle-java to /usr/lib/jvm/default-java (Ubuntu) Symlink /opt/oracle-java/bin/java to /usr/bin/java If you have a 64-bit system, you’ll need to install 32-bit libraries: # On ubuntu sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6

September 17, 2014  |  🏷️Apt-Get