1. for starters, most distributions have a release file in the /etc/ directory:
for Gentoo: /etc/gentoo-release
for Debian: /etc/debian_version
for RedHat: /etc/redhat_release (??)
2. if you are able to boot the machine, you may see a message in the boot process that shows you your distribution
3. if your dmesg still shows all boot messages, a reboot won't even be necessary:
may give a clue