2015-07-17

ehowton: (Default)

SUSE Linux Enterprise Server (SLES) and OpenSUSE have recently been including, free-of-charge, the entire IANA registered port list in /etc/services! Long gone are the days of old when we either had to commit ports to memory, or look up the IANA registered ports, and manually add them to the /etc/services file. Because really, who wants to do all that time-consuming labor? In short, me! Why?

Because its more work to comment out the 999,999 services I don't need, than to add the couple hundred I do need. Especially when the couple hundred conflict with the entire IANA registered port list pre-populated into the /etc/services file. Now what I could see as being awesome is including the entire IANA registered port list already commented out because that would allow a quick-and-easy lookup, and a quick-and-easy port entry with a single keystroke. But that's not what is happening here.

So I have a list of 57 non-production hosts (not even going to count the production numbers yet), with 57 discrete /etc/services files, all requiring 397 blocks of conflicting ports disabled. Some suggested awk, some suggested sed, but each file being unique made attempting this arduous.

Until one enterprising young man introduced us to vi substitution using absolute line numbers.

:set number

:6015,6030s/^/#

This essentially replaces (s) the first of the line (^) with a comment (#) for all ports listed between lines numbers 6015 and 6030.

example )
◾ Tags:

September 2025

S M T W T F S
 1 2 3 4 56
78910111213
14151617181920
21222324252627
282930    

Most Popular Tags

Expand Cut Tags

No cut tags