Raspberry pi

Raspberry Pi first Programming and Basic commands, Python Programming

Raspberry Pi first Programming


Raspberry Pi first Programming and Basic commandsThis project is tutorial for beginners that explains how to write your first Raspberry Pi python program and what are  the  most  frequently  used  commands any beginner should know about.This tutorial will help you understand the python programming environment quickly and, in addition, the commands I will share with you are almost used in any Raspberry Pi programming. Although there are many commands for Raspberry Pi, for now you should only practice the commands I will share with you.

But you will need to set up your Raspberry Pi properly before you start programming in python so you can access your raspberry. This is my second tutorial about how to use the most simple Raspberry Pi commands and then how to write your first Raspberry Pi python script.

In my previous tutorial, I explained how you can setup your SSH network using Putty software so that you can wirelessly access your raspberry pi, and can write your  Raspberry Pi first Programming using your laptop keyboard and mouse.  In this tutorial, we will cover

  1. How to create directory
  2. How can files and directories be viewed
  3. How to create file within directory
  4. How to write python idle basic hello world program
  5. How to run a program
  6. How to modify program

Let’s start without any further delay!!!

The Amazon Purchase links are given below:

Raspberry pi 3 full package: https://amzn.to/2F4QqqE
Power bank: https://amzn.to/2QxmDvR

Arduino Uno: https://amzn.to/39aq6ZT
Mega 2560: https://amzn.to/2SszMsI
lm7805 Voltage Regulator: https://amzn.to/2ERYoTJ
330-ohm resistors pack: https://amzn.to/2Qj1Igg
female DC power jack socket: https://amzn.to/377Pg9M
470uf capacitors: https://amzn.to/2MrN3xR
5×7 cm Vero board: https://amzn.to/37b7KWO
female headers: https://amzn.to/350w6RE
connection wires: https://amzn.to/2MvOJXd
Super Starter kit for Beginners: https://amzn.to/398dliF
Jumper Wires: https://amzn.to/2SrnBwo
Bread Board: https://amzn.to/2MxV5FM
12v Adaptor: https://amzn.to/2MuOlZk
PCB plate: https://amzn.to/2MuwNMB
Variable Supply: https://amzn.to/39d0KdP
Digital Multimeter: https://amzn.to/34WbVoa
Vero Board / stripboard: https://amzn.to/39nL9Zg
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2PVwexF
Solder wire: https://amzn.to/2QlOvTS
Wire Stripper: https://amzn.to/353tYJa
wirecutter: https://amzn.to/2tV2lFj
PCB small portable drill machine: https://amzn.to/2MvQqnx


Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Once you write a script, first of all, there is no need for a keyboard and mouse to power up your raspberry pi, as we will use the keyboard and mouse of our laptop. If you don’t use the SSH network, you’ll need to attach your keyboard and mouse and you’ll need an LCD as well. But since I’ve already set up the SSH network, I’m going to use the keyboard and mouse of my laptop.

Raspberry Pi first Programming

As you can see, no input or output devices are actually attached to the GPIO pins, because we do not use any sensors in this tutorial. Only charging up the Raspberry Pi is the only thing we need to do.

Raspberry Pi first Programming

Let’s open the putty program now, enter your raspberry pi’s IP address, if you don’t know about the IP address, look at my previous tutorial. Then open press.

Raspberry Pi first Programming

You will be asked to enter your user name and password after clicking on the Open key. Only enter the name of the account as “pi” and the password is “raspberry.”

Raspberry Pi first Programming

If the login name and password have been entered correctly, you will be logged in.

Raspberry Pi first Programming

We’re signed in as you can see. 

The following are Raspberry Pi’s most commonly used commands.

Raspberry pi display files and folders:

Let’s begin with the ls command, which is one of the most commonly used commands, the ls command used to  display all the list of folders write ls and press enter.

Raspberry Pi first Programming

As you can see all the directories and files in the list.

Raspberry Pi clear screen command:

Another commonly used command is the clear command, which was used to clear the Write clear screen and press  enter

Raspberry Pi first Programming

Everything on the screen will vanish after you press the enter key on your keyboard.
Raspberry Pi first Programming

How to change the directory in Raspberry?

Now let’s use the ls command to show the folders and files again.

Raspberry Pi first Programming

Now let’s say this time we want the test directory to be opened. We just write cd check and press in. The command used to search the inside of the folder.

Raspberry Pi first Programming

As you can see, foo.txt and temp.py are two files. Simply write cd and press enter if you want to exit this file.


Raspberry Pi first Programming

How to make a Director in Raspberry Pi?

Another command that is most frequently used is mkdir. Which folder is used to create. Write mkdir with the name of the folder. First, let’s clear the screen using the clear command before we use this command. Now let’s say we  want the name youtube to create another folder. We simply write and click enter mkdir youtube. This command creates folder called youtube. Write the ls command to test whether or not the folder has been  created.

Raspberry Pi first Programming

As you can see it has been created. Now, just write cd youtube and press enter to open this folder. If use the ls  command now, you can see that it doesn’t have any files or folders.

Raspberry Pi first Programming

YouTube is our current working directory now.

How to Write and Run a Python Program on the Raspberry Pi terminal?

Let’s build our first.py extension python program directory. Just write first.py sudo nano and press enter as you can see in the above picture. You can choose any name, but make sure you add the.py extension.

Raspberry Pi first Programming

Open the editor, that’s where you can write your script. Let’s write very easy hello program for the world.

Raspberry Pi first Programming

We don’t need any semicolons at the start, unlike Arduino’s programming. Click control o to save this file on your keyboard and simply press enter as we’ve already produced a file, then press + x to exit the editor.

Now if we’re writing the ls, you can see the first.py file in the youtube directory.

Raspberry Pi first Programming

Just type python first.py and press enter to run this program.

Raspberry Pi first Programming

You can see the hello world message. now let’s say you want to edit this program.

How to edit the Python programming for Raspberry Pi?


nano first.py

and enter.


Raspberry Pi first Programming

It’s unwritable because you can see file first.py. To exit, press control x. 

Now write and enter sudo nano first.py.

Raspberry Pi first Programming

Press y.

Raspberry Pi first Programming

Now write something you’d like to print.

Raspberry Pi first Programming

Press ctrl+ o to save the file and click to exit the editor at the end. To run this script, write python first.py.

Raspberry Pi first Programming

How to delete/remove a file in Raspberry Pi?

Now let’s say we’ve got two files and we want to delete one file, we’ve got rm simple write sudo rm command, then enter the file name and press enter.

Raspberry Pi first Programming

The folder is deleted as you can see. So for now, that’s all. These were Raspberry Pi’s most simple commands. Such  commands should be followed.

Watch Video Tutorial

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button