This 3‑hour workshop covers the core utilities that allow you to create, copy, move, link, and delete files and directories in a Linux environment. The plan is suitable for students who already know how to navigate the filesystem but want to master the manipulation side of things.
touch, catcp, mvrm, findlnchmod, chownsedtouch – Create or Update TimestampCreates an empty file or updates its access & modification times.
touch file.txt touch -t 202309301200 newfile.log
notes.txt in ~/tmp.-t.cat – Concatenate / DisplayDisplays file contents; also used to create files.
cat file.txt cat > newfile.txt echo "Hello" | cat - file.txt > combined.txt
info.txt using cat > info.txt.info.txt and notes.txt into full.txt.cp – Copy Files & DirectoriesCopies files or directories, with optional flags.
cp source.txt dest.txt cp -r dir1/ dir2/ cp -p file1 file2
info.txt to ~/backup/ preserving attributes.~/tmp/ to ~/dup/.mv – Move / RenameMoves or renames files and directories.
mv oldname.txt newname.txt mv file.txt ../destination/ mv -t dest_dir/ file1 file2
full.txt to report.txt.report.txt into ~/docs and check that the original path is gone.rm – Remove Files & DirectoriesDeletes files; can be forced or recursive.
rm file.txt rm -f file.txt rm -r dir/ rm -i file.txt
notes.txt using -i to confirm.*.tmp inside ~/tmp (no confirmation).find – Search & ExecuteFinds files by name, type, size, etc. and can execute actions.
find . -name "*.log"
find /var/log -size +5M -exec rm {} \;
.txt files in ~/tmp and list them.~/tmp.ln – Hard & Symbolic LinksCreates links to files or directories.
ln existing.txt hardlink.txt ln -s /var/log/syslog syslink.log
hard_notes.txt pointing to notes.txt.soft_info.txt in ~/docs that points to info.txt.chmod – Change PermissionsAlters file mode bits; numeric and symbolic forms.
chmod 644 file.txt chmod u+x script.sh chmod g-w file.txt
script.sh executable for the owner only.notes.txt to read‑write for everyone but write‑execute for the owner.chown – Change Owner & GroupModifies file ownership; can recurse into directories.
chown user:user file.txt chown -R root:root dir/
notes.txt to root.find … -exec rm … – Automated CleanupCombines find with exec to remove files.
find . -name "*.bak" -exec rm {} \;
find . -mtime +30 -type f -exec rm {} \;
.bak files inside ~/tmp.~/tmp and delete them.sed – Stream Editor (Text Replace)Performs inline or streamed search & replace.
sed -i 's/old/new/g' file.txt sed '/^#/d' file.sh
notes.txt and save in notes_bar.txt.#) from script.sh.rm -rf – Recursive Force DeleteForcefully removes directories and their contents.
rm -rf ~/tmp/old/
~/tmp/old (assume it contains many files).ls.mv -n – Move Without OverwritePrevents accidental overwrites when the destination exists.
mv -n source.txt dest.txt mv -n file1 file2
notes.txt to ~/docs/ but ensure you don’t overwrite an existing file.ln – Hard LinkCreates a hard link that shares the same inode.
ln existing.txt hardlink.txt
hard_notes.txt to notes.txt.ls -i.ln -s – Symbolic LinkCreates a pathname reference to another file/directory.
ln -s /usr/share/doc README_link.txt
~/tmp that points to /etc/hostname.cat to confirm it reads the target file.cleanup.sh – Basic AutomationStudents write a small shell script that uses the above commands.
# cleanup.sh #!/bin/bash DIR=$1 find "$DIR" -name "*.tmp" -delete echo "Removed all .tmp files from $DIR"
~/tmp/ and make it executable../cleanup.sh ~/tmp and confirm no .tmp files remain.Students work in small groups to complete the exercises. Instructors circulate to demonstrate “best‑practice” habits:
ls -l or stat before moving or deleting.~/backup folder when using -i or -p flags.sed and ln changes on dummy files first..conf files from /etc to /tmp/backup_conf./tmp/links.640 and owner to the current user.Feel free to tweak the schedule or the difficulty of the exercises to match your students’ experience level.