As the other answers say, $USER
is usually set to the name of the current user account.
But at least on my system (Ubuntu 14.04) the $USER
environment variable is not set for cron jobs. Instead, you can use $LOGNAME
(POSIX), which is part of the environment for cron jobs.
According to the environ(7)
man page (type man 7 environ
or man environ.7
to read it), $USER
is used by BSD-derived programs and $LOGNAME
is used by System-V-derived programs. They should have the same value if they're both set. The existence of both is an historical accident. (There could be cases where $USER
is set and $LOGNAME
isn't, but I don't know of any.)
The environ
man page also documents a number of other common environment variables. (It doesn't document all environment variables because it would be impossible to do so.)