wEEK 5

Advanced File Management & Archives

Why Archiving and Compression Are Essential in Linux Work

Every professional environment produces files—lots of them. Reports, images, logs, configuration files, backups. Managing them one by one quickly becomes inefficient. That’s where archiving and compression tools come in. They let you:

A.R.C.H.I.V.E. Framework

This week we’re introducing a new mnemonic: A.R.C.H.I.V.E..
Each letter highlights a skill you’ll practice. On the course page, each section will have a distinct background color so you can spot and navigate quickly.

A — Archives (tar basics)

Archives allow you to collect multiple files and directories into one portable unit. On Linux, the tar command is the standard tool. System administrators use it to ship application code, back up log directories, or snapshot user data. Creating an archive ensures structure and permissions are preserved, which is crucial when restoring on another system.

Commands:
cd ~
mkdir -p week5-archives && cd week5-archives
mkdir reports images
echo “Q1 Report” > reports/q1.txt
echo “Q2 Report” > reports/q2.txt
touch images/img{1..3}.png
tar -cvf backup.tar reports images
tar -tvf backup.tar

R — Retrieve from Archives

Retrieving means extracting files from an archive. Extraction is always done carefully, often into a test directory first, to confirm the archive contains what you expect before overwriting production paths. In practice, restore operations in IT usually start in a scratch directory, followed by verification.

Commands:
mkdir restored
tar -xvf backup.tar -C restored
ls -R restored

C — Compress and Save Space

Compression reduces storage size and speeds up file transfers over networks. In real environments, this saves bandwidth and lowers cloud storage costs. Different compression algorithms serve different priorities: gzip for speed, bzip2 for better space savings, xz for maximum compression.

Commands:
tar -czvf backup.tar.gz reports images
tar -cjvf backup.tar.bz2 reports images
ls -lh



Navigate the tree​

H — Handling Copies and Moves

Once created, archives are rarely static. They’re renamed, copied, and moved to reflect retention policies or to distribute across servers. A backup with a timestamp or role in its name is easier to identify months later.

Commands:
mv backup.tar.gz archives_backup.tar.gz
cp backup.tar.bz2 archives_copy.tar.bz2

I — Inspecting Archives

It’s common to inspect an archive before extracting it. This avoids overwriting critical files and confirms the archive is valid. Inspecting is especially important when receiving files from outside sources.

Command:
tar -tzvf archives_backup.tar.gz

V — Verify Integrity

Verifying ensures that what was archived and what was restored match exactly. Without this, you cannot trust your backup. On production servers, teams often use checksum tools, but a quick diff confirms whether key files are identical.

Command:
diff reports/q1.txt restored/reports/q1.txt

E — Extra Practice (zip/unzip)

While tar is the Linux standard, .zip files are still common for cross-platform sharing. Many Windows and macOS users expect .zip. Knowing both keeps your work compatible.

Commands:
zip -r project.zip reports images
unzip project.zip -d unzipped_project
ls -R unzipped_project

This concludes Lecture 5. Please return to Blackboard to access the Week 5 materials.

Scroll to Top