Skip to content

Practice: Archives and Everyday Workflow

Module
Archives and Everyday Workflow
Difficulty
Easy
Updated
Tested on
Ubuntu 24.04.5 LTS (two lab containers), GNU Bash 5.2.21
On this page

A maintenance log contains two warnings among routine messages. Prepare a handoff that preserves the original log and a separate warning summary. Before sending it, prove that the archive restores correctly. Then verify the received archive on the lab server.

Finish Putting the workflow together and its two-machine reset. Use ~/lab from the practice directory setup, and the prepared lab server.

Reserve local ~/lab/b15-practice and remote ~/b15-practice.tar.gz. Both must be absent. The private lab hostname labserver belongs to this prepared environment. Your addresses, host-key fingerprint, transfer speed, and listing dates will differ. The recorded SSH banner names the container’s WSL2 kernel; yours names your own system and kernel. Your archive digest will also differ because it includes your source metadata; compare your local and remote values with each other.

Documentation and the preceding lessons are available during practice. Try to meet the goals before opening the solution.

The handoff practice uses a separate server run from the workflow lesson. Check its console fingerprint and handle any earlier labserver entry using the SSH lesson’s reset guidance before uploading the recovery-tested archive.

Inside the local workspace, use your editor to create bundle/inbox/checks.log with a final newline:

Synthetic maintenance log to write in your editor
INFO opening
WARN fan slow
WARN cable loose
INFO closing

Keep the original log unchanged. Save a derived file at bundle/results/warnings.txt. Use bundle.tar.gz for the local archive, restored for an isolated restore test, and the reserved remote archive name above. The recording writes the editor’s text with printf.

  1. Organize: The local bundle has separate inbox and results directories. The original log still has all four lines.
  2. Locate and save: Find the log by name and identify the warning line numbers. The saved result contains exactly the two WARN lines, without grep’s line-number prefixes.
  3. Package and inspect: One gzip-compressed tar archive contains both the original log and the saved result. Inspect names before extracting.
  4. Test recovery: Extract into an empty restored directory. A recursive comparison of bundle and restored/bundle finds no differences and returns status 0.
  5. Transfer and verify: Read the host fingerprint on the trusted server console, compare it before accepting the connection, and upload the archive. The remote digest matches the complete local digest, and remote tar lists the intended members.
  6. Reset: Remove the uploaded archive remotely before leaving the remote shell. Remove the local restore, project, and archive. Remove only labserver’s saved host keys and confirm none remain. The exercise paths are absent.

For evidence, keep the saved result read, tar member list, diff status, and the local and remote digest rows. Transfer completion alone does not satisfy goal 5.

Hint

Use find for the pathname and grep for the contents. Tar’s -C chooses where stored paths are extracted. Compare bundle with restored/bundle, because the archive retains the bundle/ prefix. Lpwd and pwd distinguish the local and remote SFTP directories.

At the local shell:

Terminal window
mkdir ~/lab/b15-practice
cd ~/lab/b15-practice
mkdir -p bundle/inbox bundle/results

Create the editor file shown above, then locate and inspect it:

Terminal window
find bundle -type f -name '*.log'
grep -n 'WARN' bundle/inbox/checks.log
Organize: practice solution
learner@rootvolt:~/lab$ mkdir ~/lab/b15-practicelearner@rootvolt:~/lab$ cd ~/lab/b15-practicelearner@rootvolt:~/lab/b15-practice$ mkdir -p bundle/inbox bundle/resultslearner@rootvolt:~/lab/b15-practice$ printf '%s\n' 'INFO opening' 'WARN fan slow' 'WARN cable loose' 'INFO closing' > bundle/inbox/checks.loglearner@rootvolt:~/lab/b15-practice$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, GNU Bash 5.2.21. LOCAL solution: create the workspace and preserve the full synthetic maintenance input.
Steps (8)
  1. Type mkdir ~/lab/b15-practice
  2. Press Enter — Reserve the local workspace
  3. Type cd ~/lab/b15-practice
  4. Press Enter — Enter the local workspace
  5. Type mkdir -p bundle/inbox bundle/results
  6. Press Enter — Separate the source notes from derived results
  7. Type printf '%s\n' 'INFO opening' 'WARN fan slow' 'WARN cable loose' 'INFO closing' > bundle/inbox/checks.log
  8. Press Enter — Write the synthetic input log
Locate: practice solution
learner@rootvolt:~/lab/b15-practice$ find bundle -type f -name '*.log'bundle/inbox/checks.loglearner@rootvolt:~/lab/b15-practice$ grep -n 'WARN' bundle/inbox/checks.log2:WARN fan slow
3:WARN cable looselearner@rootvolt:~/lab/b15-practice$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, GNU Bash 5.2.21. Find the source log and identify the warnings on lines 2 and 3.
Steps (6)
  1. Type find bundle -type f -name '*.log'
  2. Press Enter — Locate the log by name under the project
  3. Output: bundle/inbox/checks.log
  4. Type grep -n 'WARN' bundle/inbox/checks.log
  5. Press Enter — Locate the matching line with its line number
  6. Output: 2:WARN fan slow 3:WARN cable loose
Terminal window
grep 'WARN' bundle/inbox/checks.log > bundle/results/warnings.txt
cat bundle/results/warnings.txt
Save: practice solution
learner@rootvolt:~/lab/b15-practice$ grep 'WARN' bundle/inbox/checks.log > bundle/results/warnings.txtlearner@rootvolt:~/lab/b15-practice$ cat bundle/results/warnings.txtWARN fan slow
WARN cable looselearner@rootvolt:~/lab/b15-practice$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, GNU Bash 5.2.21. Save and read only the two warning lines, leaving the source log intact.
Steps (5)
  1. Type grep 'WARN' bundle/inbox/checks.log > bundle/results/warnings.txt
  2. Press Enter — Save matching text without line-number decoration
  3. Type cat bundle/results/warnings.txt
  4. Press Enter — Read the saved result before packaging
  5. Output: WARN fan slow WARN cable loose

The saved text has no line-number decoration. Keeping the input alongside the derived result lets the recipient inspect context.

Terminal window
tar -czf bundle.tar.gz bundle
tar -tf bundle.tar.gz
sha256sum bundle.tar.gz
mkdir restored
tar -xf bundle.tar.gz -C restored
diff -r bundle restored/bundle
echo $?

Predict: would extracting into bundle itself provide an independent copy for the comparison?

Run it, then compare with your guess
Package: practice solution
learner@rootvolt:~/lab/b15-practice$ tar -czf bundle.tar.gz bundlelearner@rootvolt:~/lab/b15-practice$ tar -tf bundle.tar.gzbundle/
bundle/results/
bundle/results/warnings.txt
bundle/inbox/
bundle/inbox/checks.loglearner@rootvolt:~/lab/b15-practice$ sha256sum bundle.tar.gz2c9edc96e62135f64560f13abc9df58323e9debf535e2c7cc3ffa5db586f403d  bundle.tar.gzlearner@rootvolt:~/lab/b15-practice$ mkdir restoredlearner@rootvolt:~/lab/b15-practice$ tar -xf bundle.tar.gz -C restoredlearner@rootvolt:~/lab/b15-practice$ diff -r bundle restored/bundlelearner@rootvolt:~/lab/b15-practice$ echo $?0learner@rootvolt:~/lab/b15-practice$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, GNU Bash 5.2.21. Inspect the archive, record its digest, restore it into a separate directory, and confirm a zero-status recursive comparison.
Steps (17)
  1. Type tar -czf bundle.tar.gz bundle
  2. Press Enter — Package the source and saved result together
  3. Type tar -tf bundle.tar.gz
  4. Press Enter — Inspect the archive members before transferring
  5. Output: bundle/ bundle/results/ bundle/results/warnings.txt bundle/inbox/ bundle/inbox/checks.log
  6. Type sha256sum bundle.tar.gz
  7. Press Enter — Record the local digest for remote comparison
  8. Output: 2c9edc96e62135f64560f13abc9df58323e9debf535e2c7cc3ffa5db586f403d bundle.tar.gz
  9. Type mkdir restored
  10. Press Enter — Create a clean destination to test the practice archive
  11. Type tar -xf bundle.tar.gz -C restored
  12. Press Enter — Restore a copy while preserving the original bundle
  13. Type diff -r bundle restored/bundle
  14. Press Enter — Compare the original and restored directory trees
  15. Type echo $?
  16. Press Enter — Check the successful recursive comparison status
  17. Output: 0

No. The clean restored directory keeps the extracted copy separate from the source. Extracting over existing work risks overwrites and weakens the recovery check.

The expected regular-file members are bundle/inbox/checks.log and bundle/results/warnings.txt. Diff prints nothing for matching contents, then echo reports 0. This comparison checks directory contents, not every metadata field.

On the trusted server console, read the fingerprint and confirm that the upload name is unused:

Terminal window
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
test ! -e ~/b15-practice.tar.gz && printf 'Remote destination absent\n'
Server console: read the transfer host fingerprint
learner@labserver:~$ ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub256 SHA256:rGTXTBDgnalQkXzlRp1++4aa6sPJMtx66W5+dDX4lOY root@labserver (ED25519)learner@labserver:~$ test ! -e ~/b15-practice.tar.gz && printf 'Remote destination absent\n'Remote destination absentlearner@labserver:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS (lab server console), GNU Bash 5.2.21. SERVER console: independently obtain this practice server's identity and check the reserved upload pathname.
Steps (6)
  1. Type ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
  2. Press Enter — Obtain the full server fingerprint independently
  3. Output: 256 SHA256:rGTXTBDgnalQkXzlRp1++4aa6sPJMtx66W5+dDX4lOY root@labserver (ED25519)
  4. Type test ! -e ~/b15-practice.tar.gz && printf 'Remote destination absent\n'
  5. Press Enter — Confirm that the reserved upload will not overwrite a remote file
  6. Output: Remote destination absent

From the local shell, connect:

Terminal window
sftp learner@labserver

Compare the entire ED25519 SHA256 fingerprint with the console’s value. Stop if they differ. If they match, answer yes, then type the lab account password, learner, at the hidden password prompt. Each recording uses a separate server key, so the preceding lesson’s fingerprint is not this practice server’s identity.

At sftp>, type:

Commands typed at sftp>
lpwd
pwd
put bundle.tar.gz b15-practice.tar.gz
bye
Transfer: practice solution
learner@rootvolt:~/lab/b15-practice$ sftp learner@labserverThe authenticity of host 'labserver (172.19.0.2)' can't be established.
ED25519 key fingerprint is SHA256:rGTXTBDgnalQkXzlRp1++4aa6sPJMtx66W5+dDX4lOY.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yesWarning: Permanently added 'labserver' (ED25519) to the list of known hosts.
learner@labserver's password: Connected to labserver.
sftp> lpwdLocal working directory: /home/learner/lab/b15-practice
sftp> pwdRemote working directory: /home/learner
sftp> put bundle.tar.gz b15-practice.tar.gzUploading bundle.tar.gz to /home/learner/b15-practice.tar.gz
bundle.tar.gz                                 100%  283   701.7KB/s   00:00    
sftp> byelearner@rootvolt:~/lab/b15-practice$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, GNU Bash 5.2.21. LOCAL SFTP client: check server identity, authenticate, identify both directories, and upload the practice archive.
Steps (20)
  1. Type sftp learner@labserver
  2. Press Enter — Compare the complete fingerprint with the trusted console before accepting
  3. Output: The authenticity of host 'labserver (172.19.0.2)' can't be established. ED25519 key fingerprint is SHA256:rGTXTBDgnalQkXzlRp1++4aa6sPJMtx66W5+dDX4lOY. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])?
  4. Type yes into the running program
  5. Press Enter — Accept the matching host identity
  6. Output: Warning: Permanently added 'labserver' (ED25519) to the list of known hosts. learner@labserver's password:
  7. Type the password (the terminal shows nothing)
  8. Press Enter — Authenticate to SFTP with the hidden lab password
  9. Output: Connected to labserver. sftp>
  10. Type lpwd into the running program
  11. Press Enter — Identify the local source directory
  12. Output: Local working directory: /home/learner/lab/b15-practice sftp>
  13. Type pwd into the running program
  14. Press Enter — Identify the remote destination directory
  15. Output: Remote working directory: /home/learner sftp>
  16. Type put bundle.tar.gz b15-practice.tar.gz into the running program
  17. Press Enter — Upload the local archive into the remote home directory
  18. Output: Uploading bundle.tar.gz to /home/learner/b15-practice.tar.gz bundle.tar.gz 100% 283 701.7KB/s 00:00 sftp>
  19. Type bye into the running program
  20. Press Enter — Close SFTP and return to the local shell
Side Archive pathname
Local rootvolt ~/lab/b15-practice/bundle.tar.gz
Remote labserver ~/b15-practice.tar.gz

From the local shell:

Terminal window
ssh learner@labserver

Enter the hidden lab password again. At the remote shell:

Terminal window
sha256sum ~/b15-practice.tar.gz
tar -tf ~/b15-practice.tar.gz
rm ~/b15-practice.tar.gz
test ! -e ~/b15-practice.tar.gz && printf 'Remote reset complete\n'
exit
Verify: practice solution
learner@rootvolt:~/lab/b15-practice$ ssh learner@labserverlearner@labserver's password: Welcome to Ubuntu 24.04.5 LTS (GNU/Linux 6.18.33.1-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.learner@labserver:~$ sha256sum ~/b15-practice.tar.gz2c9edc96e62135f64560f13abc9df58323e9debf535e2c7cc3ffa5db586f403d  /home/learner/b15-practice.tar.gzlearner@labserver:~$ tar -tf ~/b15-practice.tar.gzbundle/
bundle/results/
bundle/results/warnings.txt
bundle/inbox/
bundle/inbox/checks.loglearner@labserver:~$ rm ~/b15-practice.tar.gzlearner@labserver:~$ test ! -e ~/b15-practice.tar.gz && printf 'Remote reset complete\n'Remote reset completelearner@labserver:~$ exitlogout
Connection to labserver closed.learner@rootvolt:~/lab/b15-practice$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, GNU Bash 5.2.21. REMOTE solution: check the complete digest and member list, remove the uploaded archive, and return to the local shell.
Steps (20)
  1. Type ssh learner@labserver
  2. Press Enter — Open a remote shell on the already verified host
  3. Output: learner@labserver's password:
  4. Type the password (the terminal shows nothing)
  5. Press Enter — Authenticate again to reach the remote shell
  6. Output: Welcome to Ubuntu 24.04.5 LTS (GNU/Linux 6.18.33.1-microsoft-standard-WSL2 x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details.
  7. Type sha256sum ~/b15-practice.tar.gz
  8. Press Enter — Compare the complete remote digest with the local digest
  9. Output: 2c9edc96e62135f64560f13abc9df58323e9debf535e2c7cc3ffa5db586f403d /home/learner/b15-practice.tar.gz
  10. Type tar -tf ~/b15-practice.tar.gz
  11. Press Enter — Verify the remote archive has the intended members
  12. Output: bundle/ bundle/results/ bundle/results/warnings.txt bundle/inbox/ bundle/inbox/checks.log
  13. Type rm ~/b15-practice.tar.gz
  14. Press Enter — Remove the uploaded archive on the server
  15. Type test ! -e ~/b15-practice.tar.gz && printf 'Remote reset complete\n'
  16. Press Enter — Confirm the remote upload is absent
  17. Output: Remote reset complete
  18. Type exit
  19. Press Enter — Leave the remote shell before cleaning local files
  20. Output: logout Connection to labserver closed.

These full digest values repeat the wrapped replay rows:

Archive location Captured SHA-256 digest
Local bundle.tar.gz 2c9edc96e62135f64560f13abc9df58323e9debf535e2c7cc3ffa5db586f403d
Remote b15-practice.tar.gz 2c9edc96e62135f64560f13abc9df58323e9debf535e2c7cc3ffa5db586f403d

The remote member list contains the original log and warning summary. Matching digests check the exact transferred archive; the isolated extraction has already tested that its contents match the local project.

After the local prompt returns:

Terminal window
rm restored/bundle/inbox/checks.log restored/bundle/results/warnings.txt
rmdir restored/bundle/inbox restored/bundle/results restored/bundle restored
rm bundle/inbox/checks.log bundle/results/warnings.txt
rmdir bundle/inbox bundle/results bundle
rm bundle.tar.gz
cd ~/lab
rmdir ~/lab/b15-practice
ls -a ~/.ssh
ssh-keygen -R labserver
ssh-keygen -F labserver || printf 'No saved key for labserver\n'
test ! -e ~/lab/b15-practice && printf 'Local reset complete\n'
Reset local exercise files and trust in labserver
learner@rootvolt:~/lab/b15-practice$ rm restored/bundle/inbox/checks.log restored/bundle/results/warnings.txtlearner@rootvolt:~/lab/b15-practice$ rmdir restored/bundle/inbox restored/bundle/results restored/bundle restoredlearner@rootvolt:~/lab/b15-practice$ rm bundle/inbox/checks.log bundle/results/warnings.txtlearner@rootvolt:~/lab/b15-practice$ rmdir bundle/inbox bundle/results bundlelearner@rootvolt:~/lab/b15-practice$ rm bundle.tar.gzlearner@rootvolt:~/lab/b15-practice$ cd ~/lablearner@rootvolt:~/lab$ rmdir ~/lab/b15-practicelearner@rootvolt:~/lab$ ls -a ~/.ssh.  ..  known_hosts  known_hosts.oldlearner@rootvolt:~/lab$ ssh-keygen -R labserver# Host labserver found: line 1
# Host labserver found: line 2
# Host labserver found: line 3
/home/learner/.ssh/known_hosts updated.
Original contents retained as /home/learner/.ssh/known_hosts.oldlearner@rootvolt:~/lab$ ssh-keygen -F labserver || printf 'No saved key for labserver\n'No saved key for labserverlearner@rootvolt:~/lab$ test ! -e ~/lab/b15-practice && printf 'Local reset complete\n'Local reset completelearner@rootvolt:~/lab$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, GNU Bash 5.2.21. LOCAL reset removes both project trees, the archive, and only labserver's saved host keys.
Steps (26)
  1. Type rm restored/bundle/inbox/checks.log restored/bundle/results/warnings.txt
  2. Press Enter — Remove the disposable restored files
  3. Type rmdir restored/bundle/inbox restored/bundle/results restored/bundle restored
  4. Press Enter — Remove the empty restored tree
  5. Type rm bundle/inbox/checks.log bundle/results/warnings.txt
  6. Press Enter — Remove only the disposable source and derived result
  7. Type rmdir bundle/inbox bundle/results bundle
  8. Press Enter — Remove the empty local project directories
  9. Type rm bundle.tar.gz
  10. Press Enter — Remove the local transfer archive
  11. Type cd ~/lab
  12. Press Enter — Return to the baseline directory
  13. Type rmdir ~/lab/b15-practice
  14. Press Enter — Remove the empty workspace
  15. Type ls -a ~/.ssh
  16. Press Enter — Inspect the SSH directory before removing the labserver entry
  17. Output: . .. known_hosts known_hosts.old
  18. Type ssh-keygen -R labserver
  19. Press Enter — Remove only saved host keys for labserver
  20. Output: # Host labserver found: line 1 # Host labserver found: line 2 # Host labserver found: line 3 /home/learner/.ssh/known_hosts updated. Original contents retained as /home/learner/.ssh/known_hosts.old
  21. Type ssh-keygen -F labserver || printf 'No saved key for labserver\n'
  22. Press Enter — Confirm no saved key for labserver remains
  23. Output: No saved key for labserver
  24. Type test ! -e ~/lab/b15-practice && printf 'Local reset complete\n'
  25. Press Enter — Confirm the local exercise reset is complete
  26. Output: Local reset complete

Removing both project trees does not reset server trust: the separate lookup confirms that labserver’s saved keys are gone. Retain the SSH directory and backup following the SSH reset explanation.

Comparing the source with itself. Use the restored/bundle pathname as the second diff argument. Two identical pathnames do not test recovery.

Comparing against another run’s archive digest. Tar includes metadata. Compare the exact local archive you uploaded with the remote copy, not an archive you rebuilt later.

1. What separate jobs do tar and gzip perform?

Answer

Tar packages members and their paths. Gzip compresses the archive’s bytes. Decompressing the gzip layer restores an archive; extraction restores separate members.

2. Why list members before extracting into a clean directory?

Answer

The list lets you inspect stored names and structure before they are written to disk. The clean destination avoids overwriting the original project and provides an independent copy to compare.

3. Which tool locates a changed text line, and which value helps check a transferred archive’s bytes?

Answer

Diff describes text changes line by line. A complete SHA-256 digest helps compare an archive before and after transfer. The digest does not explain which member or line changed.

4. Does a digest match replace the SSH fingerprint check?

Answer

No. The fingerprint identifies the server you are trusting. The archive digest checks received bytes against the local file. Neither replaces the other.

5. Why reset the server before closing the SSH shell?

Answer

The remote upload remains after transfer and after local cleanup. Remove it while you are at the remote prompt, verify its absence, then exit and clean up locally.

Goal 6 and the solution’s final two sections are the recorded reset. The server’s uploaded archive is removed, followed by both local project copies, the local archive, and only labserver’s saved host keys. The SSH directory, other entries, and backup remain. The initial baseline lab files remain.

  • Keep source input and saved results distinct.
  • Inspect archives and test recovery with an isolated extraction.
  • Compare the complete digests of the local and remote archive.
  • Verify server identity and reset both filesystems separately.

Next, build and verify your personal Linux workspace in the Beginner capstone.