Monthly Archives: March 2016

Disable IPv6 on Ubuntu 12.04

I really think IPv6 is a step in future direction but I saw poor performance on one of our OVH server. Disabling IPv6 Sysctl Edit Open /etc/sysctl.conf and add following lines. net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 Then run sudo sysctl -p Change proc Just run following command cat /proc/sys/net/ipv6/conf/all/disable_ipv6 If it returns 0, then… Read More »

dsh – distributed shell

dsh – distributed shell DSH is Distributed Shell. It allows you to run shell commands on multiple servers at once and gather see their output in local terminal. Install Install  On Debian/Ubuntu apt-get install dsh Mac brew install dsh Config You can use default config but we always add following to dsh config file: Global config => /etc/dsh.conf Local config =>  ~/.dsh/dsh.conf remoteshell… Read More »

GPG Keys Cheatsheet

Generate GPG Keys Run: gpg –gen-key You will be asked: Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only) Your selection? Hit ENTER to select default. Next, you will be asked: RSA keys may be between 1024 and 4096… Read More »

search replace in multiple files useing grep xargs sed

On many occasions we need to search and replace some text across multiple files on server. We use combination of grep, sed and xargs to achieve it mostly. We will explain commands with examples: Search and replace URLs in PHP files We came across a poorly coded PHP site which was using many 4 different… Read More »


Ubuntu server out of box is not optimized to make full use of available hardware. This means “out-of-box” setup might fail under high load. So we need to tweak system configuration for maximum concurrancy. Sysctl Tweaks Open vim /etc/sysctl.conf Add following towards bottom ### IMPROVE SYSTEM MEMORY MANAGEMENT ### # Increase size of file handles and… Read More »

Configure Postfix to Use Gmail SMTP on Ubuntu

If you want to use a Gmail account as a free SMTP server on your Ubuntu-Linux server, you will find this article useful. This guide is tested with Ubuntu 12.04. If you face any issue, feel free to use comments-section below. Relaying Postfix mails via First, install all necessary packages: sudo apt-get install postfix… Read More »

Logrotate Example for Custom Logs

You will need this if you are using custom location for log files. Below is example for Nginx where log files are directly created in /var/www/ You can put following in /etc/logrotate.d/nginx /var/www/*.log { daily missingok rotate 52 compress delaycompress notifempty create 0640 www-data adm sharedscripts prerotate if [ -d /etc/logrotate.d/httpd-prerotate ]; then \ run-parts /etc/logrotate.d/httpd-prerotate;… Read More »

Installing Percona Toolkit

Percona maintains Ubuntu repos for their products. Below is process to install it quickly. Add GPG Key gpg –keyserver hkp:// –recv-keys 1C4CBDCDCD2EFD2A gpg -a –export CD2EFD2A | sudo apt-key add – Add Repos echo “deb `lsb_release -cs` main” >> /etc/apt/sources.list.d/percona.list echo “deb-src `lsb_release -cs` main” >> /etc/apt/sources.list.d/percona.list Update apt-get update Install apt-get install… Read More »

Increase “Open Files Limit”

If you are getting error “Too many open files (24)” then your application/command/script is hitting max open file limit allowed by linux. You need to increase open file limit as below: Increase limit Per-User Limit Open file: /etc/security/limits.conf Paste following towards end: * hard nofile 500000 * soft nofile 500000 root hard nofile 500000 root soft… Read More »