May 02 2015

Enabling Ansible Jinja2 template syntax highlighting in PHPStorm (and other editors)

Category: Linux administrationFractalizeR @ 1:14 am

Just do this:

  • Add cloned repository folder to PHPStorm -> Settings -> Editor -> TextMate Bundles
  • It should work now, but may be you will have to add “*.j2” to PHPStorm -> Settings -> Editor -> Filetypes -> Files supported via TextMate bundles

May 10 2012

Getting rid of “error:: no video mode activated” when using full disk encryption in Ubuntu 12.04

Category: Articles,Linux administrationFractalizeR @ 9:59 pm
sudo cp usr/share/grub/*.pf2 /boot/grub
sudo update-grub

May 09 2012

One-liner to make gEdit 3 correctly autodetect russian encoding

Category: Articles,Linux administrationFractalizeR @ 10:54 pm

Recently I installed Ubuntu 12.04 and it’s gEdit doesn’t recognize cyrillic (Windows-1251) encoding correctly. I discovered one-liner to make it do the task:

sudo gsettings set org.gnome.gedit.preferences.encodings auto-detected "['UTF-8', 'CURRENT', 'WINDOWS-1251', 'ISO-8859-15', 'UTF-16']"

Nov 05 2010

Munin: Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

Category: Articles,Linux administrationFractalizeR @ 5:15 pm

To fix this bug, you need to patch a file /usr/share/munin/munin-graph in the following way:

Continue reading “Munin: Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()”

Nov 05 2010

Munin troubles: Fatal error: Could not open “/var/lib/munin/datafile” for writing

Category: Articles,Linux administrationFractalizeR @ 4:09 pm


Having installed Munin recently on my servers, I started to get emails from cron saying

Fatal error: Could not open "/var/lib/munin/datafile" for writing: Permission denied at /usr/lib/perl5/vendor_perl/5.8.8/ line 727.
(process:18039): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

I also got some errors about /var/log/munin/munin-update.log being inaccessible. Somehow these files does not belong to munin:munin, but to rrdcache:rrdcache, so the solution is just to make them chmod 0777 and that should solve the problem.

May 20 2010

CentOS: Migrating root (and any other) filesystem from ext3 to ext4

Category: Articles,Linux administrationFractalizeR @ 4:52 pm

With the release of CentOS 5.5 ext4 is considered stable in this distribution so I decided to migrate to it. Luckily I started from migrating fresh server with CentOS 5.5 using some instruction I found on the internet. I think I shouldn’t say, that I screwed the whole thing up 😉 After about 6 hours cursing, kicking, and crying I solved the task and figured the correct sequence of actions. The small problem with migrating root partition is that you can’t unmount it BTW.

Continue reading “CentOS: Migrating root (and any other) filesystem from ext3 to ext4”

Tags: ,

May 07 2010

Increasing RAID resync/rebuild speed

Category: Articles,Linux administrationFractalizeR @ 6:33 pm

Recently I assembled a server with several 2Tb disks in Linux RAID. RAID resync reported by cat /proc/mdstat showed that resync will take about 9 hours! More than my working day! I started to look for a way to increase resync speed.

Continue reading “Increasing RAID resync/rebuild speed”

Tags: ,

Jan 09 2010

[Linux] “network unreachable resolving XXXX” messages in system log

Category: Articles,Linux administrationFractalizeR @ 3:10 pm

Some time ago I noticed many messages in log file about named attempt to resolve strange addresses.

Continue reading “[Linux] “network unreachable resolving XXXX” messages in system log”

Tags: ,

Jan 04 2010

[Linux, PHP] PHP script to backup all databases

Category: Articles,Linux administration,PHPFractalizeR @ 1:20 am


I’d like to share my script, which I use on some production servers for quick database backup using mysql tools. People say, that I should use bash for that, but I prefer PHP 🙂

Script uses mysqldump for dumping databases and gzip for compressing backups. rm is run to ensure backups are not stored for too long.

Continue reading “[Linux, PHP] PHP script to backup all databases”

Tags: , , ,

Dec 27 2009

WARNING: mismatch_cnt is not 0 on /dev/md0

Category: Articles,Linux administrationFractalizeR @ 12:37 pm

I’ve gotten cron log from one of my servers today which says:

 WARNING: mismatch_cnt is not 0 on /dev/md0

That worried me a little and I decided to investigate.

Continue reading “WARNING: mismatch_cnt is not 0 on /dev/md0”

Tags: , , , ,

Dec 20 2009

Script for securing server with IPTables

Category: Articles,Linux administrationFractalizeR @ 7:31 pm


Here is a script, which I use on my production servers to secure them a bit. I hope it will be useful to you. Script logs all dropped packets so that you can easily find out tye clutch should there be any. Additional FTP server setup will be necessary. For ProFTPD add the following line to /etc/proftpd.conf:

PassivePorts 65400 65534

Continue reading “Script for securing server with IPTables”

Tags: , , ,

Jul 01 2009

[Linux, FreeBSD] Small Anti-DDOS Shell Script for FreeBSD

Category: Articles,Linux administrationFractalizeR @ 3:21 pm

Struggling with DDoS on my friend’s site, I wrote small Anti-DDoS script, that in original just lists all IPs, that have more than X active connections open to your server. It was originally written for FreeBSD.

# Set here a minimum number of connections for action to be executed (150 by default).
netstat -ntu -f inet| awk '{if(NR>2 && NF=6) print $5}' | cut -d. -f1-4 | grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$' | sort | uniq -c | sort -nr > $TMP_FILE
while read line; do
 CURR_LINE_CONN=$(echo $line | cut -d" " -f1)
 CURR_LINE_IP=$(echo $line | cut -d" " -f2)
 if [ $CURR_LINE_CONN -lt $FR_MIN_CONN ]; then
 # You can insert your own logic here (e.g. ban with your favourite firewall). Now it just prints the IP to console.
done < $TMP_FILE
rm -f $TMP_PREFIX.*

I think this will work on general Linux also. You just need to change “cut -d.” to “cut -d:” in the listing and, probably, “/bin/sh” to “/bin/bash”.

Tags: , ,

Jul 01 2009

[Linux, FreeBSD] Using netstat and ipfw to manually detect and blacklist DOSers on FreeBSD

Category: Articles,Linux administrationFractalizeR @ 1:22 pm

This is just an addition to my this article with some corrections needed if you use FreeBSD.

netstat command should look like

netstat -ntu -f inet| awk '{print $5}' | cut -d. -f1-4 | sort | uniq -c | sort -nr|more

And firewall IP blocking command should be

ipfw add deny all from to any in

Tags: , , ,

Jun 25 2009

[Linux] Automated RPMForge Repository Installation

Category: Articles,Linux administrationFractalizeR @ 12:28 pm

Actually, I am using CentOS on production servers. CentOS native repository is very small and contains very necessary packages. If you need something more, you should consider using RPMForge repository as I do 😉 But to add this repository to CentOS you need to do several annoying actions. And this is annoyng when you do so on each new server you are asked to setup. So, I wrote small script to automate the job which I like to share with you now.

Continue reading “[Linux] Automated RPMForge Repository Installation”

Tags: , , , ,

Jun 01 2009

[Solution] Apache: No space left on device: Couldn’t create accept lock

Category: Articles,Linux administrationFractalizeR @ 3:31 pm

My friend asked me to check the server with this problem. I did and of course first I checked free space on disk using ‘df -h’, but free space was ok. Googling around I found the reason. Unclean shutdown of Apache left many semaphores opened. So, I cleaned them with

for i in `ipcs -s | awk '/nobody/ {print $2}'`; do (ipcrm -s $i); done

You should replace “nobody” in the command with the name of the user Apache is running on your system under. Also I increased semaphore limit in /etc/sysctl.conf by adding to the end of this file

kernel.msgmni = 1024
kernel.sem = 250 256000 32 1024

No system restart is needed to apply changes. Just issue 'sysctl -p‘ command. The solution was found here.

You may also want to switch to another SSLMutex implementation.


Aug 24 2008

[Linux] Installing latest Apache, PHP and MySQL from sources

Category: Articles,Linux administrationFractalizeR @ 12:48 am

As you probably know, latest software versions are rarely available to be installed as rpms. So, you need to compile them yourself. In this article I will briefly describe a process of installing, configuring and  upgrading latest Apache and PHP.

Please remember, that installing from sources can sometimes break working system. So, please use this guide carefully.

Continue reading “[Linux] Installing latest Apache, PHP and MySQL from sources”

Tags: , , , , ,

Aug 21 2008

[Linux] Installing YUM (Yellow dog Updater, Modified)

Category: Articles,Linux administrationFractalizeR @ 4:46 pm

YUM is an rpm package manager with very easy syntax. It is preferred especially for beginners to install packages using yum as this is very easy. Your Linux distro should already have yum by default, but if this is not so, let’s install it. BTW, you can find yum manual here.

You can check if your system has yum by entering

  • yum –help

Continue reading “[Linux] Installing YUM (Yellow dog Updater, Modified)”

Tags: ,

Aug 11 2008

[Linux] Limiting download speed and number of connections per IP with mod_choke (Apache 1.x)

Category: Articles,Linux administrationFractalizeR @ 1:47 am

If you have many greedy users downloading files from your server using many streams per user, you can fight them easily with mod_choke Apache 1.x module. It is very easy. The article assumes your server is running under CPanel/WHM

Continue reading “[Linux] Limiting download speed and number of connections per IP with mod_choke (Apache 1.x)”

Aug 11 2008

[Linux] Decreasing server CPU load with PHP APC cache extension

Category: Articles,Linux administrationFractalizeR @ 1:44 am

As you know, each time php script is executed, PHP interpreter need to compile it first to bytecode and only after that – execute. That compilation takes much time.

APC PHP extension (which will be included and enabled in PHP6 by default. It becomes a standard) can speedup php script execution process by caching once compiled PHP bytecode in memory. So, installing this extension increases your server performance (we assume you are doing this at CPanel/WHM controlled server). To install extension just do the following:
Continue reading “[Linux] Decreasing server CPU load with PHP APC cache extension”

Tags: , ,

Aug 11 2008

[Linux] Installing ClamAV antivirus and integrating with Exim and pure-ftpd

Category: Articles,Linux administrationFractalizeR @ 1:41 am

Every good server must have a good antivirus installed. Let’s install ClamAV to our machine. Paths to distributions are provided to the latest versions at the time of writting. If new version releases all you need to do is to change numbers in shell command.

Continue reading “[Linux] Installing ClamAV antivirus and integrating with Exim and pure-ftpd”

Tags: , ,

Next Page »