LINUX · Integrity · 8 min

Record a checksum and verify a copy

Check file integrity using a digest and a byte comparison.

Not completed

Your task

Create app.conf.sha256 for app.conf, copy app.conf to backup.conf, and verify the digest. The original and backup must match.

What you’re aiming for

  • sha256sum -c reports app.conf OK.
  • backup.conf is byte-identical to app.conf.

1. Prepare your practice folder

Use a Linux terminal, such as Ubuntu or WSL on Windows. These examples use Linux file permissions. In WSL, create your practice folder in your Linux home directory (~).

Create a new, empty folder for this exercise. If that name already exists, choose another new name. Continue only after you’re inside the new folder.

NEW PRACTICE FOLDER
mkdir opsrung-linux-verify-checksum-copy && cd opsrung-linux-verify-checksum-copy

Run these setup commands in that folder:

SETUP — RUN ONCE
printf '%s\n' 'mode=practice
workers=2' > app.conf

2. Try the task

Work toward the goal above. Start by inspecting the files or resources, then use a hint if you need one.

Hint 1

sha256sum can write the expected hash and filename.

Hint 2

-c reads that recorded checksum.

Hint 3

Use cmp to compare the copied file with the original.

3. Review your result

Use these commands to look at your result and compare it with the goals. The website does not run or verify them.

REVIEW IN YOUR TERMINAL
cat app.conf.sha256
sha256sum -c app.conf.sha256
cmp app.conf backup.conf

What you should see

  • sha256sum -c reports app.conf OK.
  • backup.conf is byte-identical to app.conf.

If your result differs: Compare the actual output with each goal. Keep your work inside this exercise’s folder and use only its named resources.

Compare with one possible solution
ONE POSSIBLE SOLUTION
sha256sum app.conf > app.conf.sha256
cp app.conf backup.conf
sha256sum -c app.conf.sha256
cmp app.conf backup.conf

Other approaches are fine if you reach the same goal. Opening this solution does not mark the exercise complete.

Finished this exercise?

You decide when you’re done. Your choice is saved in this browser, and you can change it later.