Search This Blog

Thursday, May 24, 2012

Netstat linux command

netstat command is used to obtain network related information.

Such as
Routing table
Port information
Network interface information

let us explore netstat one by one.

1) How to display Routing table in linux?
2) How to find the port of particular application?
3) How Find out number of Machines (IP address) connected to Linux Server?

1) How to display Routing table in linux.

You can use netstat command to display routing table in linux.

#netstat -r

Tuesday, May 15, 2012

ls command delays in displaying output


Step 1:
We face issues and we tend to find an answer.
Step 2:
We get the answer and we resolve the issue.
Step 3:(Optional and always ignored)
I think its a time to document it . You will find all such instances under Problem and Answer section.



Back in october 2011 i faced a strange issue while listing the files.

I fire my favorite command to display the files/folders


#ls -ltr

to my surprise my system hanged for some time and there was significant delay in showing the output(Delay of 3 minute 2 sec. )

#time ls -ltr 
real 3m2.443s
user 0m0.003s 
sys 0m0.002s

I checked the load on system but it was within the accepted level .

Later i just issued ls command without -l option and everything looked ok.

#time ls 
real 0m0.004s
user 0m0.000s
sys 0m0.002s

This was something i never encountered before so i raised queries regarding the same on almost all linux forum.
http://www.linuxforums.org/forum/newbie/180596-execution-delay-listing-files.html#post851886

Some of the answers were really worth mentioning here.
1) the aliased "ls" command may be at fault.
Try running the command "/bin/ls -ltr" and see how that works.

2)Well the t flag sorts by modification time and then the r flag reverses the order, so maybe if there are a lot of files in that directory the sort is taking time, try running the following to identify which flag is slowing it down time ls
time ls -l 
time ls -t 
time ls -r

Answer:

The actual problem was of incorrect ownership of one of the folder. When i tried executing ls -n it resulted in faster responce . -n option make sure that only uid and gid are displayed. I figured out that one of the folder had wrong ownership. I changed the ownership of the folder and the problem was solved.