06 February 2014

How To: Set basic iptables rules

Create a shell script which does the following:

  1. Delete all existing rules
  2. Set default chain policies
  3. Allow inbound SSH
  4. Allow inbound HTTP
  5. Allow outbound SSH

Create the set-iptables-rules.sh
# nano set-iptables-rules.sh

and copy-paste the following:

04 October 2013

How To: Install Zabbix on Ubuntu 12.04 - AWS free tier

Install the Zabbix Server


Edit apt source list to add the PPA:
sudo nano /etc/apt/sources.list

Add the following items at the end of the file:
# Zabbix Application PPA
deb http://ppa.launchpad.net/tbfr/zabbix/ubuntu precise main
deb-src http://ppa.launchpad.net/tbfr/zabbix/ubuntu precise main

Press ctrl+x to quit, enter Y to save and close the file.

Next, we need to add the PPA's key so that apt-get trusts the source:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C407E17D5F76A32B

We can now install Zabbix:
sudo apt-get update
sudo apt-get install zabbix-server-mysql zabbix-frontend-php

During the installation, you will be asked to choose a password for the MySQL root account. Note the password so that you won't forget it.

28 September 2013

How To: Backup a MySQL Database with mysqldump

Backup

The basic syntax of the command is:

# mysqldump -u username -p database_to_backup > backup_name.sql

Restore

To restore a database dump created with mysqldump, you simply have to redirect the file into MySQL again.

We need to create a blank database to house the imported data.
First, log into MySQL by typing:

# mysql -u username -p

Create a new database which will hold all of the data from the data dump and then exit out of the MySQL prompt:

# CREATE DATABASE database_name;
# exit

Next, we can redirect the dump file into our newly created database by issuing the following command:

# mysql -u username -p database_name < backup_name.sql

Your information should now be restored to the database you've created.

How To: Update Hardware Clock - CentOS 6

Change the date with the "date" command, for example:

# date --set="6 SEP 2013 15:55:00"

To update the hardware clock use the following command:

# hwclock --systohc

To view the date/time in hardware clock use the following command:

# hwclock --show

01 August 2013

How To: Disable Iptables Firewall In Ubuntu Server

You can type the following command to see if firewall is active or not:

$ sudo iptables -L -n

You can save existing firewall rules as follows:

$ sudo iptables-save > firewall.rules

Finally, type the following commands to stop firewall:

$ sudo iptables -X
$ sudo iptables -t nat -F
$ sudo iptables -t nat -X
$ sudo iptables -t mangle -F
$ sudo iptables -t mangle -X
$ sudo iptables -P INPUT ACCEPT
$ sudo iptables -P FORWARD ACCEPT
$ sudo iptables -P OUTPUT ACCEPT

To disable ufw, enter:

$ sudo ufw disable