Here's a bash script that serves as an Ubuntu tutorial with interactive commands:
Tech3Space24 Apr 2026
Here's a bash script that serves as an Ubuntu tutorial with interactive commands:
#!/bin/bash
# Ubuntu Tutorial Script
# This script demonstrates basic Ubuntu/Linux commands
echo "=================================="
echo " Ubuntu/Linux Tutorial Script"
echo "=================================="
echo
# Function to pause and wait for user input
pause() {
echo "Press Enter to continue..."
read
echo
}
# 1. System Information
echo "1. System Information Commands"
echo "============================="
echo "Current user: $(whoami)"
echo "System info: $(uname -a)"
echo "Operating system: $(lsb_release -d | cut -f2)"
echo "Current directory: $(pwd)"
pause
# 2. File and Directory Operations
echo "2. File and Directory Operations"
echo "==============================="
echo "Current directory contents:"
ls -la
echo
echo "Creating test directory..."
mkdir -p tutorial_test
cd tutorial_test
echo "Created directory: $(pwd)"
pause
# 3. File Operations
echo "3. File Operations"
echo "================="
echo "Creating sample files..."
touch file1.txt file2.txt
echo "Hello World" > file1.txt
echo "This is a test file" > file2.txt
echo "Contents of file1.txt:"
cat file1.txt
echo
echo "File permissions:"
ls -l
pause
# 4. Process Management
echo "4. Process Management"
echo "===================="
echo "Running processes:"
ps aux | head -5
echo
echo "Checking if 'nano' is installed:"
if command -v nano &> /dev/null; then
echo "nano is available"
else
echo "nano not found (install with: sudo apt install nano)"
fi
pause
# 5. Package Management
echo "5. Package Management"
echo "===================="
echo "Available updates:"
sudo apt update
echo
echo "Installing a package (example: tree):"
# Uncomment the next line to actually install
# sudo apt install -y tree
echo "Package tree installed (if you uncommented above)"
pause
# 6. User and Permission Management
echo "6. User and Permission Management"
echo "================================"
echo "Current user groups:"
groups
echo
echo "Creating a test user (uncomment to execute):"
# sudo useradd -m testuser
# sudo passwd testuser
echo "User creation commented out for safety"
pause
# 7. Network Commands
echo "7. Network Commands"
echo "=================="
echo "Network interfaces:"
ip addr show
echo
echo "Testing connectivity to google.com:"
# ping -c 3 google.com
echo "Ping test commented out to avoid network issues"
pause
# 8. Text Processing
echo "8. Text Processing"
echo "================="
echo "Sample text file:"
echo "apple
banana
cherry
date
elderberry" > fruits.txt
cat fruits.txt
echo
echo "Finding 'a' in fruits:"
grep "a" fruits.txt
echo
echo "Sorting fruits:"
sort fruits.txt
pause
# 9. System Monitoring
echo "9. System Monitoring"
echo "==================="
echo "Disk usage:"
df -h
echo
echo "Memory usage:"
free -h
echo
echo "Top processes:"
# top -b -n 1 | head -10
echo "Top command commented out for safety"
pause
# 10. Useful Tips
echo "10. Useful Tips"
echo "=============="
echo "1. Use 'man command' for detailed help"
echo "2. Use 'ls -la' to see hidden files"
echo "3. Use 'sudo' for administrative commands"
echo "4. Use 'history' to see command history"
echo "5. Use 'tab' for auto-completion"
echo "6. Use 'Ctrl+C' to cancel running commands"
echo "7. Use 'Ctrl+Z' to suspend commands"
echo "8. Use 'Ctrl+R' to search command history"
pause
# Cleanup
echo "Cleaning up..."
cd ..
rm -rf tutorial_test
echo "Tutorial completed successfully!"
echo
echo "=================================="
echo "Tutorial Complete!"
echo "=================================="
echo "Remember: Always use sudo carefully"
echo "and backup important data before major changes."
To use this script:
- Save it as
ubuntu_tutorial.sh - Make it executable:
chmod +x ubuntu_tutorial.sh - Run it:
./ubuntu_tutorial.sh
Features of this script:
- Interactive tutorial with pauses
- System information commands
- File and directory operations
- Process management
- Package management
- User and permission management
- Network commands
- Text processing
- System monitoring
- Useful tips and best practices
Important Notes:
- Some commands are commented out to prevent unintended actions
- The script includes safety checks
- Always test commands in a safe environment first
- This is for educational purposes only
You can uncomment specific sections to test actual commands like package installation or user creation.