Learn to run Python or python 3 on your Kali Linux operating system.
Python is preinstalled in your Linux operating system. Using it is very simple but first, make sure to update Kali Linux to the latest version.
To start a Python command line or terminal program, open the terminal in your kali Linux, then type in python, or python3 depending on your Python installation. Press Enter. On Linux, you can do this by running $ python3 Python 3.6.
Using Python in Kali Linux
- Open the Linux terminal: By clicking Ctrl + Alt + T on the dashboard
- Download the python script.
- Use the cd command to navigate to the location of the python script in the terminal.
- Type python SCRIPTNAME.py in the terminal to execute the script.
- If the script is python3, use python3 in the terminal command:python3 SCRIPTNAME.py
Or alternatively:
- Prepend #! /usr/bin/python with your script.
- Run the following command in your terminal to make the script executable: chmod +x SCRIPTNAME.py
- Now, simply type ./SCRIPTNAME.py to run the executable script.
So, to give all the details of the proper steps in a limited time, let’s get started!
How to use Python in Kali Linux – Multiple Ways
There are two methods for creating a python script.
- Interactive mode
- Scripting mode
Both are explained below.
1# Interactive Mode
One of the methods of creating a python script is the interactive mode. The steps of the interactive mode are given below.
Step 1 Open the Terminal of your Linux OS.

Step 2 Running python is simple in the terminal. But first make sure Python is installed, verify it by typing “python3” and hitting enter.

If Python is available, use any python commands and it should work similarly to any other code Editor. Also, if a command does not work, type the “Clear” command to reset everything in the terminal.
Step: 3 If you want to exit it, use the exit bracket shown below and type clear. It will open a new window.

Run python script in python
For the scripting mode details, scroll below.
Step:1 First, let’s make a directory for scripting mode where you can store the python file or the python script. For that, follow the python code and hit enter.

Step 2 Type cd and then the folder name you just created. Then create the python script.

Step: 3 An example script is shown below. ‘py’ is used for python. Then click enter.

Step:4 To exit it, you have to press down control (Ctrl key), and C. Then type ls. There you will have your script reading.

Step:5 Depending on the input application you are running on your Kali Linux, like G edit Leafpad or simple Nano, go ahead and type mousepad helloworld.py. Press enter.

Step:6 As you can see below, you will get your input code. Give the following code. Then press control S to save and then exit.

Step:7 Come back to the tunnel and type the given code. It will show your python script on the terminal.

Now go ahead and use whichever mode you want to apply.