Introduction
A community workshop keeps its room schedule, visitor contact address, and access note in a shared HDFS folder. Before editing the programme, you need a recovery point that will still show the approved files after the live folder changes.
You will first read normal data, create a native snapshot as the ordinary owner, and then make two controlled changes. You should already know HDFS paths, uploads, directories, and basic owner/group permissions. This lab introduces snapshots and their historical paths. Use Terminal throughout; all data is independent of other labs. The author estimates 40 minutes, including reading and ordinary corrections.
Save the Approved Files Before Editing
In this step, you will read the working programme and create a named recovery point. Start in Terminal. cd changes this shell's local working directory; paths beginning with /user/labex/ in HDFS commands belong to HDFS, rather than your local disk.
cd /home/labex/project
Read the live schedule:
hdfs dfs -cat /user/labex/snapshot-workshop/team/schedule.csv
The comma-separated fields name a room and its session:
room,session
A,Printmaking
B,Bookbinding
The team folder also contains contacts.csv and notes.txt. List it:
hdfs dfs -ls /user/labex/snapshot-workshop/team
These are normal shared files owned by labex, with group bigdata. The prepared analyst user belongs to that group and may read without writing. You are the ordinary owner, not the NameNode service identity hdfs. The teaching environment uses simple authentication; it does not demonstrate Kerberos security.
A snapshot is a read-only historical view of a directory at a named point. An administrator has enabled snapshot capability only on this course folder. You create the actual recovery point yourself. -createSnapshot takes the live directory followed by your snapshot name:
hdfs dfs -createSnapshot /user/labex/snapshot-workshop/team morning-approved
The response identifies a native path ending in .snapshot/morning-approved. The special .snapshot component selects history; it is not an ordinary backup directory that you create with -mkdir. Read the historical schedule:
hdfs dfs -cat /user/labex/snapshot-workshop/team/.snapshot/morning-approved/schedule.csv
It contains the same two approved sessions. List all three historical files:
hdfs dfs -ls /user/labex/snapshot-workshop/team/.snapshot/morning-approved
The snapshot includes the original contact and access note too. If a command says No such file or directory, compare your spelling with this listing, then repeat only the failed read. If -createSnapshot says the name already exists, inspect that snapshot instead of deleting or recreating it. Do not rerun environment setup: it refuses to overwrite existing work.
You now have a real recovery point before any editing. A local downloaded copy or a folder with the same name would not create this native history.
Compare History with Later Work
In this step, you will add legitimate new work, make a narrowly scoped mistake, and see that the snapshot stays unchanged. Continue in the same Terminal.
The later workshop session is provided locally. Read it first:
cat /home/labex/project/incoming/late-session.csv
It contains room C and Paper Folding. Upload it to the live team folder. It belongs to the current programme and must survive any later recovery:
hdfs dfs -put /home/labex/project/incoming/late-session.csv /user/labex/snapshot-workshop/team/late-session.csv
Keep the intended sharing group with -chgrp. The file mode 640 grants the owner read/write, the group read, and other users no file access:
hdfs dfs -chgrp bigdata /user/labex/snapshot-workshop/team/late-session.csv
hdfs dfs -chmod 640 /user/labex/snapshot-workshop/team/late-session.csv
Next, examine a deliberately incorrect replacement:
cat /home/labex/project/incoming/schedule-draft.csv
It contains A,CANCELLED. The next upload deliberately overwrites only the named live schedule. The -f option permits replacing that destination; use it here only because this is the controlled edit. It does not affect the snapshot.
hdfs dfs -put -f /home/labex/project/incoming/schedule-draft.csv /user/labex/snapshot-workshop/team/schedule.csv
The second controlled mistake removes only the live contact file. Confirm the exact path first:
hdfs dfs -ls /user/labex/snapshot-workshop/team/contacts.csv
hdfs dfs -rm /user/labex/snapshot-workshop/team/contacts.csv
Do not use a wildcard, recursive deletion, or the team root. Read the changed schedule and then its historical version:
hdfs dfs -cat /user/labex/snapshot-workshop/team/schedule.csv
hdfs dfs -cat /user/labex/snapshot-workshop/team/.snapshot/morning-approved/schedule.csv
The live result is cancelled; history still contains Printmaking and Bookbinding. Read the historical contact as the real shared reader. sudo -u analyst runs this one client as that ordinary test identity; the absolute client path selects the prepared HDFS tool:
sudo -u analyst /usr/local/bin/hdfs dfs -cat /user/labex/snapshot-workshop/team/.snapshot/morning-approved/contacts.csv
The address remains visitors@example.test, although the live contact file is missing. Check the live listing:
hdfs dfs -ls /user/labex/snapshot-workshop/team
It contains the changed schedule, unchanged note, and new session. An existing-destination error on the earlier new-file upload means you should read that existing file, rather than delete it and broaden the upload. A missing-contact error on a repeated removal means the controlled deletion has already occurred; inspect the listing and continue.
Keep this final scene as it is. The next lab provides its own independent damaged scene and teaches recovery. Snapshots share storage with HDFS: their blocks are not independent backup copies, so they do not protect against losing the entire storage system.
Summary
You created a native HDFS snapshot before editing, then distinguished its protected historical files from the changed live folder. The later session exists only in the live programme, so replacing the entire folder with history would discard valid work. You also read history using the actual shared analyst identity.



