Skip to main content
2 of 2
added 35 characters in body
Stéphane Chazelas
  • 584.9k
  • 96
  • 1.1k
  • 1.7k

How can I determine the size limit of /etc/hosts?

It is a regular file, so the limit would correspond to the underlying filesystem's limits (which would itself be capped by the number of disks behind it), minus the space used by any other files in the same (probably root (/)) filesystem:

  • ext2/3: 2 TiB
  • ext4: 16 TiB (with the default 4KiB block size)
  • xfs: 500 TiB

How can I set the size limit of /etc/hosts?

Since it's a manually-edited file, only manually:

sed -i '100,$d' /etc/hosts

(to remove lines 100 and beyond).

Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265