The Raspberry Pi 2 will give BCM2709 hardware and ~1 GB of RAM like this:
pi@raspberrypi:~ $ cat /proc/cpuinfo | grep Hardware
Hardware : BCM2709
pi@raspberrypi:~ $ cat /proc/meminfo | grep MemTotal
MemTotal: 947756 kB
while the Pi 1 reports BCM2708 hardware and definitely less than 1 GB:
pi@raspberrypi:~ $ cat /proc/cpuinfo | grep Hardware
Hardware : BCM2708
pi@raspberrypi:~ $ cat /proc/meminfo | grep MemTotal
MemTotal: 445112 kB
To know it in even more detail, use
cat /proc/cpuinfo | grep Revision | awk '{print substr($0, length($0)-3, length($0))}'
where the result can be one of the following:
0002: Pi B Rev 1.0, 256 MB
0003: Pi B Rev 1.0, 256 MB
0004: Pi B Rev 2.0, 256 MB
0005: Pi B Rev 2.0, 256 MB
0006: Pi B Rev 2.0, 256 MB
0007: Pi A
0008: Pi A
0009: Pi A
000d: Pi B Rev 2.0, 512 MB
000e: Pi B Rev 2.0, 512 MB
000f: Pi B Rev 2.0, 512 MB
0010: Pi B+
0012: Pi A+
0013: Pi B+
0015: Pi A+
0092: Pi Zero Rev 1.2
0093: Pi Zero Rev 1.3
1040: Pi 2B Rev 1.0
1041: Pi 2B Rev 1.1
2082: Pi 3B Rev 1.2