Worksheet 2 - Nano commands: Difference between revisions

From Sensors in Schools
Jump to navigation Jump to search
(Created page with "Here is a 10-command challenge exercise using nano on a Raspberry Pi. Each challenge introduces the basics of the nano editor and teaches students common tasks, helping them become comfortable with the command-line text editor. 1. Open a File in nano Instruction: Open an existing file using nano. Command: nano filename.txt Challenge: Open a file called welcome.txt and add the text "Welcome to the Raspberry Pi" at the beginning. 2. Save and Exit nano Instruction: Learn h...")
 
No edit summary
Line 1: Line 1:
Here is a 10-command challenge exercise using nano on a Raspberry Pi. Each challenge introduces the basics of the nano editor and teaches students common tasks, helping them become comfortable with the command-line text editor.
=10-command challenge exercise using nano on a Raspberry Pi=


1. Open a File in nano
Each challenge introduces the basics of the nano editor and teaches students common tasks, helping them become comfortable with the command-line text editor.
 
==1. Open a File in nano==
Instruction: Open an existing file using nano.
Instruction: Open an existing file using nano.
<syntaxhighlight lang="bash">
Command: nano filename.txt
Command: nano filename.txt
</syntaxhighlight>
Challenge: Open a file called welcome.txt and add the text "Welcome to the Raspberry Pi" at the beginning.
Challenge: Open a file called welcome.txt and add the text "Welcome to the Raspberry Pi" at the beginning.
2. Save and Exit nano
 
==2. Save and Exit nano==
Instruction: Learn how to save a file and exit.
Instruction: Learn how to save a file and exit.
<syntaxhighlight lang="bash">
Command: Press CTRL + O (to save) and CTRL + X (to exit).
Command: Press CTRL + O (to save) and CTRL + X (to exit).
</syntaxhighlight>
Challenge: After modifying welcome.txt, save the changes and exit nano.
Challenge: After modifying welcome.txt, save the changes and exit nano.
3. Search for Text
 
==3. Search for Text==
Instruction: Use nano's search feature to find specific words or phrases.
Instruction: Use nano's search feature to find specific words or phrases.
<syntaxhighlight lang="bash">
Command: Press CTRL + W and type the word you want to find.
Command: Press CTRL + W and type the word you want to find.
</syntaxhighlight>
Challenge: Search for the word "Raspberry" in welcome.txt and confirm its position.
Challenge: Search for the word "Raspberry" in welcome.txt and confirm its position.
4. Cut and Paste Text
 
==4. Cut and Paste Text==
Instruction: Use nano to cut and paste text.
Instruction: Use nano to cut and paste text.
<syntaxhighlight lang="bash">
Command: Move the cursor to the start of the line and press CTRL + K (cut) and CTRL + U (paste).
Command: Move the cursor to the start of the line and press CTRL + K (cut) and CTRL + U (paste).
</syntaxhighlight>
Challenge: Cut the line that contains "Welcome to the Raspberry Pi" and paste it at the end of the file.
Challenge: Cut the line that contains "Welcome to the Raspberry Pi" and paste it at the end of the file.
5. Copy and Paste Text
 
 
==5. Copy and Paste Text==
Instruction: Use the copy and paste commands in nano.
Instruction: Use the copy and paste commands in nano.
<syntaxhighlight lang="bash">
Command: Press CTRL + Shift + 6 to start selecting, then CTRL + K to copy and CTRL + U to paste.
Command: Press CTRL + Shift + 6 to start selecting, then CTRL + K to copy and CTRL + U to paste.
</syntaxhighlight>
Challenge: Copy the first two lines of the file and paste them at the end.
Challenge: Copy the first two lines of the file and paste them at the end.
6. Undo and Redo Changes
 
 
==6. Undo and Redo Changes==
Instruction: Undo and redo changes in nano.
Instruction: Undo and redo changes in nano.
<syntaxhighlight lang="bash">
Command: Press ALT + U to undo and ALT + E to redo.
Command: Press ALT + U to undo and ALT + E to redo.
</syntaxhighlight>
Challenge: Undo the last action you performed, and then redo it.
Challenge: Undo the last action you performed, and then redo it.
7. Jump to a Specific Line
 
 
==7. Jump to a Specific Line==
Instruction: Jump to a specific line number in the file.
Instruction: Jump to a specific line number in the file.
<syntaxhighlight lang="bash">
Command: Press CTRL + _ (underscore), then type the line number.
Command: Press CTRL + _ (underscore), then type the line number.
</syntaxhighlight>
Challenge: Jump to line 5 in welcome.txt.
Challenge: Jump to line 5 in welcome.txt.
8. Insert the Current Date and Time
 
 
==8. Insert the Current Date and Time==
Instruction: Insert the current date and time in nano.
Instruction: Insert the current date and time in nano.
<syntaxhighlight lang="bash">
Command: Press CTRL + T (in some configurations) or manually type the date.
Command: Press CTRL + T (in some configurations) or manually type the date.
</syntaxhighlight>
Challenge: Insert today's date and time at the end of the file.
Challenge: Insert today's date and time at the end of the file.
9. Open nano in Read-Only Mode
 
 
==9. Open nano in Read-Only Mode==
Instruction: Learn how to open a file in read-only mode.
Instruction: Learn how to open a file in read-only mode.
<syntaxhighlight lang="bash">
Command: nano -v filename.txt (use -v for read-only).
Command: nano -v filename.txt (use -v for read-only).
</syntaxhighlight>
Challenge: Open the welcome.txt file in read-only mode and attempt to modify it. Note what happens.
Challenge: Open the welcome.txt file in read-only mode and attempt to modify it. Note what happens.
10. Enable Syntax Highlighting
 
==10. Enable Syntax Highlighting==
Instruction: Enable syntax highlighting in nano (for Python or other languages).
Instruction: Enable syntax highlighting in nano (for Python or other languages).
Command: Modify the `~
Command: Modify the `~

Revision as of 18:26, 18 October 2024

10-command challenge exercise using nano on a Raspberry Pi

Each challenge introduces the basics of the nano editor and teaches students common tasks, helping them become comfortable with the command-line text editor.

1. Open a File in nano

Instruction: Open an existing file using nano.

Command: nano filename.txt

Challenge: Open a file called welcome.txt and add the text "Welcome to the Raspberry Pi" at the beginning.

2. Save and Exit nano

Instruction: Learn how to save a file and exit.

Command: Press CTRL + O (to save) and CTRL + X (to exit).

Challenge: After modifying welcome.txt, save the changes and exit nano.

3. Search for Text

Instruction: Use nano's search feature to find specific words or phrases.

Command: Press CTRL + W and type the word you want to find.

Challenge: Search for the word "Raspberry" in welcome.txt and confirm its position.

4. Cut and Paste Text

Instruction: Use nano to cut and paste text.

Command: Move the cursor to the start of the line and press CTRL + K (cut) and CTRL + U (paste).

Challenge: Cut the line that contains "Welcome to the Raspberry Pi" and paste it at the end of the file.


5. Copy and Paste Text

Instruction: Use the copy and paste commands in nano.

Command: Press CTRL + Shift + 6 to start selecting, then CTRL + K to copy and CTRL + U to paste.

Challenge: Copy the first two lines of the file and paste them at the end.


6. Undo and Redo Changes

Instruction: Undo and redo changes in nano.

Command: Press ALT + U to undo and ALT + E to redo.

Challenge: Undo the last action you performed, and then redo it.


7. Jump to a Specific Line

Instruction: Jump to a specific line number in the file.

Command: Press CTRL + _ (underscore), then type the line number.

Challenge: Jump to line 5 in welcome.txt.


8. Insert the Current Date and Time

Instruction: Insert the current date and time in nano.

Command: Press CTRL + T (in some configurations) or manually type the date.

Challenge: Insert today's date and time at the end of the file.


9. Open nano in Read-Only Mode

Instruction: Learn how to open a file in read-only mode.

Command: nano -v filename.txt (use -v for read-only).

Challenge: Open the welcome.txt file in read-only mode and attempt to modify it. Note what happens.

10. Enable Syntax Highlighting

Instruction: Enable syntax highlighting in nano (for Python or other languages).


Command: Modify the `~