why does tar . see hidden files but ls . does not?

Quick answer: use ls -a to see the "hidden" files.

Long story: there's no such thing as a "hidden" file in UNIX/Linux, in the sense that the Linux kernel does not mark "hidden" files in any special way (as opposed, e.g., to what Windows does).

There is however a convention that file names starting with a dot character . are not displayed by ls unless the user explicitly asks for it (hence, the -a option). Since this was the convention adopted by the ls program (one of the first commands that existed in UNIX), it was followed by other file-display utilities, like Nautilus and the graphical file selection dialog.

On the other hand, since it's only a convention on displaying files, it does not affect other file-manipulating commands like tar.


ls (Short list) doesn't show hidden files.
ll (Long list, typically a shell alias to ls -alF) does.