Solutions
1. Print the Current Directory
pwd
Expected output:
/home/piNNNN
2. Create a Subdirectory
Create a lab subdirectory inside your home directory:
mkdir /home/piNNNN/lab
3. Copy the SSH Log File
Copy the authentication log to your lab directory:
sudo cp /var/log/auth.log /home/piNNNN/lab
4. Check File Size
ls -l /home/piNNNN/lab/auth.log
Example output:
-rw-r----- 1 root root 10380 Jul 18 10:09 /home/piNNNN/lab/auth.log
5. Read the File
cat /home/piNNNN/lab/auth.log
This will fail with:
cat: /home/piNNNN/lab/auth.log: Permission denied
❓ Why?
Because the file is still owned by root.
6. Change File Ownership
Change ownership to your user:
sudo chown piNNNN /home/piNNNN/lab/auth.log
7. Verify Ownership
ls -l /home/piNNNN/lab/auth.log
Expected output:
-rw-r----- 1 piNNNN root 10380 Jul 18 10:09 /home/piNNNN/lab/auth.log
8. Read the File Again
cat /home/piNNNN/lab/auth.log
Now you should see the content, e.g.:
2025-07-18T09:28:37.362910+02:00 pi01 sshd[51661]: pam_unix(sshd:session): session opened for user piNNNN(uid=1012) by (uid=0)
2025-07-18T09:28:41.173032+02:00 pi01 sudo: piNNNN : TTY=pts/0 ; PWD=/home/piNNNN ; USER=root ; COMMAND=/usr/bin/cp /var/log/auth.log .
9. Explain Why You Can Read It
By using the chown command, you changed the file owner from root to your own user. As you can see, the owner now has read (and write) permissions.
10. Explore Other Information in the File
The log also contains entries for:
- All SSH logins
- All
sudocommands executed
11. Copy the File to Your Laptop
Note: run the command from your own terminal (not from the raspberry pi).
Windows (Command Prompt):
scp piNNNN@piNNNN.kale:/home/piNNNN/lab/lab.txt %USERPROFILE%\Desktop\
Windows (PowerShell):
scp piNNNN@piNNNN.kale:/home/piNNNN/lab/lab.txt $HOME\Desktop\
macOS / Linux
scp piNNNN@piNNNN.kale:/home/piNNNN/lab/lab.txt ~/Desktop/
Replace:
NNNNwith your Pi numberYourNamewith your Windows username
You will need this file for your final submission.