Linux and Nano Editor: From Basics to
Python
Baskar Balasubramanyam
August 2025
1
Introduction
Tutorial Goals
• Learn basic Linux terminal commands
• Navigate the Linux file system
• Use the nano text editor
• Write and run your first Python3 program
• Practice with hands-on exercises
2
Getting Started with Linux
What is Linux?
Linux is an open-source operating system used on servers,
desktops, and mobile devices. The terminal provides powerful
text-based control over your system.
3
Linux Terminal
The terminal lets you interact with your computer using
commands. You can:
• Run programs
• Edit files
• Navigate directories
• Manage your system
4
Basic Linux Commands
Essential Commands
pwd Print working directory
ls List files in directory
cd Change directory
mkdir Make new directory
touch Create empty file
rm Remove file
cp Copy files/directories
mv Move/rename files
cat Display file contents
5
Practice Exercise 1
Exercise 1: Try these commands
1. Open the terminal
2. Run pwd and ls
3. Create a new directory: mkdir testdir
4. Change to the new directory: cd testdir
5. Create a file: touch myfile.txt
6. List files: ls
6
Navigating the File System
Navigation Commands
• cd .. – Move up one directory
• ls -l – Long listing format
• ls -a – Show hidden files
• cd / – Go to root directory
• cd ~ – Go to home directory
7
Practice Exercise 2
Exercise 2: Navigation Practice
1. Use cd and ls to explore your file system
2. Go back to home: cd ~
3. Try listing all files including hidden: ls -a
4. Practice moving between directories
8
Nano Text Editor
Getting Started with Nano
nano is a simple command-line text editor that’s perfect for
beginners.
To open a file: nano filename
If the file doesn’t exist, nano will create it when you save.
9
Nano Editor Commands
Ctrl+O Write Out (Save file)
Ctrl+X Exit nano
Ctrl+W Search for text
Ctrl+K Cut current line
Ctrl+U Paste (Uncut)
Ctrl+G Show help menu
10
Practice Exercise 3
Exercise 3: Edit a File with Nano
1. Open your file: nano myfile.txt
2. Type some text (try writing your name)
3. Save the file: Press Ctrl+O, then Enter
4. Exit nano: Press Ctrl+X
5. Verify the file exists: ls
6. View the file contents: cat myfile.txt
11
Writing Python Programs
Create Your First Python Script
Step 1: Open nano to create a new Python file
nano hello.py
Step 2: Type the following code:
12
Hello World Program
print ( " Hello , world ! " )
print ( " Welcome to Python programming ! " )
Step 3: Save and exit (Ctrl+O, Enter, Ctrl+X)
Step 4: Run your script: python3 hello.py
13
Practice Exercise 4
Exercise 4: Interactive Python Script
1. Use nano to create a file called greet.py
2. Write a program that:
• Asks the user for their name
• Prints a personalized greeting
3. Save and run the script
4. Test it with different names
14
Sample Solution
Here’s one way to solve Exercise 4:
name = input ( " Enter your name : " )
print ( " Hello , " + name + " ! " )
print ( " Nice to meet you ! " )
Try running this and entering your name when prompted.
15
Putting It All Together
More Advanced Python Example
Exercise 5: Create a simple calculator
1. Create calculator.py
2. Write a program that asks for two numbers
3. Perform basic arithmetic operations
4. Display the results
16
Calculator Solution
num1 = float ( input ( " Enter first number : " ) )
num2 = float ( input ( " Enter second number : " ) )
print ( " Addition : " , num1 + num2 )
print ( " Subtraction : " , num1 - num2 )
print ( " Multiplication : " , num1 * num2 )
if num2 != 0:
print ( " Division : " , num1 / num2 )
else :
print ( " Cannot divide by zero ! " )
17
Conclusion
Summary
Today you learned:
• Essential Linux commands for navigation and file management
• How to use the nano text editor effectively
• Creating and running Python programs
• Combining all these skills to write useful scripts
18
Further Learning Resources
• Linux Command Line: https:
//linuxize.com/post/how-to-use-nano-text-editor/
• Basic Commands: https://www.geeksforgeeks.org/
linux-unix/basic-linux-commands/
• Python Documentation:
https://www.python.org/about/gettingstarted/
• Practice: Try creating more complex Python programs!
19