Technosailor
  • Home
  • Blog
  • Venture Files
  • Espanol
  • Technosailor Staff
  • Twitter Pitch Me!
Sep
30
2004

Linux Tip: Finding All Connections on a Port

Posted by: Aaron Brazell

I used to do Linux tips all the time over at Ensight back in the early days when Jeremy and I were group blogging and long before he decided to sell Ensight and make national Canadian news. :)

So I’m back at it again. I’ll try to deliver some handy tricks and tips that I’ve picked up along the way in a semi-regular entry.

Tonight, let’s look at a good jumping off point if you think you are being hacked.

The lsof command is useful for discovering open files by a given process. Because Unix and Linux treat all files, devices, directories and kitchen sinks as “files”, we can use lsof to find open network connections too.

For instance, if I want to find out every current connection over Secure Shell (Port 22), I can run lsof with the -i argument and the port number.

root@server [/home/admin]# lsof -i :22 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME sshd 6241 root 3u IPv4 5760 TCP *:ssh (LISTEN) sshd 24719 root 4u IPv4 744723 TCP server.example.com:ssh->xxx.xxx.xxx.xxx:3915 (ESTABLISHED) sshd 24736 admin 4u IPv4 744723 TCP server.example.com:ssh->xxx.xxx.xxx.xxx:3915 (ESTABLISHED)

*Note - some distros do not include the lsof in the path. It is typically kept in /usr/sbin but may be different by setup.

*Note 2 - the xxx.xxx.xxx.xxx corresponds to the IP of your connection or your ISP-assigned hostname.

What this output tells me is that there is a TCP connection listening with the sshd daemon on port 22, that there is a TCP connection USING the sshd daemon and logged on as root and another TCP connection utilizing the sshd daemon on port 22 using the admin username.

Since these are all me, I do not worry any further.

If you want to do further research, the process ID (PID) is available as well as the ps command.

  • Add to Mixx!
  • Stumble it!
About the Author: Aaron Brazell is the lead editor of Technosailor.com and a social media expert. His passion is to see companies and individuals use the internet and web technologies wisely and effectively to promote their brands and companies. He served as Director of Technology at b5media from 2005-2008 and is currently an independent consultant.
Tagged: at 1:10 am -

Comments are closed.

  • Recent Posts

    • Western Style Writing vs. Eastern Style Writing
    • How Has Social Software Changed Your Life?
    • America the Beautiful
    • Identi.ca and the Art of the Launch
    • Job Search: Define Your Goals
  • Reader Contribution

    • Sean on Western Style Writing vs. Eastern Style Writing
    • Leslie Poston on Western Style Writing vs. Eastern Style Writing
    • Betsy Buchanan on 10 Things You Need to Know About WordPress 2.6
    • Aaron Brazell on Western Style Writing vs. Eastern Style Writing
    • Igor The Troll on Western Style Writing vs. Eastern Style Writing
  • RSS Venture Files

    • The Difference Between Designers and Marketers
    • But this worked four years ago?
    • Rules for Entrepreneurs - Avoid relying on a few whale customers
    • 6 Steps to Successful Small Business PR
    • Rules for Entrepreneurs - Outsource what you suck at
  • RSS Wicked Marketing

    • Yeah it’s cheaper, but what are you really getting?
    • What a designer is and isn’t…seriously you need to know…
    • The difference between success and closing next year…
    • It’s time to get Wicked…
  • RSS Technosailor en Español

    • PopTok: usa tus películas favoritas para enviar un mensaje
    • Video en Vivo desde tu iPhone
    • 7 Funciones que le Faltan al iPhone 3G
    • Como Vencer la Sobrecarga Informativa
    • La Batalla es Digital
  • Tip Jar


  • License Creative Commons Attribution-Noncommercial-Share Alike 3.0 | Copyright © 2004 - 2008 - Aaron Brazell | Lisa helped out | Privacy Policy

    Twitter Pitch!

    <p>Twitter pitching is a form of pitch that requires succint "what does this mean for me" kind of pitching. It is the ultimate efficiency of words. You have 140 characters or less to tell me why your pitch matters to me or my readers. Please include a means of contacting you. This is included in your 140 characters. If you send successive pitches, you will likely be ignored, unless it's obvious that the first pitch was a case of "accidental send", etc.</p> <p>This form of pitching does not mean I'm being a diva. It means that my time is valuable, and you want a piece of it. It's good practice for you, and delivers your pitch in a format I want. Win-win.</p>


    (X) Close

    Twitter Pitch Me!