find port number in linux, How do I find my port number? How do I find my IP port Linux? , What is port number in Linux?
5/5 - (2 votes)

Last Updated on January 15, 2023 by Vikash Ekka

What is IP address

An IP address (Internet Protocol address) is a unique numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. It serves two main functions: identifying the host or network interface, and providing the location of the host in the network.

An IP address is a set of numbers and dots (example: 192.168.1.1) that is assigned to a device connected to a network. There are two main types of IP addresses: IPv4 and IPv6. IPv4 addresses are 32-bit numbers usually written in the form of four 8-bit numbers separated by periods (example: 192.168.1.1). IPv6 addresses are 128-bit numbers written in the form of eight 16-bit numbers separated by colons (example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334).

IP addresses are used to identify and locate devices on a network, and to route traffic to and from those devices. Each device on a network must have a unique IP address, and the network’s router uses the IP address to forward incoming data packets to the correct device.

In addition to identifying and locating devices on a network, IP addresses also play a critical role in security. Firewalls and other security devices use IP addresses to identify and control access to a network.

What is port number and how do i check in Linux

A port number is a 16-bit unsigned integer, thus ranging from 0 to 65535, that is used to identify a specific process to which data is sent once it reaches the host machine. When a data packet is sent from a device to a network, it is sent to a specific port on the destination device.

On a Linux machine, you can check the open ports and the process that is using it by using the following commands:

  • netstat command: This command will show you a list of all the active network connections and the process ID (PID) associated with each connection. To see all open ports, you can use the following command:
netstat -tuln
  • lsof command: The “lsof” command can be used to view a list of all open files on your Linux machine, including network connections. To view the open ports and the associated process use the following command:
lsof -i
  • ss command: The ss command is similar to netstat. It can be used to display detailed information about network connections on your Linux machine, including the process ID and state. To view open ports and associated process use the following command:
ss -lnt

It is important to note that these commands might require root privileges, you may have to run them with the “sudo” command. The output of these commands will show you the protocol (TCP or UDP), the local and remote address and port, and the state of the connection. The state can be ‘LISTEN’ for listening for incoming connections, ‘ESTABLISHED’ for an active connection, and ‘CLOSED’ for closed connections.

There are several ways to find the port for a specific IP address on a Linux machine.

  1. Using the “netstat” command: You can use the “netstat” command to view all of the active network connections on your Linux machine, including the IP address and port number for each connection. To view only the connections for a specific IP address, use the following command:
netstat -an | grep <IP address>
  1. Using the “lsof” command: The “lsof” command can be used to view a list of all open files on your Linux machine, including network connections. To view the connections for a specific IP address, use the following command:
lsof -i <IP address>
  1. Using the “ss” command: The “ss” command can be used to view detailed information about network connections on your Linux machine, similar to the “netstat” command. To view the connections for a specific IP address, use the following command:
ss -ntu | grep <IP address>

It is important to note that these commands might require root privileges, you may have to run them with the “sudo” command.

It is also important to note that these commands display the information of all the connections, not just the one you are looking for, you may have to look through the output to find the port you are looking for.

Some common ports that are used in Linux

There are several common ports that are used in Linux systems:

  1. HTTP (port 80): This port is used for unencrypted web traffic. It is the default port for accessing web pages using the HTTP protocol.
  2. HTTPS (port 443): This port is used for encrypted web traffic using the HTTPS protocol. It is commonly used for secure online transactions such as online banking and online shopping.
  3. SSH (port 22): This port is used for secure remote access to a Linux machine using the SSH protocol.
  4. FTP (ports 20 and 21): This port is used for file transfer between a client and a server using the FTP protocol.
  5. Telnet (port 23): This port is used for remote access to a Linux machine using the Telnet protocol. It is not a secure protocol and it is recommended to use SSH instead.
  6. SMTP (port 25): This port is used for sending email using the Simple Mail Transfer Protocol.
  7. DNS (port 53): This port is used for the Domain Name System (DNS) service, which translates domain names into IP addresses.
  8. DHCP (port 67 and 68): This port is used for the Dynamic Host Configuration Protocol (DHCP), which assigns IP addresses to devices on a network.
  9. NFS (port 2049): This port is used for the Network File System (NFS), which allows users to access files and directories on remote Linux machines as if they were local.
  10. MySQL (port 3306): This port is used for the MySQL database service, which is widely used for storing data in Linux systems.

Here are some additional common ports that are used in Linux systems:

  1. RDP (port 3389): This port is used for the Remote Desktop Protocol (RDP), which allows users to remotely access and control a Windows or Linux machine.
  2. SMB (port 445): This port is used for the Server Message Block (SMB) protocol, which allows users to access files, printers, and other resources on a Windows or Linux machine.
  3. LDAP (port 389): This port is used for the Lightweight Directory Access Protocol (LDAP), which is used for storing and retrieving data from a directory service, such as an address book or a user database.
  4. Kerberos (port 88): This port is used for the Kerberos authentication protocol, which is used for secure authentication in a networked environment.
  5. NTP (port 123): This port is used for the Network Time Protocol (NTP), which is used for synchronizing the time on a Linux machine with a time server.
  6. IMAP (port 143): This port is used for the Internet Message Access Protocol (IMAP), which is used for accessing and managing email messages on a server.
  7. POP3 (port 110): This port is used for the Post Office Protocol version 3 (POP3), which is used for retrieving email messages from a server.
  8. SNMP (port 161): This port is used for the Simple Network Management Protocol (SNMP), which is used for monitoring and managing network devices.
  9. SIP (port 5060): This port is used for the Session Initiation Protocol (SIP), which is used for initiating, maintaining, modifying, and terminating real-time sessions that involve video, voice, messaging, and other communications applications and services between two or more endpoints on IP networks.
  10. ICMP (port 0): This port is used for the Internet Control Message Protocol (ICMP), which is used for testing network connectivity, troubleshoot and reporting errors in IP operations.

It is important to note that these are common ports and some service may use different ports. It’s always good to check the documentation of the service you are trying to access for the correct port number.

By Vikash Ekka

Hi All, My name is Vikash Ekka from India. I’m the founder and tech editor of https://www.vetechno.in. I have completed my Graduation in BCA. I love to write technical articles like Windows, Linux & MAC Tutorials, Tips, Tricks, How To fix, Tutorials About Ethical Hacking & Cyber Security Guide, and Software Review. Currently, I have been working as an IT professional since 2018.

Leave a Reply

Your email address will not be published. Required fields are marked *