Worksheet 1 - Linux commands
Real Linux Commands for Raspberry Pi: Student Worksheet
Listing Files and Folders
ls -l
Challenge: List the files in your current directory with details like file permissions, size, and date of modification. Test: Can you find which file was modified most recently?
Finding Your Current Directory
pwd
Challenge: Use this command to print your working directory (the folder you're in). Test: Can you navigate to the /home directory and print its path using this command?
Changing Directories
cd
Challenge: Navigate to a directory (e.g., /home/pi/Documents) using this command. Test: Use cd .. to go back one directory. How can you go back two directories in one command?
Creating a New Folder
mkdir new_folder
Challenge: Create a new folder called projects in your home directory. Test: Can you create a folder named data inside projects?
Moving and Renaming Files
mv file.txt new_folder/
Challenge: Move a file called report.txt to the projects folder you created earlier. Test: Can you rename report.txt to summary.txt while moving it to projects?
Copying Files
cp file.txt backup.txt
Challenge: Copy a file called summary.txt to backup_summary.txt. Test: Can you copy the entire projects folder to another folder called backup_projects?
Deleting Files
rm file.txt
Challenge: Delete the backup_summary.txt file from your home directory. Test: How would you remove the entire backup_projects folder? (Hint: rm -r)
Viewing File Contents
cat file.txt
Challenge: Use this command to display the contents of summary.txt. Test: How can you display only the first 5 lines of a file? (Hint: Look up the head command)
==Finding Text Inside Files
grep "search_text" file.txt
Challenge: Search for the word temperature in the summary.txt file. Test: How would you find all occurrences of the word error in a log file called system.log?
Viewing System Information
df -h
Challenge: Display the available disk space on your Raspberry Pi using df -h. Test: How much space is available on the /boot partition?
Bonus Challenge:
Can you combine commands? For example, try combining ls with grep to find files with specific names. Run this:
ls | grep ".txt"