we can kow ubuntu versions with any one of following commands
we can kow Centos versions with any one of following commands
you need to execute below command how to know version with lsb based command
Description: CentOS Linux release 7.4.1708 (Core)
Release:7.4.1708