Category: Small hacks

  • Bulk modify PuTTY sessions

    The following script allows you to modify PuTTY sessions in a batch.

  • I’m a hybrid morning person

    What is a hybrid morning person you ask? I love working and getting things done in the morning, but from the comfort of my bed with my laptop on my knees.

  • Cleanup Linux logs

    I just had the case that my disk on a Linux VM ran full and I had to make space quickly. I was willing to sacrifice my journald logs in order to make the urgent update work and I was able to free up a few gigabytes of space with the following commands.

    journalctl --rotate
    journalctl --vacuum-time=1s

    This drops all the logs and frees up space immediately.

  • Wait for host in BaSH

    Okay, this one is a little specific, but I recently had this issue and I wanted to share it because knowing this would have saved me one scripting language and a lot of time. I have previously implemented this in PowerShell, but it can easily be done in BaSH as well.

    The premise was to setup a new virtual machine and before I could work with the machine I had to wait until it was created and powered up. The installation was done in a pipeline and so there was no interaction. The following script waits until the machine is available and can be pinged and then terminates. This is not a finished solution but a small part of the pipeline that allowed me to continue with the regular installation via SSH after the machine was available.

  • Get installed packages

    Assuming one needs to setup a LAMP server identically to a existing machine and it is important that all the specific packages are installed in order to guarantee a stable execution of the application. the following command prints out a single line list of installed packages for the provided search terms:

    dpkg -l | grep -E 'apache|mysql|php' | awk '{printf "%s ",$2} END {print ""}'

    Just change “apache|mysql|php” (RegEx!) with the packages you want to search and you get a list like the following:

    apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php libapache2-mod-php7.4 mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server mysql-server-8.0 mysql-server-core-8.0 php php-common php-composer-ca-bundle php-composer-semver php-composer-spdx-licenses php-composer-xdebug-handler php-curl php-gd php-imagick php-json-schema php-mbstring php-mysql php-psr-container php-psr-log php-symfony-console php-symfony-dotenv php-symfony-filesystem php-symfony-finder php-symfony-process php-symfony-service-contracts php-xml php-zip php7.4 php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-zip python3-certbot-apache

    On the target system just type (append the list):

    apt install -y apache2 apache2-bin ...

    And the same software is installed on the new server.