Replacing Many Similar Strings at the Same Time by Using VI Text Editor

VI is most common text editor in Unix or Linux based system. It is one of my favorites text editor, especially while working on developing shell script or editing simple text based file.

Sometimes it’s required to have a short cut way to replace many similar strings at the same time. Below steps will help to do the task:

  1. Open the script/text file with vi text editor
  2. Press “Esc” button
  3. Type command with following usage, then press “Enter
:<begin of line number>,<end of line number> s/<string replaced>/<string replacing>/g

For instance, we want to replace string “apple” with string “mango”. Here are two scenarios to show the implementation of 3rd step as mentioned above.

First, Replacing between from 2nd until 10th line

:2,10 s/apple/mango/g

Second, Replacing all

:1,$ s/apple/mango/g

How to Setup SSH Password Less in UNIX

Let us say, there are two servers, server-A and server-B. The objective is to setup password less from server-A toward server-B using RSA Key.

Here are step by step to follow:

Step#1: Create .ssh directory in server-A if it’s not exist.

server-A# mkdir ~/.ssh

Step#2: Go to inside .ssh directory

server-A# cd ~/.ssh

Step#3: Generate both RSA private and public keys

server-A# ssh-keygen -t rsa

Step#4: Transfer generated RSA public key from server-A to server-B

server-A# scp ~/.ssh/ <server-B>:/<home>/

Step#5: Go to server-B

server-A# ssh <server-B>

Step#6: Create .ssh directory in server-B if it’s not exist.

server-B# mkdir .ssh

Step#7: Change directory permission to be readable, writable and executable by the owner

server-B# chmod 700 .ssh

Step#8: Append transferred RSA public key of server-A to authorized_keys file inside .ssh directory of server-B

server-B# cat >> .ssh/authorized_keys

Step#9: Change authorized_keys file as following

server-B# chmod 644 .ssh/authorized_keys

Step#10: Logoff from server-A and test RSA password less setup from server-A toward server-B

server-B# exit
server-A# ssh <server-B>


1- Above steps were tried between two Unix Solaris based Servers.

2- If DSA Key is preferred, just replace ‘rsa’ with ‘dsa’ in above steps

How to Monitor Network Activity on Windows PC

While connecting to any network, we might want to know the network activities going on in our PC for some reasons. For example, what is port being used by specific application? What are remote IP addresses currently accessed by the applications? How its network I/O status? Which connections are currently having LISTEN status? Etc.

There are ways to do that in Windows, one is using command line netstat. The other one is GUI based tool, called Resource Monitor.


Basically this command, as stated in Microsoft Technet Support, is to display TCP connection (with its related information, like IP, port, connection status, protocol). For connection status, 10 possible values are CLOSE_WAIT, CLOSED, ESTABLISHED, FIN_WAIT_1, FIN_WAIT_2, LAST_ACK, LISTEN, SYN_RECEIVED, SYN_SEND, TIMED_WAIT.


netstat [-a] [-e] [-n] [-o] [-p Protocol] [-r] [-s] [Interval]


-a   Displays all active TCP connections and the TCP and UDP ports on which the computer is listening.

-e   Displays Ethernet statistics, such as the number of bytes and packets sent and received. This parameter can be combined with -s.

-n   Displays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to determine names.

-o   Displays active TCP connections and includes the process ID (PID) for each connection. You can find the application based on the PID on the Processes tab in Windows Task Manager. This parameter can be combined with -a-n, and -p.

-p   Protocol   Shows connections for the protocol specified by Protocol. In this case, the Protocol can be tcpudptcpv6, or udpv6. If this parameter is used with -s to display statistics by protocol, Protocol can be tcpudpicmpiptcpv6udpv6icmpv6, or ipv6.

-s   Displays statistics by protocol. By default, statistics are shown for the TCP, UDP, ICMP, and IP protocols. If the IPv6 protocol for Windows XP is installed, statistics are shown for the TCP over IPv6, UDP over IPv6, ICMPv6, and IPv6 protocols. The -p parameter can be used to specify a set of protocols.

-r   Displays the contents of the IP routing table. This is equivalent to the route print command.

Interval   Redisplays the selected information every Interval seconds. Press CTRL+C to stop the redisplay. If this parameter is omitted, netstat prints the selected information only once.

/?   Displays help at the command prompt.

Below sample will show all TCP connections whose state “LISTENING”

netstat -a -p tcp  | findstr LISTENING

Resource Monitor

This GUI based tool can be accessed on following ways: (1) Press Control+R, then type resmon, or (2) Search resmon in Start Program or (3) Open Task Manager – Click on Performance Tab, then Resource Monitor. While tool has been open, go to Network tab.

It has five main parts, Process with Network Activity, Network Activity, TCP connections, Listening ports, and Graph. Having more comprehensive while displaying the network activities, it will help network monitoring becoming easier.

Tools for Optimizing or Reducing Image Size

Sometimes we really need to reduce image size for certain purpose. For example, while sending image through e-mail, if size is too big, it may be blocked by mail provider policy. In other case, like posting image in website, not optimized image may lead to performance’s drop of website itself, slow in loading.

Having proper image size will help us to avoid such above issues. How image can be optimized? There are many tools available that can support us for this purpose. In this article, we will look into several of them.

1- Caesium

The best thing about this, it is opensource. Although it is free for use, does not mean it is lack of quality to optimize. I have tried it my self, and find it good. We can compress some images in one time. The supported images files are bmp, jpg, jpeg, tif, tiff, png, ppm, xbm, xpm. Other thing to mention is, there is portable version of this software, so we can use it easily without doing any installation. Interested? Kindly download it here.

2- iCompress

Same like Caesium, this is also opensource. Several images can be compressed one time, just mention folder where images are located and where there result will be put, then it will do the rest after “Compress All” button is clicked. Some parameters (quality, size and type of output-jpeg or png) are adjustable as we like. Please get it here.

3- Microsoft Office Picture Manager

If you installed Microsoft Office, this can be used as well. Edit the picture and choose which compress type you want. It could be for Documents, Web pages, or E-mail.

All of above tools, i tried on Windows, i believe there is also tools for other Operating Systems (OS), for example trimage (supporting cross platform including Linux), reduce image size for Android device, but i have not tried those yet.

4- Online Images Compressor Tools

If there is an internet connection, there are some good alternatives as well. I tried compressor, Tinypng, and jpeg-optimizer, all gave acceptable optimized output. Just follow simple steps: open related URL, upload the images, compress it and download the result. No additional software is required in your device. Compressor can compress images for jpeg, png, gif, svg format. The remaining are like their name, png and jpeg respectively.

Now, you can choose based on what you need or like. Or you may also find other nice and usable tools. Do not forget to take into consideration, like if you want to compress personal or sensitive images, online tool may be not preferred choice. And as precaution, kindly download any software from internet carefully, get it from trusted source or software repository only. As per my own experience, i got the compress tool, however it contained virus. Luckily, my antivirus could detect it.

Free Tools for Calculating Disk or Folder Usage Utilization in Windows

If you are looking for a way to calculate disk or folder usage utilization in system using Windows OS, probably below two tools can fulfill your need:

1- du.exe

This useful tool was developed by Mr. Mark Russinovich (and related team. Appreciate their works!) and you can download it here and put it in any place in your PC and decompress it. The usage is quite simple as explained in Microsoft Technet Website


Du (disk usage) reports the disk space usage for the directory you specify. By default it recurses directories to show the total size of a directory and its subdirectories.

Using Disk Usage (DU)

Usage: du [-c[t]] [-l <levels> | -n | -v] [-u] [-q] <directory>

-c Print output as CSV. Use -ct for tab delimiting.

-l Specify subdirectory depth of information (default is all levels).

-n Do not recurse.

-v Show size (in KB) of intermediate directories.

-u Count each instance of a hardlinked file.

-q Quiet (no banner).

As an example: below du.exe is used to create a simple report in .csv format of disk utilization for specific folder (called Download) with depth level is 3.

du -c -l 3 Downloads > test.csv

The output will be like this:

2- windirstat

Well, thanks to Mr. Bernhard Seifert (and related team). If you prefer GUI, windirstat is a tool to try. Its GUI is simple, easy to use. Just choose any drive (one or all drives) or specific folder needed to be checked, then it will give the usage status statistic with descending order in tree format. The tree is of course expandable till the lowest level.

The tool provides some menus. One of them is deletion which will be so much helpful while you want to apply clean up action directly toward unnecessary files or folders.

So, does they fulfill your needs? I hope so. If you have another recommendation, please don’t hesitate to share in comment.