cat /sys/devices/virtual/tty/tty0/active
`tty0` refers to the current virtual console (compare this answer). By reading `/sys/devices/virtual/tty/tty0/active` you can learn which console this is.
"Current" means what you see, not where `cat` is running. E.g. if you start this loop
while sleep 1; do
cat /sys/devices/virtual/tty/tty0/active
done
let in run, manually switch to another console, wait few seconds and switch back, then you will see the other console was reported when you looked at it.