The only illegal characters when naming files, directories, groups, etc. are as follows: / : ? " | and the less than or greater than symbols. The only limitation I'm aware of in the use of underscores is in DNS naming conventions, as the underscore is an illegal character for anything other than SRV records.
This was first published in March 2003