I have an old router and I would like to keep few kibibytes and I need to know which auxiliary files can I delete from image. I already removed /etc/banner and now I want to remove /etc/services and /etc/protocols. They both have 5.6 kb and even after lzma compression still have quite a lot.
Is it safe to remove the /etc/protocols and the /etc/services?
What can be affected?
programs can do a getportbyname() sockets call in their code in order to understand what port they should use. For example, a POP3 email daemon would do a getportbyname (POP3) in order to retrieve the number 110 that POP3 runs on.
the uhttpd and dropbear uses port from config and they don't use the protocols mapping file but what about others?
As far I see the only program that uses them is iptables where I can use these alisases
yes I know that this is only about two kibibytes but even them will may be useful for me. I'll store a lot of data in /tmp folder and the more RAM will be available then better to me.
Anyway I even more interested why do we need this files at all.
BTW, squashfs uses lzma compression but is any chance to have the lzma compressor and decompressor as a regular command line tool? Or at least some liblzma so I can use it in my programm?
Also I wondered that OpenWrt contains bz2 decompressor but doesn't have bz2 compressor.
For me it's not clear who needs bz2 and why wasn't added bz2 compressor because I guess it will share almost the same code as decompressor and not a big overhead for space
Answering myself: the /etc/services file isn't really needed and can be (almost safely) removed.
It's used by getservbyname() but in fact the function is called only by inetd, nc, tcpudp, and telnet client when they using protocol names instead of ports.
Changing the file is also useless idea. For example in Termux which is a Linux emulator/wrapping layer for Android they do really need to change telnet port to 8023 for telnetd because 23 needs for a root permissions.
But they have to patch all software instead of changing the /etc/services. Why?
Because telnet client also reads it and if you change telnet port to 8023 then it won't be able to connect to others servers.
So you can add new entries into the /etc/services but you must not change any existing lines.
But the /etc/protocols may be not so safe to remove because it may be used by firewall