Creating NGINX Rewrite Rules

How to create NGINX rewrite rules (the same methods work for both NGINX Plus and the open source NGINX software). Rewrite rules change part or all of the URL in a client request, usually for one of two purposes:

  • To inform clients that the resource they’re requesting now resides at a different location. Example use cases are when your website’s domain name has changed, when you want clients to use a canonical URL format (either with or without the www prefix), and when you want to catch and correct common misspellings of your domain name. The return and rewrite directives are suitable for these purposes.
  • To control the flow of processing within NGINX and NGINX Plus, for example to forward requests to an application server when content needs to be generated dynamically. The try_files directive is often used for this purpose.

Example of a redirect to a new domain name:

<code>server { listen 80; listen 443 ssl; server_name; return 301 $scheme://$request_uri; }

Read more details and examples from the Nginx blog post:


Linux Dash

A simple web dashboard to monitor your linux systems.


  • A beautiful, simple web-based dashboard for monitoring a linux server
  • Only ~1MB on disk! (.git removed)
  • Live graphs, refresh-able widgets, and a growing # of supported modules
  • Drop-in installation for PHP, Node.js, Python, and Go

More details and downloads:


Email Checker

Email Checker is a simple tool for verifying an email address. It’s free and quite easy to use. Just enter the email address and hit check button. Then it tells you whether the email address is real or not. It extracts the MX records from the email address and connect to mail server (over SMTP and also simulates sending a message) to make sure the mailbox really exist for that user/address. Some mail servers do not co-operate in the process, in such cases, the result of this email verification tool may not be accurate as expected.


Boot-Repair Utility and Methods

Boot-Repair is a simple tool to repair frequent boot issues you may encounter in Ubuntu like when you can’t boot Ubuntu after installing Windows or another Linux distribution, or when you can’t boot Windows after installing Ubuntu, or when GRUB is not displayed anymore, some upgrade breaks GRUB, etc.

Boot-Repair lets you fix these issues with a simple click, which (generally reinstalls GRUB and) restores access to the operating systems you had installed before the issue.

Boot-Repair also has advanced options to back up table partitions, back up bootsectors, create a Boot-Info (to get help by email or forum), or change the default repair parameters: configure GRUB, add kernel options (acpi=off …), purge GRUB, change the default OS, restore a Windows-compatible MBR, repair a broken filesystem, specify the disk where GRUB should be installed, etc.

More Information and link:


Linux – Copy file to multiple dir

How an I copy a file into multiple directories? You could write a script or just use these commands from the terminal in bash.

Copy test.txt into dir1,dir2,an dir3 dirs:

 echo dir1 dir2 dir3 | xargs -n 1 cp -v test.txt 

Copy test.txt into /dir/d1, /dir/d2, and /dir/d3 dirs:

 echo /dir/d{1,2,3} | xargs -n 1 cp -v test.txt 


Generating puppet password hashes

Puppet needs user passwords in configuration files to be encrypted in the format the local system expects. For Linux and most unix-like system, that means, you have to put the sha1 sum of the password into the configuration file.

user { 'root':
ensure => 'present',
password => '$1$HTQx9U32$T6.lLkYxCp3F/nGc4DCYM/',

To generate the password use Python with:
python -c 'import crypt; print crypt.crypt("password", "$6$salt")'

Obviously don’t use password as your password!

Quickly change the date and time in Linux from the shell

Sometimes you may just need to get the date and time quickly set before going on and installing NTP or OpenNTP and configuring them with a NTP server. The following examples show how quickly you can set the date and time at the command shell in Linux.

How can I set the system date and time from the command prompt (bash shell)? I don’t have GUI installed and I am login over ssh session. How can I set date under Linux operating systems?

Type the date command:

 $ date 

Sample outputs:
Wed Apr 23 10:32:59 CDT [email protected]

Linux Set Date Command Example – Use the following syntax to set new data and time:

 date --set="STRING" 

For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:

 date -s "2 OCT 2006 18:00:00"
date --set="2 OCT 2006 18:00:00"

You can also simplify format using following syntax:

 date +%Y%m%d -s "20081128" 

Linux Set Time Examples:

To set the time to 15:47:

date +%T -s "15:47:00" 

To set the date and time to July 10 at 15:50:

 date 07101550 

To set the time and date including the year to July 10 2012 at 16:00 and 30 seconds:

 date -s "10 JUL 2012 16:00:30" 

For more info see the man pages in your distro with “man date” command.

Linux ethtool Examples to Manipulate Ethernet Card

ethtool is a utility for Linux kernel-based operating system for displaying and modifying some parameters of network interface controllers (NICs) and their device drivers. ethtool is developed parallel to the Linux kernel.

The command is useful for

  • Identification and diagnosis of Ethernet devices
  • Extended Ethernet devices statistics
  • Control speed, duplex, auto-negotiation and flow control for Ethernet devices
  • Control checksum offload and other hardware offload features
  • Control DMA ring sizes and interrupt moderation
  • Control receive queue selection for multiqueue devices
  • Upgrade firmware in flash memory


ethtool eth0
ethtool -s eth0 autoneg off
ethtool -s eth0 speed 10 autoneg off
ethtool -i eth0
ethtool -K eth0 tso off
ethtool -K eth0 tso on
ethtool -a eth0