Is there a way to check Used Ports on Linux without commands, I mean checking files or so on ?
Asked
Active
Viewed 415 times
0
-
1What is your goal here? Why aren't you able to use standard tools to do this? The below answer is correct, you can look in /proc, but even for that, you'll need to run *some* command, even if its cat or ls. – EEAA May 14 '17 at 16:29
-
I meant to get used ports without traditional commands like netstat and lsof and so on .. why ? Because I am preparing Script to do this job on different Linux distributions and MAC .. as you know some Linux distributions don't have netstat or lsof , same on MAC .. and Business doesn't want to Bundle netstat with the original application package, the below answer is correct for Linux. – user212051 May 15 '17 at 12:55
1 Answers
3
You can get this information in /proc/net/tcp , /proc/net/udp or /proc/net/raw.
More details and syntax here: http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html
Depending of what you want to do with port numbers, you may have to translate the port number in decimal, as it's stored in hexadecimal in these files.

Jérome Boham
- 66
- 3
-
Thanks for your answer .. This is very true on Linux .. Do you know how to do this on MAC ? – user212051 May 15 '17 at 12:56
-
-
dead link; here is an archive [mirror](https://web.archive.org/web/20150213042359/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html) – Scrooge McDuck Nov 22 '21 at 21:03