Archive for the ‘debian’ Category

Redshift to reduce eye strain from nightly computer use

January 11, 2017 Leave a comment

Note: This tutorial is mainly for Linux users. For other operating systems you could consult the article “Best Automatic Display Adjustment Software for Mac, Windows, iOS and Android“.

Redshift is a little Free and Open Source tool that can reduce the blue component in the light emitted by your computer screen. By default, it does so between sunset and sunrise based on your latitude / longitude coordinates, but you can also use a permanent fixed light temperature.

The underlying idea is that too much blue light can strain your eyes, especially at night.

Permanent candle light

On Debian and derivatives like Ubuntu, the redshift command line version can be installed like this:

sudo apt-get install redshift

I personally like a “permanent candlelight” setting at all times. This simple example sets a relatively low fixed light temperature of 2200K and a slightly dimmed brightness (see man redshift for more details):

redshift -r -O 2200 -b 0.8

If you like this approach, you can run this command at X session start, similar to what is shown under “Autostart after Login” below.

Emulating Day and Night

If you want redshift to distinguish between day and night, it is convenient to use the GUI version with a config file that specifies your latitude and longitude as shown below.

On Debian and derivatives like Ubuntu, redshift with the GTK UI can be installed like this:

sudo apt-get install gtk-redshift

You can determine your coordinates by googling for the name of your town or city, combined with the words “longitude” and “latitude”, for example for the German town of “Rodgau” this would be:

Note that latitudes south of equator and longitudes west of Greenwich must be specified as negative values. The following shows an example ~/.config/redshift.conf for Halifax (44.65° North, 63.58° West):



You can visit the Redshift website for more details about installation and configuration, etc.

Run the tool for the first time either via Start Menu – Accessories – Redshift on Debian systems, or as redshift-gtk on the Linux command line. You should then be able to see a reddish light-bulb icon in the system tray (aka “notification area”) of your desktop system. Clicking on it gives you options to temporarily disable the tool or view info about your configured geo-location and whether redshift thinks it is currently night-time. If so, you should notice a reddish screen color temperature.

Autostart after Login

To have redshift-gtk start up on every X session, add an entry to the Autostart mechanism of your desktop environment or window manager. For XFCE on Debian, open Start Menu – Settings – Session and Startup – Application Autostart tab and add an entry like this:


Categories: debian, linux, xfce Tags: ,

Convert mpc to mp3 on Linux

January 1, 2017 Leave a comment

You need the lame and mpcdec commands. On Debian, mpcdec is in the musepack-tools package:

sudo apt-get install lame musepack-tools

Then to convert all mpc files in the current directory to matchingly named mp3 files:

for x in *.mpc; do mpcdec "${x}" - | lame -r - "${x%.mpc}.mp3"; done
Categories: bash, coding, debian, linux, music

Determine which Tomcat version is running

August 6, 2016 7 comments

Determine process id

First we determine the process id(s) of the running Tomcat instance(s).

We can grep the running process list for ‘catalina.home’:

pgrep -f 'catalina.home'

This might yield more than one pid.

Or we can search by port (8080 is the default, adjust if necessary). The following commands will likely require root privileges:

lsof -t -i :8080

Alternatively, for example if lsof is not installed:

fuser 8080/tcp

Or yet another way, using netstat (or its “ss” replacement):

netstat -nlp | grep 8080
ss -nlp | grep 8080

Determine catalina.home

For the process id(s) determined above, we look at process details:

ps -o pid,uid,cmd -p [pidlist] | cat

For each specified pid, this shows the uid (system user) and the full command line of the process.

Typically the command line will contain something like “-Dcatalina.home=[path]” and that path is the catalina.home system property of the Java process.

Alternatively – with Java 7 and later – we can use the JDK command “jcmd” to query the JVM process for its system properties:

sudo -u [uid] jcmd [pid] VM.system_properties \
   | grep '^catalina.home' \
   | cut -f2 -d'='

Determine version

Now we can finally determine which Tomcat version is installed under the catalina.home path:

[catalina.home]/bin/ version \
   | grep '^Server number:'

Note: Please replace [catalina.home] with the path you determined above.

The final output should be something like this:

Server number:

Compare two Tomcat installations using rsync

Lets assume you manage multiple servers that host Java web applications using the Tomcat web server.

To quickly compare the Tomcat installations on host1 and host2, we can use the “dry-run” mode of the rsync command.

In the following example, we assume that you have ssh access to both of your Tomcat hosts, the installations are in /opt/tomcat and the “tomcat” system user has read access to all relevant files and directories of the installation:

ssh tomcat@host1
rsync --archive --checksum --dry-run --verbose --delete \
      --exclude temp --exclude work --exclude logs --exclude webapps \
      /opt/tomcat/ tomcat@host2:/opt/tomcat/

This will list

  • All files that differ in checksum
  • All files that only exist on host2 (look for ‘deleting [filename]’)

Run the same commands with host1 and host2 switched, to also see the files that only exist on host1.

We excluded the temp, work and logs directories because they are variable in nature.
We also excluded the webapps directory because we only wanted to compare the base installation.

Categories: bash, coding, cygwin, debian, linux, mac os

Spotify on Debian GNU/Linux in Canada

March 29, 2016 Leave a comment

Today I decided to try out the free ad-sponsored Spotify music streaming service. It has been available in Canada since September 2014.

After signing up you can immediately use the flash-based web player at

Installing the client app

Alternatively you can download and install the Spotify client app. I cannot say yet what the advantages or disadvantages are, maybe reading this article can be helpful.

Anyway, if you want to try the client app, for Debian (or Ubuntu) users it works like this:

  1. Add the repo key (to verify downloaded packages)
  2. Add the spotify repo to apt sources
  3. Update apt caches
  4. Install the spotify client

Here are the shell commands (requires sudo):

sudo apt-key adv --keyserver hkp:// --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886
echo deb stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
sudo apt-get update
sudo apt-get install spotify-client

After successful installation you will find a “Spotify” entry in the “Multimedia” section of your start menu.

Using your Facebook login

If you use your Facebook account to sign into Spotify you will probably see this question:

Spotify would like to post to Facebook for you.
Who do you want to share these posts with?

It is safe to choose “Not Now” which prevents Spotify from posting to your timeline. The login will still work.

If your are using the downloaded stand-alone client app and the Facebook login fails with an error page, then simply enter the email address and password from your Facebook account into the login fields of the Spotify client app.

Spotify says that it only uses these credentials to pass through to the Facebook authentication and won’t store your password anywhere. I hope that’s true.

Categories: bash, debian, linux, music Tags:

Set the X cursor theme in XFCE 4.10

August 16, 2015 Leave a comment

After upgrading to Debian Jessie and XFCE 4.10, I set the default cursor theme in XFCE main menu – Settings – Mouse and Touchpad – Theme tab.

But this seemed to affect only a few applications.

To consistently set the theme for all applications and the desktop I had to run this:

oliver@debian:~$ sudo update-alternatives --config x-cursor-theme
There are 3 choices for the alternative x-cursor-theme (providing /usr/share/icons/default/index.theme).

  Selection    Path                                    Priority   Status
  0            /usr/share/icons/Adwaita/cursor.theme     90        auto mode
  1            /usr/share/icons/Adwaita/cursor.theme     90        manual mode
  2            /usr/share/icons/DMZ-Black/cursor.theme   30        manual mode
* 3            /usr/share/icons/DMZ-White/cursor.theme   50        manual mode

Press enter to keep the current choice[*], or type selection number:

Select the desired theme from the listed options and make sure it is the same as the one you selected in the XFCE settings.

Categories: bash, coding, debian, linux, xfce Tags: ,

Zulu – Certified OpenJDK 8 builds for all operating systems

May 5, 2015 1 comment

You might have heard that Java is Open Source. And then you noticed that the Java SE downloads from the Oracle website are not actually Open Source. Maybe you also heard about OpenJDK.

So how does this fit together?

OpenJDK is an Open Source implementation of Java and Oracle Java engineers do work on Java with the OpenJDK community and and within the OpenJDK projects.

But source code needs to be compiled into executable binaries to be useful for end users. And that’s where things get dicey …

Where to find OpenJDK builds

For a long time there has been no reliable source for certified, well-supported builds of OpenJDK for all platforms.

The various GNU/Linux distributions, like Fedora, Debian, etc, have provided OpenJDK builds for a quite a while now, but for Windows and MacOS there were only some unofficial, often outdated hobby projects without reliable security updates.

Zulu – Open JDK builds


This changed within the last 2 years: JVM vendor Azul Systems first released their “Zulu” line of free OpenJDK builds in September 2013, mainly targeting Windows Servers and the Microsoft Azure cloud. In 2014 they added support for Linux, MacOS and Java 8, as well as Docker images. All Zulu builds are certified against the official Java SE TCK. The focus is on the JDK and servers, without browser plugin or webstart.

The Azul website does not clearly state their security update policy for their free builds, but they offer deb and rpm package repositories that seem to contain latest builds of OpenJDK that match the current Oracle JDK update versions. Also, their engineers participate in the community and allegedly contribute back to OpenJDK.

Zulu – OpenJDK 8 for Debian stable

For Debian stable (Wheezy or Jessie), Azul is a convenient way to install OpenJDK 8, since the Debian openjdk-8 package is currently only available in Debian unstable and hasn’t even made it into the Debian testing yet.

Here is how I set up the Azul deb repo and installed their OpenJDK 8:

sudo apt-key adv --keyserver hkp:// --recv-keys 0x219BD9C9
apt_source='deb stable main'
echo "$apt_source" | sudo tee "$apt_list" > /dev/null
sudo apt-get update
sudo apt-get install zulu-8

Please note, that the package installation automatically sets the Java related system alternatives to the Zulu ones. So right after zulu-8 installation the java version in your system path will be something like this:

oliver@basement:~$ java -version
openjdk version "1.8.0_45"
OpenJDK Runtime Environment (Zulu (build 1.8.0_45-b14)
OpenJDK 64-Bit Server VM (Zulu (build 25.45-b02, mixed mode)