File Management  «Prev  Next»

Creating a Symbolic Link and Finding Files: Exercise

Objective: Create a symbolic link to an existing file and save a list of regular files in a project tree.

You want convenient access to a project document without moving it or creating an independent copy. A symbolic link supplies a pathname reference. Separately, find can produce a list of the project's regular files.

Prepare a Practice Workspace

Create a fresh workspace under your own account. If the name below exists, choose a different name. Run setup commands separately and stop on errors. These are small text fixtures, not a deployed website.

mkdir file-search-practice
cd file-search-practice
mkdir -p project/qa project/docs project/.notes
printf '%s\n' 'Practice test plan' > project/qa/test_plan.html
printf '%s\n' 'Practice index' > project/docs/index.html
printf '%s\n' 'Hidden-directory note' > project/.notes/note.txt

Tasks

  1. Check your location with pwd. Inspect project/qa and confirm that test_plan.html exists.
  2. From the workspace directory, create a symbolic link named plan.html to project/qa/test_plan.html. Keep the target file in its original location.
  3. Inspect the link with ls -F and ls -l plan.html. Read through it with cat plan.html. Explain where the relative target pathname starts.
  4. Use find to list only regular files under project, including files in hidden directories. Save the paths to a new project_list file outside the searched tree, in the workspace directory.
  5. Display the saved report. Compare it with ls -aR project, and explain why the report contains paths rather than copies of the files.

Use -type f to select regular files and -print to print paths. Output redirection with > replaces an existing report, so check the filename first. Read diagnostics: a permission error can leave an incomplete list.

Self-Assessment: 2 Points

This is self-assessment, not automatic scoring. Submit your commands, observations, and explanation to compare with the model solution. Submission does not execute your commands or award points.