BCS1110 1.0-RELEASE (GENERIC) bcs1110.ashish.nl/labs/lab-02-solution/ [ Light ]
guest@bcs1110:~$ cat lab-02-solution.md
# Lab 02 — Hi Tux (Solution)

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 sudo commands 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:

  • NNNN with your Pi number
  • YourName with your Windows username

You will need this file for your final submission.