ftp – sync data from remote ftp server


To sync data from remote ftp server install ncftp with following command:

apt-get install ncftp

Now use following command to sync data from remote ftp server:

ncftpget -R -T -v -u userName -p 'password' ftp_hostname "directoryPathInFtpServer" "directoryPathInLocalMachine"


Get gitlab version number from Gitlab cli


To get Gitlab & other dependent modules version numbers use the following command:

gitlab-rake gitlab:env:info

The output will include all details like Gitlab version, git version, git shell version, OS version, Ruby version, Gem version, Bundler version, Rake version, Redis version, Sidekiq version & etc…

vim – set tab space


To change tab space width to 4 spaces add following code in /etc/vim/vimrc file

filetype plugin indent on
"to show existing tab with 4 spaces width
set tabstop=4
"when indenting with '>', use 4 spaces width
set shiftwidth=4
"On pressing tab, insert 4 spaces
set expandtab

This will convert all existing tabs to 4 spaces width & also all new tabs with 4 spaces width.

Get Thread and Heap dump – Java


Thread and Heap dumps are useful for debugging any Java programme.

To get thread dump:

By using jstack command we can get thread dump of a Java process.


$ jstack PID

where PID is Java process id for which we want to get thread dump.

To get heap dump:

By using jmap command we can get heap dump of a Java process.


$ jmap -heap PID

where PID is Java process id for which we want to get heap dump.

ping ip with port


Ports are a concept of UDP and TCP. Ping messages are technically referred to as ICMP Echo Request and ICMP Echo Reply which are part of ICMP. ICMP, TCP, and UDP are “siblings”; they are not based on each other, but are three separate protocols that run on top of IP.

Therefore you can not ping a port. What you can do, is use a port scanner like nmap and check if ip/host and port are accessible.

$ nmap -p 80 www.google.com


Starting Nmap 6.40 ( http://nmap.org ) at 2015-12-02 14:38 IST
Nmap scan report for http://www.google.com (
Host is up (0.085s latency).
Other addresses for http://www.google.com (not scanned):
rDNS record for sa-in-f106.1e100.net
80/tcp open http

Nmap done: 1 IP address (1 host up) scanned in 0.64 seconds

You can also use telnet onofri.org 80

Linux – Ping multiple hosts using fping


fping is a ping like program which uses the Internet Control Message Protocol (ICMP) echo request to determine if a host is up.

With fping we can ping multiple hosts at a time. Use following command to ping multiple hosts:

$ fping -f IPsFiles.txt 

where in IPsFiles.txt I have multiple hots.

Below are some other examples of fping:

To ping a host/IP:

$ fping

Output: is alive

$ fping

Output: is unreachable

To ping range of IP’s:

$ fping -g

To list only unreachable hosts/IP’s

$ fping -q -u -f IPsFiles.txt

where -q is for Quiet mode and -u is to list only unreachable targets.

To list only reachable hots/IP’s

$ fping -q -a -f IPsFiles.txt

where -a is to list only alive hots.

iptables allow port for ip


To allow only an ip to access a port use following iptables rule

iptables -I INPUT -p tcp -m tcp -s --dport 8080 -j ACCEPT

Above iptables rule will allow only to access port 8080 and reject all other ip addresses.

Similarly we can give any other ip address and port combination.