Skip to main content
1 of 2
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265

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
  • 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