How to open a text file from my desktop using python Windows Bash Terminal
In this Blog i will step through , how to open text file located in Desktop using Python through Windows Bash Terminal
Things you need before getting Start
- A text file save at your Desktop
- Python Library installed
- Window Bash Terminal enable or installed
Step 1
Run Window Bash Terminal as Administrator

Step 2 ( Locate Where is the Desktop File)
Check where is your Desktop Folder Located
- At Window Search Bar type ” This PC”
- Check the Desktop Location

Step 3 ( Navigate Folder in Window Bash)
In Step2 we have found out that the Desktop Directory path is as below
C:\Users\User \Desktop
After Knowing where our “Desktop” folder is located ,
we need to navigate the Directory in Window Bash towards the Desktop Directory
We will use cd .. to navigate backwards ( Note : There is 1 spacing after cd )
Now after , Completing Backward navigation above
We need to navigate forward towards the Desktop Directory using cd
Step 4 ( Activate Python)
Now we are in the Correct Directory type python3 at your Windows Bash Terminal
Step 5 ( Read Desktop Text File)
Now we are in the Python Terminal , its time to write some Python Scripts
Note :-> My Text File filename located at Desktop is named gg,txt
Write the Code Below
import os
file = open(“gg.txt” ,’r’)
file.read()
Well is Done !!
Check out How to Connect Mysql with Python Here