TCP Connection Info

Hello Experts,

We have an application which is login on CentOS 6.8 64 bit (GUI Interface) & after login generate tcp port 50000 for make connection with user.
Behind that port there are many connection connected with different-different IP (, 207.12, 207.13) & user name (user1, user2, user3):

Example Output:-
[root@CC ~]# lsof -i :50000
TCPServer 3647 rajat  245u  IPv4 156532      0t0  TCP> (ESTABLISHED)
TCPServer 3647 rajat  261u  IPv4  23354      0t0  TCP *:50000 (LISTEN)
TCPServer 3647 rajat  387u  IPv4  24955      0t0  TCP> (ESTABLISHED)

From this cmd i only check which IP is connected behind port 50000, but i want to check user name also. Please suggest.
Rajat SehgalFounder Enhance TechnologyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joy DingenenICT system consultantCommented:

i don't think what you're asking is possible as far as i understand the question. If the program you're starting at port 50000 has a log you might find that info there. If you
ps -ef | grep pid#

Open in new window

you can get more info about the thread but the user that initiates the program will always own it.

Best of luck,
Rajat SehgalFounder Enhance TechnologyAuthor Commented:
I need detail of user name along with pid which is connected with port 50000
Joy DingenenICT system consultantCommented:
The second column of the output you posted is the pid. The third is the user that started the thread that is serving something on port 50000.
The user that connects to that port is inside an application so the application log should help you there.

If this is something you made yourself i would suggest you echo that info to a file on connection.
Defend Against the Q2 Top Security Threats

Were you aware that overall malware worldwide was down a surprising 42% from Q1'18? Every quarter, the WatchGuard Threat Lab releases an Internet Security Report that analyzes the top threat trends impacting companies worldwide. Learn more by viewing our on-demand webinar today!

Rajat SehgalFounder Enhance TechnologyAuthor Commented:
This is showing detail of connectivity only server (IP/Port) & node (IP/Port).
[root@CC ~]# lsof -i :50000
TCPServer 3647 rajat  245u  IPv4 156532      0t0  TCP> (ESTABLISHED)
TCPServer 3647 rajat  261u  IPv4  23354      0t0  TCP *:50000 (LISTEN)
TCPServer 3647 rajat  387u  IPv4  24955      0t0  TCP> (ESTABLISHED)

This PID is generate by port 50000, if i kill this PID (3647) it will kill port 50000 (application), we need only kill login/connected users not application. rajat is the user name of server and my application is running on that user, we need user id info as selected column.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
What you're asking is impossible from a Linux perspective, as the uid/gid of a process contains no correlation of user identity.

This is code you'd add at your application layer, so when you open your high port number connection, you somehow record which user is associated with each connection.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rajat SehgalFounder Enhance TechnologyAuthor Commented:
Thanks Sir
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.