Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am in need of the port numbers and the services available in Linux. How to disable a particular port if not needed. How to restart the same port when needed?
I am in need of the port numbers and the services available in Linux. How to disable a particular port if not needed. How to restart the same port when needed?
There isn't a list of ports for Linux. There is an IANA list of DEFAULT ports for services you can find in many places on the Internet, but those are just defaults/recommendations. You can configure most services to run on any port you'd like.
You don't disable a port...you disable the SERVICE that is LISTENING on that port.
You don't restart a port...you restart the SERVICE that LISTENS on that port.
For example, you can configure SSH to listen on port 8422 if you'd like..providing nothing ELSE is using that port. To 'disable that port', you would shut down SSH. To 'restart the port', you would START SSH. You can type in "cat /etc/services" and get a general list, but there is NO GUARANTEE that the services mentioned in that file are either running at ALL, or configured to listen on the ports mentioned in that file.
You can find port number in /etc/services, although they may not be right if you have altered them (common practice with ssh, for example, and some services will re-use ports nominally allocated to something else).
You can't really disable a port, but you can block all traffic to it using iptables. To stop the block, you have to undo what you did to block it (remove the rule).
If you are using iptables, you might be better advised to go about it in a different way, depending on the numbers. The alternative approach is to drop everything, with the exception of the things that you know that you want to allow.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.