How to find out which Raspberry Pi you have from the Command Line
From the command line, you can easily see which Raspberry Pi hardware version you are logged into by running the following command:
cat /sys/firmware/devicetree/base/model
On the other hand, if you want to know which major version of the Raspbian OS (i.e. stretch, buster, ...) is installed, you can deduce that from the output of any of the following commands:
cat /etc/apt/sources.list
cat /etc/*release
If you'd like more info on the Linux Kernel, then use
uname -a