Start with uname, that tells you the name of the OS, the specific version, and the name of the hardware platform (i386 versus ARM for example). It is standardized and available on all Unixes I know of.
On Linux, uname only gives you the version number of the kernel. To find out whether it is RedHat / Debian / Gentoo / ... there is a handful files that are always stored in well known locations you can check, for example /etc/redhat-version, /etc/debian_version, and so on (and honestly, I don't remember whether that's spelled redhat-version, redhat.version or redhat_version).
I don't know of a standardized way (like POSIX or SUS) to identify Linux distributions, other than checking for the presence of these files.