REVISED: the original version doesn't work on Ubuntu 10.04 which does not mention Ubuntu in uname -v. The /etc/lsb-release file is much better for this purpose as it has an explicit DISTRIB_ID line set to Ubuntu.
Based on l0b0's response, this sh script detects Ubuntu with an if statement. As others have pointed out, depending on what you're doing it may be more appropriate to detect particular programs or features, but as someone who has written Ubuntu-specific installers I appreciate that sometimes a simple smoke test that someone is not misapplying them is all you want.
#!/bin/sh
UBUNTU=`grep -i ubuntu /etc/lsb-release | wc -l`
if [ "$UBUNTU" != "0" ] ; then
echo "This is so totally Ubuntu!"
fi
uname -v
gives the kernel version details. It's likely that running an Ubuntu-branded kernel will mean that you are running on Ubuntu, but it's perfectly plausible to be running a non-Ubuntu-branded kernel on an otherwise Ubuntu system. – a CVn – 2017-02-17T13:37:48.290At that point you'd have to define sharp boundaries between distros, which is basically like trying to define life or intelligence. – l0b0 – 2017-02-17T14:19:19.993