Show complete URL in netstat output

netstat -pnut -W | column -t -s $'\t'
This takes all of the tab spaces, and uses column to put them into the appropriately sized table.
Sample Output
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 192.168.178.139:59711   xxx.xxx.xxx.xx:7000     ESTABLISHED 7211/xchat      
tcp        0      0 192.168.178.139:46307   xxx.xxx.xxx.xxx:2204    ESTABLISHED 37550/ssh       
tcp        0      0 192.168.178.139:39466   xxx.xxx.xxx.xxx:22      ESTABLISHED 36789/ssh       
tcp        0      0 192.168.178.139:54130   xxx.xx.xxx.x:22         ESTABLISHED 7405/ssh        
tcp        0      0 192.168.178.139:52571   xxx.xx.x.xx:22          ESTABLISHED 32981/ssh       
tcp        0      0 192.168.178.139:37883   xxx.xxx.xxx.xxx:22      ESTABLISHED 9419/ssh        

2
By: Nadiar
2014-05-03 00:48:53

1 Alternatives + Submit Alt

  • The -W switch of netstat makes it print complete URL of the connections, which otherwise by default is truncated to fit its default column size. Now to compensate for irregular column sizes, pipe the output to column (-t switch of column prints in tabular form). The only downside to this part is that the very first row, the header, goes pear shape. Show Sample Output


    6
    netstat -tup -W | column -t
    b_t · 2014-01-08 22:39:01 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: