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.

Dec 222010
 

Get HTTP request with nc command

Answer:

nc command is a very useful tool for network diagnosis, e.g. when you want to know the exact requests sent by your HTTP client (e.g. browser) to your web server, you can easy test with nc.

1. In your server, start nc and listen on port 80

# sudo nc -l -p 80

2. In your browser, type the server IP address.

3. In your shell, HTTP requests will be printed.

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.3) Gecko/20090712 Firefox/3.5.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Dec 152010
 

What are the difference between tail -f and tail -F?

Answer:

Basically these two command are very similar, except tail -F do one more thing: the retry.

This is useful when you are tailing a web server log, e.g. apache log. When the the log file got rotated, the tail -F will continue to work since it will retry for the rotated file, while tail -f can't.

Dec 102010
 

Extract a bzipped tar file

Answer:

Normally tar is combined with gzip as the most common usage, however, sometimes people use bzip2 instead for maximum compression rate. File in such format usually have the file name like: program.tar.bz2

To extract it using a single command:

# tar -jxvf program.tar.bz2

The key is the argument - j