How to check Python version on Linux

In this article, we will see different methods to check Python version on Linux.

1. By listing /usr/bin/python directory
2. using python x command

Method1: Check Python version on Linux

Following command is used to find the python version on Linux server.

ls /usr/bin/python*

Below output states Python 2.7 and Python 3.7 version is installed on Linux server.

root@kali:~# ls /usr/bin/python* /usr/bin/python /usr/bin/python3.7m /usr/bin/python2 /usr/bin/python3.7m-config /usr/bin/python2.7 /usr/bin/python3-config /usr/bin/python2.7-config /usr/bin/python3-futurize /usr/bin/python2-config /usr/bin/python3-jsonschema /usr/bin/python2-futurize /usr/bin/python3m /usr/bin/python2-pasteurize /usr/bin/python3m-config /usr/bin/python2-qr /usr/bin/python3-pasteurize /usr/bin/python2-wsdump /usr/bin/python3-wsdump /usr/bin/python3 /usr/bin/python-config /usr/bin/python3.7 /usr/bin/python-faraday /usr/bin/python3.7-config

Method1: Check using python x command

If we have single version just run the below command. Otherwise run the /usr/bin/pythonx -V. Where x is Python major version series number.

/usr/bin/python -V /usr/bin/python3 -V