Sukrit Dhandhania

Getting started with iptables in Linux

Linux machines are known to be pretty secure. Studies have shown that Linux has been designed in a secure manner. Yet, despite all the security features that come bundled with a Linux installation, you need to configure these features correctly to make them work for you. I’ll guide you through the process of setting up of one of the tools that help secure your machine – the firewall. We will use the iptables firewall for this exercise. I am assuming that you are using a server running Red Hat Enterprise Linux 4 or similar. However, most of the steps should work fine on other Linux distributions as well. In this article we will setup a firewall on a Linux server running the Apache Web Server, FTP, and SSH. …

How to send email from the Linux command line

The Linux command line can be very powerful once you know how to use it. You can parse data, monitor processes, automate backups and do a lot of other useful and cool things using it. There often comes a need to generate a report and mail it out. It could be as simple a requirement as a notification that the day’s backup went through fine, or did not. I’ll help you get started with sending mails from the Linux command line and in shell scripts. We will also cover sending attachments from the command line. We will begin with the “mail” command. …

How to reset a lost MySQL root password

Have you ever forgotten your MySQL root password? It’s one of those things that just happens despite the numerous precautions one might take. As a result, you are locked out of your database server. You can’t create new databases and are left with little control over the state of your database server. In such situations knowing how to regain root access to your database server comes in handy. So here’s what you can do to reset the password for the root user in MySQL on both Windows and Linux. …

How to create automated Linux/Unix backups

“A stitch in time saves nine”, goes an old saying. In the world of computers we refer to that stitch as backups. When running a production IT infrastructure, it is imperative that we achieve an uptime on our servers and applications of as close to a hundred percent as possible. While there are a number of ways to make an IT infrastructure solid, it is impossible to make it failure proof. So we make a plan B.

Servers are made of three broad layers – the hardware, the operating system and applications, and the data. In case of a hardware failure it is rather simple to replace the machine with a new one. Installing the operating system and applications too are relatively simple. The part that is hard to replace is the data and configuration that your applications use. In case of failure this is the part that can not be replaced. So we backup that data on a regular basis. We back it up in such a way that it becomes easy to retrieve in case of emergency. …

Increase your Linux/Unix Productivity: How to use crontab

Apart from video games one of the great advantages of using computers is that they don’t seem to mind doing boring and repetitive tasks that we would rather not do. For monotonous tasks such as running daily backups we are better off scheduling them to run at a certain time every day, and do more interesting stuff with our time. Linux and UNIX usually come with the utility “crontab” by default. This very useful command allows you to schedule tasks to run at a specified time and repeat as configured. A task scheduled using “crontab” is called a “cron job”. …

How to use dstat to monitor your Linux/UNIX server

If you have a Linux server running at your office or at a data center for which you are responsible, you want to maintain an uptime of as close to a hundred percent. In such a case you want to make sure you keep an eye on how the system is running. To be precise you want to monitor all the system resources that contribute to the system running fine which then results in a high uptime. Memory, CPU, disk usage… are some of the things you want to observe. We would usually use a combination of the tools that come with a Linux or UNIX installation, such as “free”, “top”, “vmstat”… I’ll introduce you to a tool that gives you just about all the info that the other tools combined give you, all under one roof – Dstat. The developer of this command line tool, Dag Wieers, calls it “a versatile replacement for vmstat, iostat, netstat and ifstat”. He adds that “Dstat overcomes some of their limitations and adds some extra features…” To me Dstat is the mother of all command line system monitoring tools. It’s simple to install, easy to use, can be tweaked with ease, and it generates reports that you can plot as a graph to impress your boss. …