CPUs has no serial number; maybe that you want DMI basic info without root privilege (This will only show you a persistent id of your motherboard manufacturer and model, but no serial number):
dmesg | grep -i dmi: | cut -d ":" -f 2-
Otherwise you could "tell" dmidecode to run from unprivileged user:
sudo chmod +s /usr/sbin/dmidecode
Then you could run for instance:
dmidecode -s system-serial-number
In most cases "system-serial-number" is like either "chassis-serial-number" or "baseboard-serial-number". Remember that not all distros have this program installed, for instance, Debian based systems have a package named after it.
Otherwise you can find a unique and persistent, thro' installs, system ID via your system's disk; to do that you may run the following:
mount | grep "on / type" | awk '{print $1}'
The former will give you device's path where your system is mounted (for my OS it returned /dev/sda7), and then you can find an ID for it with the following:
find /dev/disk/by-id/ -lname "*sda" ! -name "wwn*"
So the complete command to find a unique ID from your system's hard disk could be:
find /dev/disk/by-id/ -lname "*`mount | grep " / " | awk '{print $1}' | cut -b 6-8`" ! -name "wwn*" -printf "%f\n"
I hope this may fit your needs or someone else's in here. Command cut -b 6-8 may not be portable, because I'm assuming block devices names to be three chars long; moreover, /dev/disk/by-id/ path is only filled by UDEV managed systems and not all Linux distros use it, but I ensure you the former will work in Ubuntu.