LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 09-14-2005, 08:04 AM   #1
bladehaze
LQ Newbie
 
Registered: Sep 2005
Posts: 12

Rep: Reputation: 0
Question about /etc/service


I am just not sure about the concept. So, I saw a bunch of service in /etc/service, which is provided on my linux box. My question is, if I comment out one of those service, is the port associated with the service still accessible, or it is just a file to associate the quest from on port with only that application?

for example, port 22 is for ssh. If I comment this line out in /etc/service, is port 22 still usable for other applications? Do I have to define that service in /etc/service to use port 22 for that application?

Last edited by bladehaze; 09-14-2005 at 08:06 AM.
 
Old 09-14-2005, 09:36 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Hi,

/etc/services is 'just' for number/name translation. So commenting out a service will _not_ close that port or deactivate that service.

If you, for example, do not want ssh access to your box, don't start sshd during startup. How you can do this depends on your distro, but most use links from /etc/rc.d/rc<number>.d/ to /etc/rc.d/init.d (path could be different).

Most applications that you can connect to have default portnumbers (80 for http, 21 for ftp, 22 for ssh etc). Running your own application and using one of these 'reserved' ports is possible but should not be done. Take one of the unassigned numbers (although IANA should officially approve this).

Hope this clears things up a bit.
 
Old 09-14-2005, 10:36 AM   #3
bladehaze
LQ Newbie
 
Registered: Sep 2005
Posts: 12

Original Poster
Rep: Reputation: 0
so, why do I need this file? If I delete it, what would not work?
 
Old 09-14-2005, 10:50 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Hi again,

You do need it for name <-> number translation(s). But if I'm being very basic: You don't need it (there are a few 'but's' here, so don't delete it).

It's a bit like your /etc/hosts file. You do not need it, but then you (and all your apps) would need to use ip numbers instead of names (127.0.0.1 instead of localhost).

Some programs need it to make the output look 'nicer'. Netstat, for example, uses /etc/services.

So, don't delete it (it's not big and it's not a security risk at all).

Hope this helps.
 
Old 09-14-2005, 02:33 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,326
Blog Entries: 4

Rep: Reputation: 2840Reputation: 2840Reputation: 2840Reputation: 2840Reputation: 2840Reputation: 2840Reputation: 2840Reputation: 2840Reputation: 2840Reputation: 2840Reputation: 2840
etc/services has three basic pieces of information:
  1. A mnemonic name of the service, such as "ftp".
  2. The port-number that will be used to connect to it.
  3. The network protocol, such as UDP or TCP, that is used.

Its basic purpose is to define those mnemonic names, as a reference, for your convenience in other things. You should not remove the file.
 
Old 09-15-2005, 03:52 PM   #6
bladehaze
LQ Newbie
 
Registered: Sep 2005
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks a lot.
 
Old 09-15-2005, 07:10 PM   #7
danimalz
Member
 
Registered: Jul 2005
Location: West Coast South, USA
Distribution: debian 3.1
Posts: 267

Rep: Reputation: 36
further

Not to highjack your thread

I have a very related question.

I was looking into /etc/services some time ago and found some references on the
net that provided 'enhanced' versions of this file (ie - it contained additional standard ports). So i copied one of these examples, it was over twice the size of the original one shipped with debian.

But then I came across a reference that said never to update that file, in fact it recommended making /etc/services immutable for security purposes. So i reverted back
to the original. In the security recommendation there was no real reasons given for the importance of this file.

can anyone please shed light?, just curious really.
 
Old 09-15-2005, 08:11 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
As mentioned above, it's basically a x-ref text file, but you should never change the port entries with nums < 1024 (Well Known ports), as these are specified by IANA and reserved for root use only (ie only root owned processes can bind to these).
As it says in the file hdr, Registered ports are 1024-49151, so these are reserved for known services if the number has been used.
So long as a number is not registered or you know the std service is not run on this box, you can use that port if you wish.
The upper limit is port num 65535.
You can check out the associated page http://www.iana.org/assignments/port-numbers for more info.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
question about uucp service and /etc/inetd.conf file frankie_DJ Linux - Newbie 2 09-03-2005 01:23 AM
init.d service start Question casentm Fedora 2 03-20-2005 08:23 PM
A question about service config 3887182 Slackware 4 01-24-2005 03:18 AM
sendmail service question deWin Linux - Newbie 12 12-31-2004 04:12 PM
small question, service hanxuerui Linux - Newbie 5 04-04-2003 04:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration