InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Linux/Unix Command Line tutorials

  • Awk
  • Curl
  • Edit a file without changing its timestamp on Linux
  • Find which process is listening on a port on Linux
  • Get file size in bytes on Linux
  • How to delete files starting with dash/hyphen
  • How to kill unresponsive ssh session using escape sequence
  • How to show environment variable for a process id (pid)
  • How to sort using a specific field on Linux
  • How to specify environment variable for a command on Linux
  • How to zip/unzip a directory with password
  • ImageMagick
  • Impact on LC_ALL on Linux sort
  • Linux - find listening ports
  • Linux - find top directories by used disk size (excluding size of subdirectories)
  • Linux - how to run a command as different user
  • Linux - list only directories
  • Linux - providing sudo access to a users - some best practices
  • Linux - sending mail from command using mailutils
  • Linux file timestamps
  • Linux how to modify a user using usermod
  • Linux ping a port using netcat
  • Linux replace comma with newline
  • Linux screen - quick start guide
  • Linux what package provides a file
  • Linux/Unix - How to go to previous directory
  • Linux/Unix - find inode number of a file
  • Linux/Unix - truncate a large log file without deleting it
  • Linux/Unix history with date and time
  • Memcache - how to dump all keys and values on command line
  • Mongo - cli quick start guide
  • Perl command line - replace multi line comments
  • Python/Perl/Unix one liners
  • Rsync
  • Ruby gem - handy reference
  • SSH
  • Some handy linux gnu date commands
  • Use watch to monitor a command at some frequency on Linux
  • bower - installation and quick start guide
  • csvkit - parse csv file and data on Linux command line
  • ffmpeg
  • grep without regex (fixed string)
  • redis cli quick start tutorial
  • wget handy commands

Linux find

  • Find recently modified files on Linux
  • Linux - find and delete files older than 30 days
  • Linux - find files containing specific text
  • Linux find - ignore case in name
  • find - exclude directory or file pattern
 
  • Home
  • > Tutorials
  • > Linux/Unix Command Line

Find which process is listening on a port on Linux

By admin | Last updated on Mar 20, 2016

Sometimes we need to find out what process is using or listening on a specific port on Linux machine. This can be fairly useful in a production for debugging things. Here are some ways to find process listening on a port on Linux environment. For the purpose of this article we will use Ubuntu Linux.

Use netstat to list all processeses and listening ports

Use netstat with -p (process) option along with -n [–numeric-ports] and -l (listening ports also).

$ sudo netstat -nlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1114/sshd       
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      5212/sendmail: MTA:
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      7597/mysqld
....

The column named “PID/Program Name” contains the process id and name of the program.

In case you want to print full path of the program for a process id you can use the following command:

$ ps -f -p 1114
UID        PID  PPID  C STIME TTY          TIME CMD
root      1114     1  0 Sep02 ?        00:00:01 /usr/sbin/sshd -D

Using lsof to find process from port

command line util lsof is used to list opened file. To list what process are using a specific port, run the following:

$ sudo lsof -i tcp:22

Using fuser to find process from port

fuser can be used to list process listening on a port.

$ sudo fuser -uv 80/tcp
                     USER        PID ACCESS COMMAND
80/tcp:              root      28836 F.... (root)apache2
                     www-data  28841 F.... (www-data)apache2
                     www-data  28842 F.... (www-data)apache2
                     www-data  28844 F.... (www-data)apache2
                     www-data  28845 F.... (www-data)apache2
                     www-data  28848 F.... (www-data)apache2
                     www-data  28878 F.... (www-data)apache2
                     www-data  28906 F.... (www-data)apache2
                     www-data  28907 F.... (www-data)apache2
                     www-data  28908 F.... (www-data)apache2
                     www-data  28909 F.... (www-data)apache2

Here -u is being used to display user also.

Suggested posts:

  1. NextJS Quick start tutorial on Mac
  2. Enable query log without restarting mysql on Linux
  3. Impact on LC_ALL on Linux sort
  4. CSS – enlarge image on hover
  5. Install Android 8 on Pixel 2
  6. Install google camera on Asus m1 max pro
  7. Linux rsync tutorial
  8. How to fix a broken sudoers file on AWS/EC2 Linux
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Linux/Unix Command Line, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress