Show Free Disk Space on Linux

Submitted by Peter Majmesku on Tue, 05/23/2017 - 13:17


The "disk free" program shows the free space on a storage device via command line.

  • Show free space for the entire filesystem:
    •  df -h
  • Show free space for the local filesystem:
    • df -hl
  • Show more documentation regarding the "df" program:
    • man df


The "disk usage" program shows the used, not free, space on a storage device via command line.

  • Show the used space amount on the entire file system:
    • du -sh /
  • Show the used space of the folder named "media" by excluding ".bmp"-files:
    • du --exclude="*.bmp*" -sh media/ 
  • Show the used space of the current directory:
    • du -sh ./
  • Sort the folders in the current directory (recursion depth 1) by their disk usage:
    • du -h --max-depth 1 ./ | sort -h
  • Show more documentation regarding the "du" program:
    • man du

Ubuntu: Install Elasticsearch as Docker Container and manage it nicely in GUI

Submitted by Peter Majmesku on Fri, 12/09/2016 - 14:16

Install Docker

Firstly install Docker via this article: Mind to setup the user and group permissions according to the article. So that you are able to start Docker as non-root user.

Check your user's group setting

Make sure that a group with the name "docker" exists and your user is a member of that group. To add a user to an existing group, execute the following command:

sudo usermod -a -G groupName userName

After your user (mine f.e. is "peter") is being successfully added into the "docker" group, logout and login to ensure that you are acting from the docker user group.

Install Kitematic

Dowload the Kitematic GUI for Docker Debian package via This program will empower you, to manage your Docker containers easily via a graphical user interface. Mind that this application is currently beta. Then install it by

sudo dpkg -i dist/Kitematic_0.12.9_amd64.deb
Kitematic - GUI for Docker

Install Elasticsearch as Docker Container by Kitematic

Follow the following steps in Kitematic:

  1. Hit the "New"-Button
  2. Search for "elasticsearch" to see the official Elasticsearch Docker Container in the search result list
  3. Choose the version you want via the tag (version 1.7.2 is the version which works for me)
  4. Hit the button which is labeled with "Create". Kitematic will now install the Elasticsearch Docker container for you.
Kitematic Elasticsearch installation

GUI for Elasticsearch: Jettro

To be able to execute easily queries within Elasticsearch, check status etc., you can install Jettro ( Just execute the following command inside your Elasticsearch Docker container to install the Elasticsearch plugin:

bin/plugin install jettro/elasticsearch-gui 

Jettro - GUI for Elasticsearch inside the webbrowser

Start the Docker Container automatically on system startup as a Daemon

An official tutorial about this can be found here: In particular, you can follow the steps below.

Create a file at 


with the following content:

Description=Elasticsearch container

ExecStart=/usr/bin/docker start -a elasticsearch
ExecStop=/usr/bin/docker stop -t 2 elasticsearch


Now reload the daemon:

sudo systemctl daemon-reload

Start the Elasticsearch Docker container as a service:

sudo systemctl start docker-elasticsearch.service

Enable the service at system startup:

sudo systemctl enable docker-elasticsearch.service

Voilà! Happy search index querying. (:

Linux: Mass rename files by number and timestamp + mass edit of the last-edit date

Submitted by Peter Majmesku on Sun, 12/04/2016 - 21:26

This can be useful for masses of images editing. I needed to change the filenames of my photos to bring them in order for the popular german online print image service PosterXXL. To have all my photos ordered by specific locations, they needed ascending numeric filenames. Here I have stumbled upon useful console commands.

Rename all files to a number plus the current timestamp

ls | cat -n | while read n f; do mv "$f" "file-$(date +%s)-$n.jpg"; done

Change the last edit date of all files in a folder - not the filenames, but in the meta-information of the files

find -print | while read filename; do     touch -d "2 hours ago" "$filename"; done


Mass image rename in Linux

Use multiple PHP versions on Ubuntu 16.10 with Apache 2 and in the CLI

Submitted by Peter Majmesku on Thu, 11/10/2016 - 16:55

I needed an easy ability to switch multiple PHP versions on my local development environment. This ability should include the command line interface and webserver components of PHP. Here I am sharing my findings with you. I guess that this functionality is not new on Ubuntu 16.10. Most probably you can use the features already on Ubuntu 16.04 (LTS version) also.

You can use multiple PHP versions with one Apache server. Easily install them via the Apt package manager by the famous PPA from Ondrej. Then you can install multiple PHP versions like so:

sudo apt install php7.1 php5.6 php7.0

For being able to switch the PHP versions within the Apache webserver, you need the Lib Apache packages. You can install them like so:

sudo apt install libapache2-mod-php7.0
sudo apt install libapache2-mod-php7.1
sudo apt install libapache2-mod-php5.6

Afterwards you are able to switch the PHP version, which is being executed by Apache. E.g.:

sudo a2dismod php7.0
sudo a2enmod php5.6
sudo service apache2 restart

To switch he PHP CLI version, you can use the "update-alternatives" command. This command let's choose you the various versions of your program. In the background it will create symlinks for you. For getting into the version chooser dialogue, execute the following command:

sudo update-alternatives --config php

To switch PHP extensions for a specific PHP version, you can use the "phpenmod" and "phpdismod" commands. For enabling the Xdebug PHP extension for PHP 7.0, use the following command:

sudo phpenmod -v 7.0 xdebug

Run Behat tests on Ubuntu 16.10

Submitted by Peter Majmesku on Wed, 10/19/2016 - 15:35

To make it work you need Selenium standalone in version 2.52 and Firefox in version 45. This combination does work. The others do not. Download Selenium standalone in version 2.52 from

Then modify your


to use the packages from Ubuntu 16.04 Xenial. This is described at Afterwards update your package manager, check for the proper package version and install it:

sudo apt update

sudo apt-cache show firefox | grep Version

sudo apt-get install firefox=45.0.2+build1-0ubuntu1

Afterwards you are able to execute your Behat tests. F.e. by this command:

bin/behat --suite=my-test-suite

Install the Shutter screenshot program on Linux (Mint 18)

Submitted by Peter Majmesku on Mon, 10/17/2016 - 18:24

To install Shutter on Linux (Mint 18) with working screenshot editing extension, you must execute the following command. It will install the required packages via the Ubuntu package manager, which are needed for the screenshot editing extension.

sudo apt install shutter libgoo-canvas-perl gnome-web-photo

Then "restart" your computer. Afterwards Shutter looks like in the attached screenshot. Of course it will be in your operating system language. Mine is German.

Happy screen photographing! (:

Apache 2: Troubleshoot Vhost config for local development

Submitted by Peter Majmesku on Mon, 10/17/2016 - 09:46

General permissions

If you get this message in the webbrowser:

You don't have permission to access / on this server

and this one in the error.log file from Apache:

[Mon Oct 17 08:44:39.025804 2016] [core:error] [pid 8335:tid 139844481865472] (13)Permission denied: [client] AH00035: access to / denied (filesystem path '/home/peter/Dev') because search permissions are missing on a component of the path

then you need to execute the following command on your user folder (for me: /home/peter):

chmod +x /home/YOUR-USERNAME

If Apache is displaying your PHP file's code in the webbrowser, then run this command (worked for PHP7 on Ubuntu 16.04):

sudo apt install php libapache2-mod-php

Cache folder permissions

I assume you have your webroot files in your userfolder at /home/USER. As the PHP process is writing cache files as the www-data user per default (on Ubuntu/Debian), you must configure user and group permissions. Add the www-data user into the user's group and your user into the www-data group. So that they can use their files. The example command is:

sudo usermod -a -G www-data YOUR-USERNAME

sudo usermod -a -G YOUR-USERS-GROUP www-data

Then make the www-data user (as which Apache is acting), act by your user's group. This setting can be made in the file at /etc/apache2/envvars. Modify the lines as follows:

export APACHE_RUN_USER=www-data

Phing: Sync a complete website to remote server quickly

Submitted by Peter Majmesku on Mon, 08/29/2016 - 21:04

The famous Phing build tool (written in PHP) offers automation for repetitive tasks, which need to be executed by the Linux terminal. So you can sync an entire website (files and database) to the remote server. Here is an example of a Phing target to do the job:

    <target name="syncWebsiteToLive"
            description="Sync folder and files via Rsync to live server.">
        <echo msg="Syncing data to live server." />
        <exec command="rsync -a --progress --delete /home/peter/Websites/ --exclude=.git/ --exclude=.idea/ --exclude=sites/default/settings.php"
              checkreturn="true" />
        <echo msg="Delete old database" />
        <exec command="ssh 'mysql -uroot -pPASSWORD -e &quot;drop database example_com;&quot;'"
              checkreturn="true" />
        <echo msg="Create new empty database" />
        <exec command="ssh 'mysql -uroot -pPASSWORD -e &quot;create database example_com;&quot;'"
              checkreturn="true" />
        <echo msg="Import database dump" />
        <exec command="ssh 'mysql -uroot -pPASSWORD example_com &lt; /var/www/'"
              checkreturn="true" />

This target is later contained in your build.xml file. Afterwards you can execute the following command:

phing syncWebsiteToLive

The output will be the following:

Buildfile: /home/peter/build.xml
DevOps > syncWebsiteToLive:
     [echo] Syncing data to live server.
sending incremental file list
      7,515,285 100%  111.94MB/s    0:00:00 (xfr#1, ir-chk=1009/1040)
     [echo] Delete old database
     [echo] Create new empty database
     [echo] Import database dump
Total time: 5.7706 seconds

The website has been single by one single console command in an absolute minimum of time. This approach is good for a website in development stadium or a website which database can be just replaced. Then this way can save a lot of time compared to other approaches like ftp and manual database dump import. 

Subscribe to Linux