Question: If I want to `tail` a 25 GB textfile, does the `tail` command read the whole file?

Since a file might be scattered on a disk I imagine it has to, but I do not understand such internals well.

Answer: 
You could have seen how `tail` works yourself. As you can for one of my files `read` is done three times and in total roughly 10K bytes are read:

```
strace 2>&1  tail ./huge-file >/dev/null  | grep -e "read" -e "lseek" -e "open" -e "close"
open("./huge-file", O_RDONLY)           = 3
lseek(3, 0, SEEK_CUR)                   = 0
lseek(3, 0, SEEK_END)                   = 80552644
lseek(3, 80551936, SEEK_SET)            = 80551936
read(3, ""..., 708) = 708
lseek(3, 80543744, SEEK_SET)            = 80543744
read(3, ""..., 8192) = 8192
read(3, ""..., 708) = 708
close(3)                                = 0

```
If `head` or `tail` *appears* to be reading the entire file, a likely reason is that *the file contains few or no newline characters*. I tripped over this a few months ago with a very large (gigabytes) JSON blob that had been serialized with no whitespace whatsoever, not even in strings.

If you have GNU head/tail you can use `-c N` to print the first/last N *bytes* instead of *lines*, but unfortunately this is not a POSIX feature.