Skip to main content

Posts

Showing posts from July, 2014

Featured Post

Product Design of a 4 wheel differential drive robot

Linux command awk extract anything

Awk is pretty use full when you are writing automatic scripts to do your jobs. Some simple examples of how we can use awk are given below ps | awk '{print $1}' It will print first column of ps command.  If you want to print second column also write ps | awk '{print $1 $2}' Output seems to be pretty crowded? Add a simple space by ps | awk '{print $1 " " $2}' Want to limit it display only second line? ps | awk ' NR==2{print $1 " " $2}' Want to exclede first row? You can do it by ps |awk 'NR !=1{print  $1 " " $2}' Similarly you can print rows greater than a value by ps |awk 'NR >1{print  $1 " " $2}' You can extract virtually anything using awk... Feel free to explore every options. Type man awk or awk --help to explore other options. Feel free to comment also... :) This site has some good examlpes.

Pass output of one command to argument of other

Well Linux is famous for combining things in power full ways in which anything is possible from a command line. The real fun of Linux came when you start focusing on terminal to do everything... It's possible to pipeline commands in terminal. Also it's possible to pass output of something as an argument of other. For example you can ping to your own external ip by ping $(curl -s  curlmyip.com) curl curlmyip.com returns you ip address. This address is passed to  the telnet as an argument. Whatever you put between $( and ) will execute as if it is a bash command.

How to know external IP address from Linux terminal?

ifconfig displays only local ip address of your system. If your system is directly connected to internet then it will be your external ip address. It may not be the case always. Because you will be behind a router or a modem. You can know the external IP address by going to www.whatismyip.com or www.ipecho.net . If you want to know it from a terminal type curl curlmyip.com What curl do is it fetches the content of the link to the terminal. There are also several other websites that offers this same service. Some of them are listed below. curl  ipecho.net/plain curl myexternalip.com/raw curl curlmyip.com curl ifconfig.me/ip curl icanhazip.com curl ip.appspot.com

How to set dns address in android phones?

Ever wondered how setup dns address in android phones. You can do it if your phone is rooted. You may have a terminal installed with busybox if your phone is rooted. Otherwise install a terminal and gain root permission by typing su Then list all the device dns entries using this command getprop | grep dns Then set the dns entries by the command setprop net.rmnet0.dns1  8.8.8.8 Here rmnet0.dns1 is given as an example. This may vary depending on which dns entry you have to choose. 8.8.8.8 is the googles dns server address. Replace it with your choice.

Testing NAT Port Forwarding and reverese NAT

For a long time I have been trying to configure port forwarding using NAT. But every attempt was futile...  Finally I found that my port forwarding works just fine. But it just appears to be not working because my router doesn't support reverse NAT. In this post I will show you guys how to test whether you configure your NAT correctly or not. (Read a detailed write up by shane. Link ) First make a port forwarding rule in your router say 1600. Download this little tool called simple internet tools. Install it and open port listener and select your internal IP(192.168.x.x). Then type your port number and press start listening. Go to this site  and check whether it says port is opened. If your connection is successful you will notice it in the port listener application. Then go to your browser and type your internet ip address. (You can find it from www.whatismyip.com) . Tnen type your port number after a colon. (116.211.22.12:1600). Your browser shows a webpage not available w