What is each port on the system used for?

Some time ago I wanted to know data on system ports, to know what each one was used for, its utility or function, and I remember that in Wikipedia or some other site I found something about this.

However, some time later I discovered that this information is already in our Linux system, we have it in the file: / etc / services

For example, I leave you a sample (and only a small sample!) Of what it contains:

ftp-data 20 / tcp
ftp 21 / tcp
fsp 21 / udp fspd
ssh 22 / tcp # SSH Remote Login Protocol
ssh 22 / udp
telnet 23 / tcp
smtp 25 / tcp mail
time 37 / tcp timserver
time 37 / udp timserver
rlp 39 / udp resource # resource location
nameserver 42 / tcp name # IEN 116
whois 43 / tcp nicname

As you can see, it shows us the service first, then the port it uses, then the protocol and finally a brief description of some services.

They can show the content of this file by opening it with any text editor, for example in a terminal they could put:

nano /etc/services

Or simply listing the file with:

cat /etc/services

If they want NOT to show all the content, because they only want to know (for example) which port is used for FTP, they can filter with the command grep :

cat /etc/services | grep ftp

And this will give us as a result only what is related to FTP:

 ftp-data 20 / tcp
ftp 21 / tcp
tftp 69 / udp
sftp 115 / tcp
ftps-data 989 / tcp # FTP over SSL (data)
ftps 990 / tcp
venus-se 2431 / udp # udp sftp side effect
codasrv-se 2433 / udp # udp sftp side effect
gsiftp 2811 / tcp
gsiftp 2811 / udp
frox 2121 / tcp # frox: caching ftp proxy
zope-ftp 8021 / tcp # zope management by ftp

Well that. That our system often has the information we need, and we are not even aware 😀

regards


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   proper said

    Always recommended No. use the default ports. If an unwanted person tries to connect by ssh, the first port they will use will be 22. The same will happen with telnet (I guess no one uses it anymore xD).

    regards

    1.    103 said

      However, it is possible to find out which port the service uses.

    2.    KZKG ^ Gaara said

      Of course, it is NOT recommended to use the default ports, at least not in all services. A classic example is SSH, which obviously, although there are correct policies in the firewall, it is always good to change the port. We already explain that here: https://blog.desdelinux.net/configurar-ssh-por-otro-puerto-y-no-por-el-22/

  2.   Neo61 said

    Go my friend, you are great, I see that you satisfied my request, Thank you very much !!!!!, but I need more, although something is better than nothing and I keep waiting for more scripts, I am hungry for knowledge

    1.    KZKG ^ Gaara said

      For some more scripts ... mmm well, check out what we have put here: https://blog.desdelinux.net/tag/bash/

  3.   Algave said

    Nice to have SElinux activated: $

    1.    Hugo said

      SELinux is already another matter, it is certainly recommended for corporate use, but it may be overkill for a home system (well, this depends on the level of "paranoia" of the user).

  4.   Neo61 said

    Gaara, friend, Yes, I have already reviewed that, all very good and I have saved it, only that I was left with the desire to continue learning after… .how to say… ..the first class to make a script and what did you put in https://blog.desdelinux.net/bash-como-hacer-un-script-ejecutable/
    exactly 261 days ago ... lol ... I thought I would continue with a consecutive or logical order to continue learning, just that.

    1.    KZKG ^ Gaara said

      After that I put one on if-then-else conditions, look for it there it is.

      1.    Hugo said

        Go ahead and write an article on the use of cases, it is very useful (I do not do it myself due to lack of time, sorry). By the way, you didn't tell me if the alternative I sent you to the distros detection script was of any use to you.

        1.    KZKG ^ Gaara said

          It's that I ended up just packing in .DEB and that's it, I saved that hahaha, and a friend (son_link) will pack it for Arch, and I'll see how I learn to pack in .RPM 🙂

          Yes yes, it served me well, I learned something new hehehehe.

  5.   nocturnal said

    Thanks for sharing the tip! It goes to my mardadores.

    Regards. 🙂

    1.    KZKG ^ Gaara said

      Thanks to you for the comment 😀

  6.   hektor said

    thanks for the info

  7.   lyon13 said

    It's 1000 xD ports

    But with nmap pointing to our static ip, those that are running do not find us and something can enter there?

    For example armitage uses nmap to track holes

    regards

    1.    KZKG ^ Gaara said

      Yes, with nmap you can know the ports that are open on a computer 🙂

  8.   dhunter said

    Nice trick, just a comment, no need to pipe cat with grep.

    grep ftp / etc / services