Repeat a Linux Command Every X Seconds Forever- using watch

Use watch Command

Watch is a Linux command that allows you to execute a command or program periodically and also shows you output on the screen. This means that you will be able to see the program output in time. By default watch re-runs the command/program every 2 seconds. The interval can be easily changed to meet your requirements.

Monitor Memory Usage

“Watch” is extremely easy to use, to test it, you can fire up a Linux terminal right away and type the following command:

# watch free -m

The above command will check your system free memory and update the results of the free command every two seconds.

Monitor Memory Usage in Linux

As seen per the above output, you have a header, displaying information about (from left to right) update interval, command that is being executed and current time. If you wish to hide this header, you can use the -t option. Continue reading “Repeat a Linux Command Every X Seconds Forever- using watch” »


Set Up Apache Virtual Hosts on Debian 7

Step One— Create a New Directory

First, it is necessary to create a directory where we will keep the new website’s information. This location will be your Document Root in the Apache virtual configuration file. By adding a -p to the line of code, the command automatically generates all the parents for the new directory.

You will need to designate an actual DNS approved domain (or an IP address) to test that a virtual host is working. In this tutorial, we will use as a placeholder for a correct domain name.

sudo mkdir -p /var/www/

*If you want to use an unapproved domain name to test the process, you will find information on how to make it work on your local computer in Step Seven. Continue reading “Set Up Apache Virtual Hosts on Debian 7” »


How to copy files using no owncloud web interface

Migrating was instant since we’re moving on the local fs. Checking the above screenshot you can see the rights are still the same of course. Own the folders to the ownCloud user and change the permissions to octal 755:

# Recursively own the folder to www-data

sudo chown -R www-data:www-data $OWNCLOUD_DATA_DIR/<user>/files/<folder>

# Set permissions so www-data has rwxr and group has read.

sudo chmod 755 $OWNCLOUD_DATA_DIR/<user>/files/<folder>

Moving a file/folder into ownCloud’s data directory doesn’t add it to the database automatically. Luckily, the ownCloud developers were kind enough to create a command line tool called occ that can manually add missing files and folders to the ownCloud database. You can run the following snippet on your server to check where this utility is located on the local file system:

find / -name "occ" 2>/dev/null

All you need to do is cd into that folder (in my case /var/www/owncloud) and run the following snippet:

For all account execute the following command:

sudo -u www-data php occ files:scan --all

For specific owncloud user id execute the following:

sudo -u www-data php occ files:scan <username>

Where www-data is the user your web server runs on. And now, it is time for the results:

YEAH!! So this command has definitely helped. Now you can add all your files directly into your ownCloud data folder without having to sync from the desktop client.



Increasing Attachment Size in Posfix

Postfix by default restrict attachment size to approx 10MB i.e. 10240000 bytes.

You can check it using following command:

postconf | grep message_size_limit

To change attachment-size to say 50 MB, run a command like:

postconf -e message_size_limit=52428800

If you are running a mail-server with SMTP/IMAP access, you need to change postfix attachment size only. I spent half-hour debugging dovecot to increase attachment size, just to realize that above change in postfix config was all I needed!


Install Poppassd in CentOS 7

Steps for configuration change password plugin for squirrelmail/Horde/Rainloop using poppassd are:

Download poppassd.c from

Look at poppassd.c and make sure it looks safe

yum -y install gcc
gcc poppassd.c -o poppassd -lcrypt
mv poppassd /usr/local/bin/
yum -y install xinetd
cp /etc/xinetd.d/time-stream /etc/xinetd.d/poppassd

nano /etc/xinetd.d/poppassdUpdate “service time” to “service poppassd”

disable = no
id = poppasswd
user = root
group = root
server = /usr/local/bin/poppassd
port = 106
systemctl restart xinetd
systemctl enable xinetd

Test by doing “telnet localhost 106” that service is started properly or not.

Your poppassd is now installed on Centos 7 system.



DNS Slave Using Virtualmin

DNS Slave Auto-Configuration Quickstart

A quick guide to assist administrators who want to use Virtualmin’s automatic DNS slave configuration features. This allows for DNS server redundancy.


Virtualmin can automatically manage any number of DNS slave servers for you. Once configured, it will create slave zones on other servers and configure them to automatically update when changes are made on your Virtualmin server. For this to work, you need Virtualmin on your primary server and Webmin (a free download) on your slave server(s). Henceforth, all references will refer to the primary server as the “Virtualmin server” and the DNS slave server as the “slave server”.

Getting Webmin for the Slave

If you don’t have Virtualmin installed on your slave server(s), you’ll need to install Webmin. Webmin is available for nearly every UNIX and Linux variant available, and is free to download and use. Continue reading “DNS Slave Using Virtualmin” »


Force reboot of a remote Linux machine

To force the kernel to reboot the system we will be making use of the magic SysRq key.

The magic_SysRq_key provides a means to send low level instructions directly to the kernel via the /proc virtual file system.

To enable the use of  the magic SysRq option type the following at the command prompt:

echo 1 > /proc/sys/kernel/sysrq

Then to reboot the machine simply enter the following:

echo b > /proc/sysrq-trigger

Voilà! Your system will instantly reboot.


Add a Static Route on CentOS

To add a temporary route:

ip route add via dev eth0

To make it persist system or network settings restart, create a route-ifname file for an interface through which the subnet is accessed, in this case eth0:

nano /etc/sysconfig/network-scripts/route-eth0

Add the line with the network settings for the other subnet: via dev eth0

If your computer is on a network and is not directly connected to the internet, it will be configured with what is called a default gateway, which is usually a router. If the computer cannot find the specific IP address on its local network (aka broadcast domain), as defined by its subnet, it will forward any packets headed to that IP address to the default gateway. The gateway will then attempt to forward packets elsewhere, such as the internet, or another broadcast domain Continue reading “Add a Static Route on CentOS” »