Practice: Archives and Everyday Workflow
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.
Before you start
Section titled “Before you start”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.
Scenario and input
Section titled “Scenario and input”Inside the local workspace, use your editor to create bundle/inbox/checks.log with a final newline:
INFO openingWARN fan slowWARN cable looseINFO closingKeep 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.
Goals you can check
Section titled “Goals you can check”- Organize: The local bundle has separate inbox and results directories. The original log still has all four lines.
- 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.
- Package and inspect: One gzip-compressed tar archive contains both the original log and the saved result. Inspect names before extracting.
- Test recovery: Extract into an empty restored directory. A recursive comparison of bundle and restored/bundle finds no differences and returns status 0.
- 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.
- 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.
One recorded solution
Section titled “One recorded solution”Organize and locate
Section titled “Organize and locate”At the local shell:
mkdir ~/lab/b15-practicecd ~/lab/b15-practicemkdir -p bundle/inbox bundle/resultsCreate the editor file shown above, then locate and inspect it:
find bundle -type f -name '*.log'grep -n 'WARN' bundle/inbox/checks.loglearner@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$ Steps (8)
- Type
mkdir ~/lab/b15-practice - Press Enter — Reserve the local workspace
- Type
cd ~/lab/b15-practice - Press Enter — Enter the local workspace
- Type
mkdir -p bundle/inbox bundle/results - Press Enter — Separate the source notes from derived results
- Type
printf '%s\n' 'INFO opening' 'WARN fan slow' 'WARN cable loose' 'INFO closing' > bundle/inbox/checks.log - Press Enter — Write the synthetic input log
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$ Steps (6)
- Type
find bundle -type f -name '*.log' - Press Enter — Locate the log by name under the project
- Output:
bundle/inbox/checks.log - Type
grep -n 'WARN' bundle/inbox/checks.log - Press Enter — Locate the matching line with its line number
- Output:
2:WARN fan slow 3:WARN cable loose
Save the two warnings
Section titled “Save the two warnings”grep 'WARN' bundle/inbox/checks.log > bundle/results/warnings.txtcat bundle/results/warnings.txtlearner@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$ Steps (5)
- Type
grep 'WARN' bundle/inbox/checks.log > bundle/results/warnings.txt - Press Enter — Save matching text without line-number decoration
- Type
cat bundle/results/warnings.txt - Press Enter — Read the saved result before packaging
- 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.
Package and test recovery
Section titled “Package and test recovery”tar -czf bundle.tar.gz bundletar -tf bundle.tar.gzsha256sum bundle.tar.gzmkdir restoredtar -xf bundle.tar.gz -C restoreddiff -r bundle restored/bundleecho $?Predict: would extracting into bundle itself provide an independent copy for the comparison?
Run it, then compare with your guess
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$ Steps (17)
- Type
tar -czf bundle.tar.gz bundle - Press Enter — Package the source and saved result together
- Type
tar -tf bundle.tar.gz - Press Enter — Inspect the archive members before transferring
- Output:
bundle/ bundle/results/ bundle/results/warnings.txt bundle/inbox/ bundle/inbox/checks.log - Type
sha256sum bundle.tar.gz - Press Enter — Record the local digest for remote comparison
- Output:
2c9edc96e62135f64560f13abc9df58323e9debf535e2c7cc3ffa5db586f403d bundle.tar.gz - Type
mkdir restored - Press Enter — Create a clean destination to test the practice archive
- Type
tar -xf bundle.tar.gz -C restored - Press Enter — Restore a copy while preserving the original bundle
- Type
diff -r bundle restored/bundle - Press Enter — Compare the original and restored directory trees
- Type
echo $? - Press Enter — Check the successful recursive comparison status
- 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.
Verify identity and transfer
Section titled “Verify identity and transfer”On the trusted server console, read the fingerprint and confirm that the upload name is unused:
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pubtest ! -e ~/b15-practice.tar.gz && printf 'Remote destination absent\n'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:~$ Steps (6)
- Type
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub - Press Enter — Obtain the full server fingerprint independently
- Output:
256 SHA256:rGTXTBDgnalQkXzlRp1++4aa6sPJMtx66W5+dDX4lOY root@labserver (ED25519) - Type
test ! -e ~/b15-practice.tar.gz && printf 'Remote destination absent\n' - Press Enter — Confirm that the reserved upload will not overwrite a remote file
- Output:
Remote destination absent
From the local shell, connect:
sftp learner@labserverCompare 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:
lpwdpwdput bundle.tar.gz b15-practice.tar.gzbyelearner@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$ Steps (20)
- Type
sftp learner@labserver - Press Enter — Compare the complete fingerprint with the trusted console before accepting
- 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])? - Type
yesinto the running program - Press Enter — Accept the matching host identity
- Output:
Warning: Permanently added 'labserver' (ED25519) to the list of known hosts. learner@labserver's password: - Type the password (the terminal shows nothing)
- Press Enter — Authenticate to SFTP with the hidden lab password
- Output:
Connected to labserver. sftp> - Type
lpwdinto the running program - Press Enter — Identify the local source directory
- Output:
Local working directory: /home/learner/lab/b15-practice sftp> - Type
pwdinto the running program - Press Enter — Identify the remote destination directory
- Output:
Remote working directory: /home/learner sftp> - Type
put bundle.tar.gz b15-practice.tar.gzinto the running program - Press Enter — Upload the local archive into the remote home directory
- Output:
Uploading bundle.tar.gz to /home/learner/b15-practice.tar.gz bundle.tar.gz 100% 283 701.7KB/s 00:00 sftp> - Type
byeinto the running program - 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 |
Verify and remove the remote copy
Section titled “Verify and remove the remote copy”From the local shell:
ssh learner@labserverEnter the hidden lab password again. At the remote shell:
sha256sum ~/b15-practice.tar.gztar -tf ~/b15-practice.tar.gzrm ~/b15-practice.tar.gztest ! -e ~/b15-practice.tar.gz && printf 'Remote reset complete\n'exitlearner@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$ Steps (20)
- Type
ssh learner@labserver - Press Enter — Open a remote shell on the already verified host
- Output:
learner@labserver's password: - Type the password (the terminal shows nothing)
- Press Enter — Authenticate again to reach the remote shell
- 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. - Type
sha256sum ~/b15-practice.tar.gz - Press Enter — Compare the complete remote digest with the local digest
- Output:
2c9edc96e62135f64560f13abc9df58323e9debf535e2c7cc3ffa5db586f403d /home/learner/b15-practice.tar.gz - Type
tar -tf ~/b15-practice.tar.gz - Press Enter — Verify the remote archive has the intended members
- Output:
bundle/ bundle/results/ bundle/results/warnings.txt bundle/inbox/ bundle/inbox/checks.log - Type
rm ~/b15-practice.tar.gz - Press Enter — Remove the uploaded archive on the server
- Type
test ! -e ~/b15-practice.tar.gz && printf 'Remote reset complete\n' - Press Enter — Confirm the remote upload is absent
- Output:
Remote reset complete - Type
exit - Press Enter — Leave the remote shell before cleaning local files
- 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.
Reset the local copies
Section titled “Reset the local copies”After the local prompt returns:
rm restored/bundle/inbox/checks.log restored/bundle/results/warnings.txtrmdir restored/bundle/inbox restored/bundle/results restored/bundle restoredrm bundle/inbox/checks.log bundle/results/warnings.txtrmdir bundle/inbox bundle/results bundlerm bundle.tar.gzcd ~/labrmdir ~/lab/b15-practicels -a ~/.sshssh-keygen -R labserverssh-keygen -F labserver || printf 'No saved key for labserver\n'test ! -e ~/lab/b15-practice && printf 'Local reset complete\n'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$ Steps (26)
- Type
rm restored/bundle/inbox/checks.log restored/bundle/results/warnings.txt - Press Enter — Remove the disposable restored files
- Type
rmdir restored/bundle/inbox restored/bundle/results restored/bundle restored - Press Enter — Remove the empty restored tree
- Type
rm bundle/inbox/checks.log bundle/results/warnings.txt - Press Enter — Remove only the disposable source and derived result
- Type
rmdir bundle/inbox bundle/results bundle - Press Enter — Remove the empty local project directories
- Type
rm bundle.tar.gz - Press Enter — Remove the local transfer archive
- Type
cd ~/lab - Press Enter — Return to the baseline directory
- Type
rmdir ~/lab/b15-practice - Press Enter — Remove the empty workspace
- Type
ls -a ~/.ssh - Press Enter — Inspect the SSH directory before removing the labserver entry
- Output:
. .. known_hosts known_hosts.old - Type
ssh-keygen -R labserver - Press Enter — Remove only saved host keys for labserver
- 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 - Type
ssh-keygen -F labserver || printf 'No saved key for labserver\n' - Press Enter — Confirm no saved key for labserver remains
- Output:
No saved key for labserver - Type
test ! -e ~/lab/b15-practice && printf 'Local reset complete\n' - Press Enter — Confirm the local exercise reset is complete
- 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.
Mistakes to recognize
Section titled “Mistakes to recognize”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.
Recall check
Section titled “Recall check”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.
Reset this lesson
Section titled “Reset this lesson”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.
Further reading
Section titled “Further reading”- On Ubuntu:
man tar,man sha256sum,man diff,man sftp, andman ssh. - GNU tar manual.
- GNU Diffutils manual.
- Ubuntu SFTP manual and SSH manual.