Connect to serial console from Linux command line

The easiest way to connect to a serial console from Linux command line is using the screen command. In my example below, I will show you how to connect to a serial console of a server using the serial to usb cable.

[root@test ~]# screen /dev/ttyUSB0
 Connected to *******

Enjoy 🙂


Delete files starting with hyphen (-)

Today I have gone through something interesting, Just to remove a file in Linux; but the file starts with a hyphen!

[root@test]# rm '-g.txt'
rm: invalid option -- 'g'
Try rm ./-g.txt' to remove the file `-g.txt'.
Try `rm --help' for more information.

Yes error message said it, just use the format

rm -rf ./filename_with_hiphen

Enjoy 🙂

Device eth0 does not seem to be present, delaying initialization.

You might have come across this headline, especially if you working with Oracle Virtual box machines, machines those are cloned from previous setups etc.


To resolve the issue, just remove the file /etc/udev/rules.d/70-persistent-net.rules and reboot the machine. This file contains the MAC address details associated with the machine. If you don’t want to reboot the machine, run the below command :

udevadm trigger --subsystem-match=net

This command will trigger the rules again.

Enjoy 🙂

“This page includes other resources which are not secure.” || “The connection to this website is not fully secure because it contains unencrypted elements(such as images) or the encryption is not strong enough”

“This page includes other resources which are not secure.”

“The connection to this website is not fully secure because it contains unencrypted elements(such as images) or the encryption is not strong enough”

You might have noticed these warnings in your browsers even though you installed your SSL certificates correctly and wondering what is the next step to do. The answer is just replace the http links with https in your websites. Yes, you should find out all the insecure calls(http) to images,videos,css,javascript and replace it with https. It is a hair pulling job to find out these links manually and replace them correctly. But I can definitely help you to find out the http links.

Try the below things.


Just give your website link in this website and check. It will list all the insecure URLs in your website.

In some cases, I have noted that the SSL warning comes only after you login, In that case, you cant use my first suggestion and you can use the chrome console as mentioned below

2. Using Chrome console

Load the site in google chrome -> Press F12 -> Select Console.
You can see the warning in red color that the mixed content should be replaced. Once you replace all those http links with https, your site should load fine.

Hope this helps 🙂

Linux Cluster using drbd and heartbeat

Here I am discussing about how to setup a cluster of two linux servers. serverg1 and serverg2 are the two linux servers with IP address and respectively. Flush the iptables before the setup. I am using the floating IP address for this cluster. Before starting the installations, Make sure that you have a partition of equal size available for this setup. Here I am creating a partition /dev/sdb1 of 100 MB size.

fdisk /dev/sdb
Restart the servers
mke2fs -j /dev/sdb1

dd if=/dev/zero bs=1M count=100 of=/dev/sdb1;sync

Now the partition is ready for the installation. We can start installing the packages :
yum install drbd84-utils.x86_64
yum install kmod-drbd84.x86_64
yum install heartbeat
Update the /etc/hosts file with the hostnames for easy dns resolution. serverg2 serverg1

DRBD Configuration

Now edit /etc/drbd.conf with the below values :

global { usage-count no; }
resource r0 {
protocol C;
startup { wfc-timeout 10; degr-wfc-timeout 30; } #change timers to your need
disk { on-io-error detach; } # or panic, ...
net {
after-sb-0pri discard-least-changes;
after-sb-1pri discard-secondary;
after-sb-2pri call-pri-lost-after-sb;
cram-hmac-alg "sha1";
shared-secret "my_secret_password_G";
syncer { rate 5M; }
on serverg1 {
device /dev/drbd0;
disk /dev/sdb1;
meta-disk internal;
on serverg2 {
device /dev/drbd0;
disk /dev/sdb1;
meta-disk internal;

copy the configuration file /etc/drbd.conf to the second server.

scp /etc/drbd.conf root@serverg2:/etc/drbd.conf

Now create the metadata on both the servers:

drbdadm create-md r0

Start drbd on both the servers:

service drbd start

Verify both the servers are secondary :

cat /proc/drbd

You can see both the nodes as secondary, that is natural. Now we need to start the initial replication from the master server(here serverg1)

drbdadm -- --overwrite-data-of-peer primary r0

watch the drbd process until it shows uptodate:

watch -n 1 cat /proc/drbd

Now format the drbd partition and mount it on the master server

mkfs.ext4 /dev/drbd0
mkdir /replication
mount /dev/drbd0 /replication

At any time, you can check the server role by using the below command :

drbdadm role r0

Primary server should return,

[root@serverg1 ~]# drbdadm role r0

If you want to switch to the second server, run the below in the primary server:
1. umount /replication
2. drbdadm secondary r0
run the below in current seconday server:
mkdir /replication
drbdadm primary r0
mount /dev/drbd0 /replication
Once you are switched the servers, confirm the status by

df -h
drbdadm role r0

So we have gone through how to switch manually. we can automate the same using heartbeat.

Heartbeat configuration:
Create a configuration file /etc/ha.d/ on the primary server serverg1

debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
bcast eth0
auto_failback on
node serverg1
node serverg2

set auto_fallback to ‘off’ to avoid switching the server back to the primary from the slave server.
Create /etc/ha.d/authkeys file and add the below :

auth 1
1 sha1 MySecret

Change the permission to 600

chmod 600 /etc/ha.d/authkeys

Edit /etc/ha.d/haresources as below:

serverg1 drbddisk::r0 Filesystem::/dev/drbd0::/replication::ext4 IPaddr:: mysqld

It is important to keep the contents in separate lines. Now start the heartbeat service in serverg1
service heartbeat start
Now copy all the heartbeat files to the second server:

scp /etc/ha.d/ /etc/ha.d/authkeys /etc/ha.d/haresources root@serverg2:/etc/ha.d/

Now start the heartbeat service in second server(serverg2)

service heartbeat start
chkconfig --add heartbeat
chkconfig heartbeat on

Now verify the primary and secondary numbers using the command :

drbdadm role r0
df -h

If you stop the heartbeat service in one server or shutdown the server, partition will mount automatically to the other server and the services mentioned in the haresources file will start.

check the srv record from Linux machine (sip or exchange autodiscover)

You can use any of the below 2 methods to find out the srv records :
1. Using dig

root@test:~# dig srv

(check for the answer section similar to below )

;; ANSWER SECTION: 29 IN SRV     10 10 443

2. Using nslookup

root@test:~# nslookup (press ENTER)
> set type=srv (press ENTER)
> (press ENTER)

(See the output similar to below )

Non-authoritative answer:        service = 10 10 443

Authoritative answers can be found from:   internet address =

Redirect a site using html

You can use the below code to redirect a site to

<html lang="en-US">
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1;url=">
<script type="text/javascript">
window.location.href = ""
<title>Page Redirection</title>

If you are not redirected automatically, follow the <a href=''>link to my blog</a>


Enjoy 🙂