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

Answer:

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
0.0.0.0         102.147.87.1    0.0.0.0         UG        0 0          0 eth0
0.0.0.0         102.147.45.1    0.0.0.0         UG        0 0          0 eth0
102.147.45.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0
102.147.87.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0
Jun 212012
 

Network sniffing with tcpflow

Answer:

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 google.com to console, you can use

sudo tcpflow -c -i en0 src or dst host www.google.com

Feb 292012
 

How to get the hostname of a local machine using Java

Answer:

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

import java.net.InetAddress;

public class Test {

    public static void main(String[] args) {

        try {
            InetAddress addr = InetAddress.getLocalHost();

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

            System.out.println(hostName);

        } catch (Exception e) {}
    }
}
Sep 182011
 

Combine multiple images into a single image with ImageMagick

Answer:

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.