On Java, Python, Groovy, Grails, Spring, Node.js, Linux, Arduino, ARM, Embedded Devices & Web

Archive for the ‘CentOS 6.X’ Category

Set Up a TFTP Server on Linux |

Posted by Venkatt Guhesan on March 13, 2017

Most users are familiar with FTP, but if you want to kickstart Red Hat installs, PXE boot systems, auto-provision VoIP phones or unbrick a Linux-based router, you want a Trivial File Transfer Protocol (TFTP) server. Setting one up on Linux is easy, and a perfect project to take on over the weekend.

Source: Weekend Project: Set Up a TFTP Server on Linux | | The source for Linux information

Posted in Bash, CentOS 6.X, CentOS7, Hypervisior Images, Linux, Scripting | Tagged: , , | Leave a Comment »

How To Record Everything You Do In Terminal – OSTechNix

Posted by Venkatt Guhesan on March 13, 2017


script -a my_history

mkdir test

cd test

touch hello_world.txt

echo 'Hello World' > ./hello_world.txt

# This closes the "script -a my_history" file

Source: How To Record Everything You Do In Terminal – OSTechNix

Posted in Bash, CentOS 6.X, CentOS7, Linux, Scripting | Tagged: , , , , , | Leave a Comment »

Developing email applications on Windows, targeted for Linux environment – email, mailx, sendmail

Posted by Venkatt Guhesan on December 11, 2016

linux_centos_logoIf you’re developing on a Windows platform for an application targeted for Linux or Unix that deals with email, then this article will be useful.

Let us begin by  understand the problem.


If you are a Java/Spring developer, (developing in Java is platform independent – runs on any platform where a JVM is available) then you have two options in front of you for sending emails from a Java application:

Option #1: JavaMail API

Option #2: Linux sendmail or mailx invoked via Runtime.getRuntime().exec(invoke – linux – mail – command) [example here]

If you are a PHP or Ruby or Bash or Python developer, you can do the same using a native library available within the language or invoke a native Linux execute-command to invoke either sendmail or mailx.

What happens if you are developing a hybrid library that needs to send email both from Java and Python. Then most likely you want to leverage a common library accessible to all the various libraries. In this case, you’re going to depend on either sendmail or mailx.   Now let us throw in a additional problem into this mix. Suppose you are developing on a Windows platform but the end application is targeted to run on Linux. This now creates a new additional problem. Sendmail or Mailx do not exist for Windows. Well, this article provides a way to develop on Windows by invoking execute mailx calls from your native code to the underlying emulation of Linux on Windows.

Now that we have established the problem, let us walk through a solution.

Please note that this is not the only solution but a potential solution. If you know of other mechanisms, feel free to send me a link and I’ll add them in.


Step-1: Make sure that you have Cygwin installed (with email tool selected additionally) on your Windows computer.

# Download  setup-x86_64.exe from
# and run it.

# When you run the setup, please additionally select "email" tool additionally. It is not added by default.

Once Cygwin is installed, most people traditionally use all the Cygwin tools from within a Cygwin Command-Prompt. The executables are located under “\bin\**” directory. Which means that if you run a “ls” in a DOS command-prompt, it will error saying “command not found”. There is a undocumented\not so known secret to emulating Linux commands natively in Windows. This is where your true Linux power comes in under native Windows.

Step-2: Add Cygwin\bin path natively to Windows PATH.

# In my computer, I have Cygwin installed at the following path: c:\cygwin64\

To add "c:\cygwin64\bin" the system path, perform these steps:

1. Start the System Control Panel applet (Start - Settings - Control Panel - System).
2. Select the Advanced tab.
3. Click the Environment Variables button.
4. Under System Variables, select Path, then click Edit.
5. Add c:\cygwin64\bin to the path.

Once Step-2 is completed. If you start a new DOS command-prompt and run a “ls” command, you should see the directory listing (same as a ‘dir’ command under Windows).

Step-3: The send email application uses “c:\cygwin64\etc\email\email.conf” for SMTP and other email properties.

# Edit c:\cygwin64\etc\email\email.conf and add your SMTP details (domain/server name, user-id, password)
# For this example, I have setup a *special* GMail Email account specially to test [Don't use your private GMail] so I will use the user-id and password for that Gmail account.

SMTP_PORT = '587'
USE_TLS = 'true'
MY_NAME  = 'Venkatt Guhesan'

Step-4: Let’s test this under a DOS command-prompt.

# Open a DOS Command-Prompt and run the following:

echo "Test from Cygwin in Windows under DOS command-prompt" | email -s "Testing Email from Windows DOS" 

# Within minutes, you should see an email in the Gmail inbox as expected.

# If you are not seeing it, then you can use the example below where you can pass in the SMTP arguments for validation. Maybe you typed in the password for the Gmail account incorrectly or you entered one of the parameters incorrectly in the c:\cygwin64\etc\email\email.conf file.

echo "Test from Cygwin in Windows under DOS command-prompt" | email -s "Tetsing Email" -r -p 587 -m login -u -i YOUR_GMAIL_PASSWORD_GOES_HERE -tls


Once you have confirmed a successful email then the next step is to create a mailx application.

Step-5: Create a mailx.exe (mailx) within Cygwin’s bin directory.

For emulating mailx from Cygwin’s email.exe, you’re in luck. The format for mailx is identical to the email.exe’s arguments. All you are missing is mailx.exe. So simply copy email.exe under Cygwin’s bin directory to mailx.exe under the same Cygwin’s bin directory. And you’re all set!

# simply copy email.exe under Cygwin's bin directory to mailx.exe under the same Cygwin's bin directory

cd c:\cygwin64\bin
cp email.exe mailx.exe

# Now just like you running email (without the .exe suffix) you can run mailx (without the .exe suffix)

Step-6: Test sending an email using mailx

echo "Test from Cygwin-mailx in Windows under DOS command-prompt" | mailx -s "Testing Email from Windows DOS" 


As a last step, now within your Java application, test Runtime.getRuntime().exec(“mailx command”);

Runtime.getRuntime().exec("echo 'Test from Cygwin-mailx in Windows under DOS command-prompt' | mailx -s 'Testing Email from Windows DOS'");

Now your Java application as well as any Python, Bash, Linux shell applications and/or scripts are now leveraging the common “mailx” and your development is now consistently the same using one common mailx library.


Today’s inspirational quote:
  • We must all either wear out or rust out, every one of us. My choice is to wear out.
– Theodore Roosevelt, an American statesman, author, explorer, soldier, naturalist, and reformer who served as the 26th President of the United States from 1901 to 1909.

Posted in Bash, CentOS 6.X, CentOS7, Grails, Groovy, Java, Linux, Spring, Windows | Tagged: , , , , , , | Leave a Comment »

CentOS 6.8 & 7 – Change Timezone

Posted by Venkatt Guhesan on November 6, 2016


Here is a cheat sheet on changing the timezone in a linux system (CentOS 6.8 or 7):

# Remove the current timezone file
rm /etc/localtime

# Create a symbolic link to the new timezone you want
# ls -la /usr/share/zoneinfo/
# ls -la /usr/share/zoneinfo/US/

# For GMT
ln -s /usr/share/zoneinfo/GMT /etc/localtime
# For EST
ln -s /usr/share/zoneinfo/EST /etc/localtime
# For UTC
ln -s /usr/share/zoneinfo/UTC /etc/localtime
# For GMT
ln -s /usr/share/zoneinfo/GMT /etc/localtime
# For New York (Eastern)
ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime
# For Central
ln -s /usr/share/zoneinfo/US/Central /etc/localtime
# For Mountain time
ln -s /usr/share/zoneinfo/US/Mountain /etc/localtime
# For Pacific time
ln -s /usr/share/zoneinfo/US/Pacific /etc/localtime

# Set Date and Time (as needed)
date 072522172010
hwclock --systohc

# If you're using NTPD Service
# CentOS 6.8
service ntpd stop && service ntpd start
# In CentOS 7 
systemctl stop ntpd && systemctl start ntpd

You may also be interested in NTP Service blog article here.

Today’s inspirational quote:
  • Men (people) are disturbed not by events but by their opinion about events.
  • Wealth consists not in having great possessions, but in having few wants.

Posted in CentOS 6.X, CentOS7, Linux | Tagged: , , , , , | Leave a Comment »

How to sync your date when you restore a VirtualBox snapshot?

Posted by Venkatt Guhesan on November 5, 2016

hypervisor_logoThis article focuses on synchronizing/updating the clock in your guest linux VM after you restore a VirtualBox snapshot.

When you create a VirtualBox snapshot, it’s essentially a photo taken and frozen in time. All bits including the date and time are frozen to that instant. When you restore a snapshot, the Linux guest VM system is restored back to that snapshot including the date and time. This may not be desired all the time especially if the purpose is to restore the configuration and settings to an earlier time but your want to roll forward the clock on the VM to the present instance. The outlined steps below can also apply to other virtual hypervisors like Qemu, VMWare, Amazon S3 images, etc. (essentially where ever you may have a CentOS or Red Hat Linux Virtual instance and with slight modifications the same can be applied to any Linux guest hypervised image)

Below are a few simple steps you can take to reset the clock:

Steps to perform before you create a VirtualBox snapshot:

# Install ntp service 
yum -y install ntp
# Turn it on so that it starts up automatically on reboot
chkconfig ntpd on
# Point it to your nearest internet accessable NTP server available around the globe for time-services 
# Manually start it up and ensure that it comes up
service ntpd start

Now take a VirtualBox snapshot as needed.

When you restore a snapshot, do the following after the snapshot is restored:

# After snapshot restore, run 

That’s it! Your date & time should now be updated but all of the other settings and modifications you have done will be restored to it’s former glory!

What is NTP?
NTP stands for Network Time Protocol, and it is an Internet protocol used to synchronize the clocks of computers to some time reference.


Today’s Inspirational Quotes:

bust_of_marcusaureliusIf you are distressed by anything external, the pain is not due to the thing itself, but to your estimate of it; and this you have the power to revoke at any moment.

Marcus Aurelius, Meditations



Posted in CentOS 6.X, CentOS7, Hypervisior Images, Kernel, Linux | Tagged: , , , , , | 1 Comment »

Two useful links comparing CentOS 6.X’s – SysV-Init vs CentOS 7.X – SystemD – init systems

Posted by Venkatt Guhesan on July 19, 2016

In CentOS 6.8, the init system that brings up all the services (link autoexec files in Windows) was called SysV- Init. This has been the foundation for ages as long I’ve been using CentOS. But in the latest release of CentOS (CentOS 7+) the init engine has been moved to a more favorable engine labeled SystemD. SystemD is the init engine behind Ubuntu, Fedora, Red Hat and CentOS. So the standardization is good for the Linux community but moving from CentOS 6.8 to CentOS 7 is not a trivial task (especially when it comes to RPMs that working on the SysV-Init paradigm).

Here are two links that outlines the differences:




Posted in CentOS 6.X, CentOS7, Linux | Tagged: , , , , , , | Leave a Comment »