Install docker on multiple Ubuntu Xenial hosts with Ansible

Ansible is an amazing piece of configuration management software. Among its amazing features is that it’s totally agentless and the only 2 packages that it needs on any host are python and an SSH server.

Today we will create a playbook that will do the following:

  1. Add the stable docker repository to the software sources
  2. Add the gpg key
  3. install docker-ce package

It’s assumed that you have already added all required hosts to /etc/ansible/hosts and I’m naming this group “swarm”

- hosts: swarm
  remote_user: qcri\aamr
  gather_facts: no

 - name: add docker repo
     repo="deb xenial stable"
 - name: install repo gpg key
 - name: refresh cache and install docker-ce


Sources: Ansible Documentation

Posted in Ansible, Linux, Uncategorized | Tagged , , , , , , , | Leave a comment

How to clear your bash history

For old commands, just edit .bash_history and delete whatever you want from inside.

For commands in the current session, just run this command before you exit:


The $HISTFILE environment variable is the one which holds your commands and will flush to the file once you exit the session.


Posted in Linux, Uncategorized | Tagged , , , | Leave a comment

Create Amazing QR Codes with QRCode Monkey

And it’s FREE! I wouldn’t have written a blog entry for something except if it was such an amazing one:

Posted in Uncategorized | Tagged , , | Leave a comment

Fix Slow SFTP/SCP File Upload Rate and Stalling caused by TCP SACK

In brief, sometimes a conflict occurs between some firewalls and the TCP SACK. In my case, the upload was severely affected and reached upload speeds of a few kilobytes over a LAN!

The following command disables TCP SACK and fixes the slow upload on all Ethernet cards:

sudo sysctl -w net.ipv4.tcp_sack=0

To make it permanent, edit /etc/sysctl.conf and add this line

net.ipv4.tcp_sack = 0

Then run:

Posted in Linux, Uncategorized | Tagged , , , , , , , , | Leave a comment

Reclaim storage space from qcow2 image after moving

After it is moved to another host, since it is a sparse file, the qcow2 takes the full space, e.g. if it was dynamically set to 100GB, it will take 100GB, even if only 50 GB were actually used.

I could get back more than 20 GB from my Win7 VM (from a 50 GB file) using this:

sudo qemu-img convert -O qcow2 win7.qcow2 win7_small.qcow2



Posted in Linux, Uncategorized | Tagged , , , , , | Leave a comment

Securely delete files/folders in Ubuntu

In brief, you should NEVER trust your HDD before handing it over to someone else!

The solution to this would be either wipe the whole HDD or at least wipe the files/folders that you need to keep out of reach.

There are two quick ways to do this on Ubuntu; shred and wipe. I prefer wipe because it can accept folders as well.

The point is to fill the place of your data with random bits multiple times, as follows:

  1. sudo apt install wipe
  2. wipe -rq folder_name

r: for recursive

q: for quick mode, with only 4 iterations of random data.


Note: This process is very time-consuming, even in quick mode, depending on how large your data is, and how fast the HDD you are wiping is.


Posted in Linux, Uncategorized | Tagged , , , , , , , | Leave a comment

Add an additional physical volume to your encrypted LVM volume group

With a default Linux Mint installation, do the following after connecting the new hard disk to your computer, we will assume the new HDD is /dev/sda:

  1. sudo pvcreate /dev/sda
  2. sudo vgextend mint-vg /dev/sda
  3. sudo lvextend -l +100%FREE /dev/mint-vg/root
  4. sudo cryptsetup resize /dev/mapper/mint–vg-root
  5. Enjoy!


Posted in Linux, Uncategorized | Tagged , , , | Leave a comment