Ports are virtual places within an operating system where network connections start and end. They help computers sort the network traffic they receive. This means they are entities in a computer networking which acts as a communication endpoint for identifying a given process or application on the a given operating system.
How to close open ports in linux
- There are several ways to close open ports in linux.
fuser -k 3001/tcp
-k -> for kill
sudo kill $(sudo lsof -t -i:5000)
- In place of 5000 you can specify your port number
-t : This flag specifies that lsof should produce terse output with process identifiers only and no header - e.g., so that the output may be piped to kill(1). This option selects the -w option.
-i : This flag selects the listing of files any of whose Internet address matches the address specified in i. If no address is specified, this option selects the listing of all Internet and x.25 (HP-UX) network files.
How to list open ports in linux nodejs
How to install nodejs
How to setup nginx server blocks
How to install nginx
How to create ssh key
To summarize, closing open ports is one of the most fundamental tasks of a Linux system administrator for security reasons. Close all unwanted ports and configure firewalls such as UFW and FirewallD to open or block ports based on your needs. For more information.
Happy coding 🎉!