Posts

Keeping your (SVN) trunk in order

For unlucky few of us that still have to deal with subversion every now and then here is a reminder on how to keep your commit records in your trunk up to do date with your branches: First, you may excabercate what commits may be eligable for a merge into your trunk by executing this command: trunk> svn mergeinfo --show-revs eligible branches/BRANCH_NAME . It should result in a list of record entries that you may, thereupon, use for a true merge in case you need the commit for further trunk development or just commit record-only-merge in case the commit became obsolete: trunk> svn merge --record-only -c 123456 branches/BRANCH_NAME Afterwards, don't forget to commit your changes. Record-Only-Merges may look funny at first but will remove the commit record from the list of eligible merges for good :)

This and sed

Sed is a nice little tool that is quite hard to understand. While a longer tutorial can be found here . I found it especially useful for editing config files. If you want to deny root login via ssh you can simply enter this command: # sudo sed -ir 's/^(PermitRootLogin) .+/\1 no/' /etc/ssh/sshd_config It uses pattern matching a la perl and s/ searches for a line that ^starts with "PermitRootLogin" followed by one or more other characters. After the second slash we enter how it is replaced and here \1 fills in the bracketed "PermitRootLogin" string and then we add "no". In Perl this would look like this: # sudo perl -pi -e 's/^PermitRootLogin.+/PermitRootLogin no/'  /etc/ssh/sshd_config

Selected lessons in bash scripting

The masterpiece Let us first have a look at a more or less complicated bash script that employs a variety of features needed in bash scripting. The following script reads an input csv file line by line, stores each csv entry into a field in an array and then writes each value into a postgres database. #!/bin/bash # requires "list_of_ids" and "historical_Homer_final.csv" in same dir declare -a TASKIDS=(`awk -F"|" '{printf "%s ",$1}' list_of_ids`) declare -a DESCIDS=(`awk -F"|" '{printf "%s ",$2}' list_of_ids`) while read line do IFS=',' read -r -a array <<< "$line" ORIGINALDATE=`date --universal '+%s' -d "${array[0]}"` let ORIGINALDATE+=341712000 for index in ${!array[*]} do if [[ $index -ge 1 && ${TASKIDS[$index-1]} -ge 1 ]] then #write value to DB VALUE="${array[$index]}" TASKID=${TASKIDS[$index-1]} DESCID=${DESCIDS[$in

Passwordless Sudo Execution

Sudo allows you to execute (all) commands that would otherwise require root privileges. Once you are a sudoer, entering your password is the only, albeit tiresome, requirement for that. But, strictly speaking, it is not. Because, the /etc/sudoers file may be configured for you to execute specific commands with sudo without entering your password. The security pitfalls this entails are content of your own contemplation and not covered here. But, in some case like certain scripts, it might make your live much easier when allowing passwordless sudo. The following entry will grant myuser the power to reboot and poweroff my pc without entering a password: myuser ALL = NOPASSWD: /sbin/poweroff, /sbin/reboot In case this doesn't work you may check if those commands are actually symlinks to other commands that have to be added to the list.

What To Do When Your Ubuntu System Hangs On Reboot Or Shutdown?

When Linux hangs or freezes during the shutdown or reboot sequence, especially during remote sessions where no physically attached keyboard can be accessed, you may want to make sure the server will reboot no matter what and apply the -f parameter to force immediate shutdown: reboot -f In other situations where you may have a keyboard at hand and want to debug shutdown hangs, you may find the not so well known Magic SysRq keyboard shortcuts come in handy. Pressing CTRL+PRINT+B will immediately reboot your system without invoking the init system and even when the systemd debug console won't accept any keyboard inputs anymore.

Setting Up Multiple Docker Containers That Provide Remote Sessions

Docker is a widely used virtualisation technology that is based on the Linux-kernels network-namespaces-feature and works in conjunction with github repositories that provide a wide array of various distinct services that can be installed and run in virtual machines just by typing a single command. For a basic introduction I would recommend this tutorial. When setting up a bunch of docker containers, however, you may soon notice, that using only a single Dockerfile for each container may create a lot of overhead and takes much longer than necessary. Thats where this howto comes into play. This howto covers two topics. First of all we will create a simple Docker image that can be used in conjunction with Xrdp in order to administrate it remotely. Here we will explain basic handling of the Dockerfile and how we can enable remote sessions to our Docker container. Then, the formerly created image will be used as a base for a list of other images and containers. Here we will cover

Ubuntu 16.04.2 Kiosk Mode

If you want to run a PC in Kiosk mode, you probably want to run an instance of a web browser that does not allow anything else but simple browsing with only the mouse. The browser is not supposed to be canceled or quit but should indefinitely run and provide the specified web page you want to provide the kiosk for. This would entail booting the PC directly into the web browser. Setup: In this example we use the chromium open source chrome derivate web browser that will connect to a specified web page and will function in kiosk mode just in the way you would expect it to run. This howto is addressed to intermediate users that have a basic understanding of the linux shell, that are able edit script files and know what ~ means. In order to achieve this goal we can create a simple Ubuntu server installation and just install the bare minimum of packages required to fulfill our task. In part I will rely on the very helpful but a bit outdated example from Oli Warner. Installation of U