Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jul 092012

How to show current routing table


To show the current system's routing table, you can try:

# sudo netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface         UG        0 0          0 eth0         UG        0 0          0 eth0   U         0 0          0 eth0   U         0 0          0 eth0
Jun 212012

Network sniffing with tcpflow


Wireshark is the De facto standard in network sniffing, but most of the time you might just want to analyse the content passing through your web browser or web server, then it is easy with tcpflow

For example, to show your communication with to console, you can use

sudo tcpflow -c -i en0 src or dst host

Feb 292012

How to get the hostname of a local machine using Java


The following codes illtsraeted how to get the hostname of the local machine using Java.


public class Test {

    public static void main(String[] args) {

        try {
            InetAddress addr = InetAddress.getLocalHost();

            // Get hostname
            String hostName = addr.getHostName();


        } catch (Exception e) {}
Sep 182011

Combine multiple images into a single image with ImageMagick


With the powerful ImageMagick program, we can easily handle common graphics tasks using command only.

For example, to combine multiple images into a single image, we need just one command:

# convert file1.jpg file2.jpg file3.jpg +append -quality 90 'output.jpg'

The above command (file1.jpg file2.jpg file3.jpg) into the file output.jpg with quality set to 90.