How to do DNS lookup using Dig Command

Dig command is a command line tool use for querying DNS nameservers for information about host addresses, mail exchanges, nameservers, and related information. This tool is available on any Linux (unix) or Mac OS X operating system.

Example of using Dig Command

munkwais-MacBook-Pro:~ munkwai$ dig www.google.com

; <<>> DiG 9.8.3-P1 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32350
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.google.com. IN A

;; ANSWER SECTION:
www.google.com. 299 IN A 173.194.126.80
www.google.com. 299 IN A 173.194.126.81
www.google.com. 299 IN A 173.194.126.83
www.google.com. 299 IN A 173.194.126.82
www.google.com. 299 IN A 173.194.126.84

;; Query time: 44 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Apr 16 04:29:00 2015
;; MSG SIZE rcvd: 112

Continue reading

How to gracefully restarting the Apache httpd daemon

ApacheToday i received an email from our customer said that they do not know how to restart the Apache Web Server graceful. Restarting Apache Web Server also known as gracefully restarting the Apache httpd daemon.

Gracefully restarting httpd daemon will ensures that existing processes are allowed to finish serving the current page. Besides, it will reduce the chance of disrupting a user’s browsing experience.

How do i gracefully restart Apache Web Server?

To gracefully restart Apache web server. Please enter following command as the root user:-

Under Debian / Ubuntu Linux

apache2ctl graceful

Under RedHat / Centos / Fedora Linux

apachectl -k graceful

Continue reading

How to rsync with custom SSH Port

rsync is a great utility used to synchronize the files and directories from one location to another in an effective way. Normally i use rsync command to transfer files from my Mac OS X Machine to my Linux Server. Recently i change all my Linux Server SSH port from default port 22 to port 2424. When i try to transfer files from my local machine to my linux machine via rsync, it failed. By default, rsync command won’t work with custom SSH port as it assume the SSH port is set to 22.

After i read through the man page of rsync command, i found a solution on how to rsync file to a custom SSH port machine.

The solution is simple by add the -e flag. This flag allows you manually define the ssh command to use when connecting

Syntax

rsync -avz -e “ssh -p $sshPortNo” user@remoteIP:/path/to/files/ /local/path/

Example:

rsync -avz -e “ssh -p 2424” techkaki@192.168.1.4:/tmp/sample.txt /Users/techkaki/Downloads/

Done!! 🙂