Today I discovered that sudo ls shows hidden files (that is, those that have names starting with .) on OS X. This surprised me so much that I asked a question about this behaviour, which I still find somewhat strange and unexpected.Turns out, this behaviour goes back to 2BSD in 1979.Given that, now Id like to ask the following question. Why doesnt ls on Linux behave this way?Was there a period of time when ls on some other kinds of *nixes had this behaviour? Are there any documents, commit messages, emails explaining who and why decided that this feature should not be copied at all or that it should be dropped if it was copied initially?
sudo ls not showing hidden files on Linux
ls;history;bsd;coreutils;dot files
The POSIX standard says:Filenames beginning with a  ( '.' ) and any associated information shall not be written out unless explicitly referenced, the -A or -a option is supplied, or an implementation-defined condition causes them to be written.Being root is evidently not considered a condition which causes hidden files to be written by the GNU Coreutils implementation of ls that is commonly packaged in Linux distros.There are good reasons not to have the behavior of programs influenced by global variables, like which user ID is in effect. A script developed as non-root will change behavior when run as root.The hiding of files that begin with dot is not a security mechanism; it shouldn't be connected to security contexts. It conceals things that we normally don't want to see, like the .git directory among your .c source files or whatever. If you have read access to another user's directory, you can list their hidden files.  The dot hides items whose presence is expected and uninteresting, not whose presence is intended to be secret.Dotted directory entries other than .. and . have no special operating system status; just ls treats them specially.I just tried Solaris 10; its ls also has no such behavior. It is not a universal Unixism, which explains why the POSIX requirement is worded that way.