LINUX · Files & archives · 8 min
Archive only the configuration
Create and inspect a tar archive without including scratch files.
Not completedYour task
Create configs.tar containing the config directory and its two files. Do not include scratch.txt. Preserve the original files.
What you’re aiming for
- The archive contains config/app.conf and config/db.conf, with their original contents.
- scratch.txt is not in the archive.
- Original configuration files remain.
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.
mkdir opsrung-linux-archive-config && cd opsrung-linux-archive-config
Run these setup commands in that folder:
mkdir config printf 'mode=practice\n' > config/app.conf printf 'host=local\n' > config/db.conf printf 'do not archive\n' > scratch.txt
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
List the directory before deciding what to archive.
Hint 2
Give tar the config directory explicitly instead of archiving everything.
Hint 3
Use tar -cf to create and tar -tf to inspect the archive.
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.
tar -tf configs.tar tar -xOf configs.tar config/app.conf tar -xOf configs.tar config/db.conf ls config
What you should see
- tar -tf configs.tar lists only config/ and its two files, app.conf and db.conf. Listing order can vary.
- Reading app.conf from the archive prints mode=practice; reading db.conf prints host=local.
- ls config still lists app.conf and db.conf.
If your result differs: Archive config/ specifically. Archiving the whole practice folder would also include scratch.txt.
Compare with one possible solution
tar -cf configs.tar config/ tar -tf configs.tar
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.