Category: GNU/Linux

Fail2Ban Custom filters and Testing Regex’s against existing Logs

Fail2ban is a tool that can automatically ban malicious bots trying to get into your server. Provided you set up filters and the ip address (or fqhn) is logged you can use fail2ban with any application.

Create a filter, using a regular expression (fail2ban is built with python):

In /etc/fail2ban/filter.d/my-custom-filter.conf:


failregex = ^  -.* "POST \/user\/register HTTP\/1.0" 200

ignoreregex =

Now you want to test this for matches against a log file. Ensure that the log file has existing matches.

Make use of the command line tool fail2ban-regex:

fail2ban-regex /var/log/apache2/example-access.log /etc/fail2ban/filter.d/my-custom-filter.conf

You will get summary data like this:

Running tests

Use   failregex file : /etc/fail2ban/filter.d/my-custom-filter.conf
Use         log file : /var/log/apache2/example-access.log


Failregex: 1 total
|-  #) [# of hits] regular expression
|   1) [1] ^  -.* "POST \/user\/register HTTP\/1.0" 200

Ignoreregex: 0 total

Date template hits:
|- [# of hits] date format
|  [23636] Day/MONTH/Year:Hour:Minute:Second

Lines: 23636 lines, 0 ignored, 1 matched, 23635 missed
Missed line(s): too many to print.  Use --print-all-missed to print all 23635 lines

Which lets you debug your filter regular expression to ensure it is matching the malicious log entries.


Finally, add the new filter to your jail.local by appending the following:

enabled  = true
filter   = my-custom-filter
action   = iptables-multiport[name=NoAuthFailures, port="http,https"]
logpath  = /var/log/apache2/example-access.log
banTime  = 864000
findtime = 1800
maxRetry = 3

You can read more about the configuration of jails in the manual

How to install Ubuntu 16.04 and Automatically Install all my apps

How to install Ubuntu 16.04 and Automatically Install all my apps

I’m assuming this gets searched quite a lot. It is one thing installing ubuntu, but another hugely time consuming gig installing all the old applications that you like. Couple that with your configurations of .bashrc, application configs, editor configs and logins for apps and it becomes a seemingly impossible task.

But it’s not it can be done with an awesome tools known as ansible which will become known to you in due time. First off lets install it.

Remember this tutorial is just for a ffresh install of the Desktop ubuntu version, although the ansible script can be modified for a server. If you just want to upgrade your ubuntu 14.04 LTS server to Ubuntu 16,.04 check this out

Installing Ubuntu 16.04

  1. Download the desktop version of Ubuntu 16.04, it is a .iso.
  2. Get an empty USB Flash drive (2 gb or more) or clear an old one with ubuntu (Or use gparted it’s the best, see below)
  3. Get a PC ready either for a dual boot (Windows and Ubuntu) or just Ubuntu. I think the .iso we just downloaded has gparted – a utility to partition space to install operating systems – installed. Otherwise get gparted here. Clear enough free space for ubuntu (20gb should be ok) with gparted.
  4. On an ubuntu machine: Windows key -> Search for Startup disk Creator -> Open it -> Make a Startup disk with the ubuntu .iso Alternatively if you are on windows you can use Unetbootin to Install the iso onto a USB
  5. Get the pc you have cleared to install ubuntu on and plug in the startup/ bootable usb, make sure to select the drive of the USB to boot from
  6. Now say install ubuntu not try ubuntu without installing Unless you just want to try it
  7. It will prompt for your language choice, but this is a good time to connect to your wifi in the top right.
  8. Select your language and continue, then depending on your preference choose Download updates while installing ubuntu and Install third-party software for graphics and Wi-Fi hardware, Flash,MP3 and other Media
  9. Continue and wait a while…
  10. It will then ask the installation type. Make your choice depending on if you want to dual boot and just want the new ubuntu or something else. You will need to make some swap space available for memory if you choose something else, use this guide on the manual ubuntu partitioning. (I changedto install alongside, because I got an error with the manual method, I also didn’t connect to the wifi)
  11. Next select your timezone/city then your keyboard layout
  12. Next your name (this is used as the name of your home folder /home/surfer190 so make sure it is lower case and simple. Choose a password and continue. You can enrypt your home folder if you aren’t the only user on the pc.
  13. Install then completes, Woohoo fresh install

Customisation and Automatically Install all my apps

First thing I noticed was the unnatural scrolling direction of the two-finger scroll on the touchpad.


How to Change Desktop Environment from Xfce to KDE

Don’t use Xfce, use KDE!

Why is Xfce junk?

The style is very half windows, half mac, half-a-job. There is also no built in support for dual monitors so you have to use xrandr everytime you boot which is very annoying. Sure it is lightweight, but it is not good enough.

Why is KDE the best?

Well for one, it was the first ever GNU/Linux Desktop environment, announced in 1996. So they have had time to refine the experience and it is very smooth and customisable. It is also now the most popular desktop environment and rightly so.

What about the rest?

Well Gnome is alright but you will pull your hair out after a while. Unity for ubuntu is really good and I would advise sticking with it if you are on ubuntu. I have not tested Cinnamon but apparently it is very windowsy, so you may want to stay clear.

How to Change Desktop Environment from Xfce to KDE

Take note that in this case I am using Debian 8 as the operating system, with the apt-get package manager you can probably use the same commands but with your package manager of choice eg. aptitude, yum, emerge

1. First install KDE, otherwise if you remove XFCE first then your network connection manager may not work.

sudo apt-get purge xfce4

2. Install KDE

sudo apt-get install ~t^desktop$ ~t^kde-desktop$

3. Reconfigure the Display manager and select KDE, this probably appened in the previous step

sudo dpkg-reconfigure kde

4. Configure the default X-session to start. Select KDE.

update-alternatives --config x-session-manager

5. Autoremove Xfce

sudo apt-get autoremove

What Now?

Enjoy the best Desktop environment there is. Welcome to the calm world where almost everything is intuitive…