Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 3: Linux Basic Commands

AWS Cloud

Practice Questions and Lab Exercises

Come on, practice time! Use an assigned Linux learning terminal or a local compatible shell. Work on the sample files in your own practice folder and compare the results after typing each command.

  1. Explain the purpose of /etc, /var/log, /home and /usr/share.
  2. What is the difference between absolute and relative paths? Give two examples.
  3. Convert to numeric: rwxr-x---, rw-r--r--, r--------. Convert 750 and 640 to symbolic.
  4. Why does AWS show mode 400 for the client-side SSH private key on macOS or Linux? Explain what access the other classes should have.
  5. Write the commands to install git and tree on Ubuntu and on Amazon Linux 2023.
  6. File task. Create a unique practice workspace, copy the candidate and demonstrate the old and new names. Compare the contents before choosing a replacement.
  7. Identity task. Use id to describe your own active identity and group list. Compare it with a lookup for the same named account. Explain one reason those lists could differ.
  8. Process task. Start one short sleep in your own shell, record $! immediately and inspect that exact PID. Collect the child’s normal exit status with wait.
  9. Editor task. Use a known practice path and write a three-line note. After exiting, verify the exact lines and count. Compare save and discard using a second unsaved change.

Quick Revision

  • Navigate: pwd, ls -la, cd. Files: mkdir -p, touch, cp -r, mv, rm -r (permanent!).
  • View: cat, less, head, tail -f.
  • Mode bits use read 4, write 2 and execute or search 1. Apply the minimal modes that fit the file, directory and intended identity. chown changes ownership.
  • Read active user and group identifiers with id. Administrative permissions depend on the host’s policy. For an approved local supplementary addition, the append option preserves other supplementary groups.
  • Identify the release. Ubuntu and Debian commonly use APT. Amazon Linux 2023 uses DNF. Query the installed state and candidate before an authorized change.
  • Processes: ps aux, top, kill. Help: man, --help. Editors: nano (easy), vim (i, Esc, :wq).

Got it? Navigation, files, permissions, users and packages – this is the daily work on a server. Now let's move on to the advanced commands – grep, awk, services and cron.

Hand over a verified release candidate

The morning student crew at Mauli Dairy prepared a pickup page and a small log excerpt. The next crew needs a candidate copy it can review, a count of the report requests that returned an error and a short explanation of how the files were checked. They should be able to repeat the checks themselves. Your job is to build that handover in a practice folder. The exercise connects directory navigation, file operations, reading, permissions, local identity, process checks, help and an optional edit. Each step produces evidence for the next decision.

Use Bash and a normal account with a writable directory under your home. The commands work on a typical Linux learning host. Several steps also work in a local macOS Bash session. The permission experiment relies on ordinary non-root access. If you are root, switch to a normal learning shell before doing it. The core lab makes no cloud resource, package, account or service changes. A learner who has no assigned EC2 instance can still complete the practical work and explain the Linux-specific examples from their printed outputs.

Use one shell for the lab so it keeps the path variable and can identify its own background process. If a step produces a different result from the expected one, pause on that step. Check the current path, object and error before proceeding. Your reviewer values a useful explanation of a failure more than an unverified claim that all commands succeeded. Keep a note outside the practice directory with the outputs and your interpretation. Then you can remove the generated fixtures without losing the work you want to keep.

The intended handover includes a visible current page and a preserved prior version, a small count derived from the log file, proof that the candidate can be reached under your account and notes on the optional editor exercise. In a real deployment there would also be a separate publication decision and a real application test. Here the word candidate refers to the sample files you prepared for review. No web server reads this directory. That makes it a safe place to practise small and reversible steps.

Work out the facts before using the terminal

Which common Linux directories hold configuration, logs and user material?

On many Linux systems /etc holds host configuration. /var/log is a common place for log files, but some services record messages through the journal or another destination. /home often holds ordinary users' home directories. An account can have a different home location. /usr/share frequently contains shareable data supplied by installed programs, such as documentation or other architecture-independent material. These names help orient you. The service's documented configuration and the actual paths on the host tell you what this machine uses.

Which practice paths are absolute and which are relative?

A path such as /home/asha/project/index.html starts at the filesystem root visible to the process. The path ./candidate/index.html starts from the current working directory. If the shell changes into another folder, the relative path can lead somewhere else or fail. A path such as ../candidate/index.html first asks to walk to the parent. Compare the actual current directory with the one the example assumes before using a relative file operation.

Translate rwxr-x---, rw-r--r-- and r-------- into numbers.

The results are 750, 644 and 400. In each group of three, add four for read, two for write and one for execute or search. For 750 the owner has all three, the group has read and execute or search, and the other class has none. For 644 the owner can read and write and the other two classes can read. For 400 only the owner has an ordinary read bit. The owner and group associated with the object determine which class matters for a particular process.

Which commands would install tree and git on two different practice systems?

On a suitable Ubuntu or Debian system the usual approved request is sudo apt install tree git. On Amazon Linux 2023 it is sudo dnf install tree git. This exercise only asks you to write and explain those commands. Before actually installing, confirm the OS and release, check the installed state and allowed candidate, and read the proposed transaction. If you already have the tools and need only to verify them, a query or a path check can answer the question without an installation.

What does a restrictive mode on an EC2 SSH private key protect?

When connecting from macOS or Linux, AWS shows use of mode 400 on the client-side private key so the owner can read it. SSH can refuse a private key file that is accessible to other users. The key stays on the client. Check the file path and ownership without printing the key. A key mode change is a local file permission action. If an SSH attempt instead reports a connection or account problem, use the corresponding instance and client evidence.

Create the practice inputs

The starting tree will contain a source directory, a candidate directory and an evidence directory. Source holds the new draft and sample pickup times. Candidate begins with yesterday's page so you can show what a replacement changes. Evidence starts as a folder for your extracted rows and a saved prior page. The content is small on purpose. You can recognize every entry and state exactly what should happen before running a command. Prepare this tree with the following block.

practice_lab=$(mktemp -d "$HOME/linux-practice-lesson.XXXXXXXX") &&
  cd -- "$practice_lab" &&
  mkdir -- source candidate evidence &&
  printf '%s\n' '<h1>Pickup times</h1>' '<p>Morning collection 06:45</p>' > ./source/index.html &&
  printf '%s\n' '<h1>Pickup times</h1>' '<p>Morning collection 06:30</p>' > ./candidate/index.html &&
  printf '%s\n' 'AM 06:45' 'PM 17:15' > './source/pickup times.txt' &&
  printf '%s\n' '08:00 report 200' '08:02 photo 503' '08:05 report 503' '08:07 report 200' > ./source/requests.log &&
  pwd && ls -ld -- ./source ./candidate ./evidence

Confirm the path is the unique directory the command just created. If the setup failed, inspect the first error and your current directory before using more relative paths. The paired commands run in sequence only while the previous ones succeed. Following the last printed path gives you a checkpoint. If you leave the shell and later return, take care that the folder variable belongs to your current shell before relying on it. You can find the directory by the actual path recorded in your practice note.

Read both index files and compare them. The intended difference is the morning collection time. The word index names a conventional example here. The file has two simple HTML elements, which contain headings and text for a browser if it is opened. The shell can read that same file as text. The report log contains four lines with a time, kind and status. The pickup times file contains only two specific records. State which file you are going to use for each question. This prevents a matching number in a different file from being mistaken for the result.

pwd
ls -l -- ./source/index.html ./candidate/index.html './source/pickup times.txt'
head -n 2 ./source/index.html
head -n 2 ./candidate/index.html
head -n 4 ./source/requests.log

The two page excerpts should show 06:45 and 06:30, respectively. If the same time appears twice, verify the names and the initial text. The long listing includes the fully supplied paths, which is useful when two different folders have an item with the same name. The space in the pickup file requires quoting as one argument. If you get an error about a shorter file name, inspect how the shell split it before changing any permission or generating a replacement.

Preserve the earlier page before staging the new one

Now prepare the review candidate. First copy the current candidate page into the evidence folder as a retained previous version. Then stage the new page under a fresh temporary name inside the candidate directory. Inspect the staged file before choosing to rename it. The retained name lets you prove which contents you started with. The staged name makes it possible to verify the proposed replacement before changing the destination. Use the following sequence only in the lab you checked. If either copy prompts unexpectedly, decline and inspect the existing file.

cp -i ./candidate/index.html ./evidence/index-before.html
cmp ./candidate/index.html ./evidence/index-before.html
cp -i ./source/index.html ./candidate/index-next.html
cmp ./source/index.html ./candidate/index-next.html
ls -l -- ./candidate/index.html ./candidate/index-next.html ./evidence/index-before.html

Both byte comparisons should report equality through status zero and normally no printed difference. The two files in candidate still represent different times. Before renaming, verify the time of each and the presence of the retained copy. The planned rename within this directory replaces the previous candidate entry. In this specific lab you already saved that entry's known contents. In another environment, check whether the destination is an existing file, directory or link and confirm the action with its owner. The options and behavior of a move can depend on the source and destination types.

mv -i ./candidate/index-next.html ./candidate/index.html
cmp ./source/index.html ./candidate/index.html
head -n 2 ./candidate/index.html
head -n 2 ./evidence/index-before.html
ls -l -- ./candidate

At the prompt approve the replacement only when it names the draft in this lab and your previous checks passed. The candidate should now match the new source page at 06:45. The evidence file should still show 06:30. The temporary name in candidate should be gone. If you decline the replacement, compare the observed tree with this predicted one and explain why the candidate retained the previous value. An interactive tool can finish without making a proposed change, so verify the result directly.

Use a diff to show the intended text change. An exit status of one is normally an indication of differences for diff. The expected change is the one pickup time line. If two files are equal and the candidate is supposed to differ from its before snapshot, investigate the input paths. If a necessary file could not be read, report the error instead of treating it as evidence of equality or a completed review.

if diff -u ./evidence/index-before.html ./candidate/index.html; then
  stage_diff_status=0
else
  stage_diff_status=$?
fi
printf 'Stage comparison status: %s\n' "$stage_diff_status"

Practice planning a reversal. If you needed the earlier version back, you would copy the retained 06:30 version to a new temporary name, compare it with the retained source and move it into the known candidate path as part of an approved reversal. Keep the newer original available separately. You can explain the reversal without performing another move in this exercise. A real deployment would have more verification, such as relevant file attributes, included dependencies and the application response. This small lab teaches you to identify and verify the recovery inputs before you need them.

Produce a scoped evidence extract and count

The handover asks for report requests that returned 503. The sample log stores one request per line with time, kind and status as its three fields. First view the lines so you can explain the filter. A direct search for status 503 will match both the photo and report observations. That is a useful control because you know the broad search gives more rows than the reviewer's question asks for. Use the correct two conditions for the extract and save it under a separate name.

grep -nF -- '503' ./source/requests.log
(
  set -o noclobber
  awk '$2 == "report" && $3 == "503" { print }' ./source/requests.log > ./evidence/report-errors.txt
)
cat -- ./evidence/report-errors.txt
wc -l ./source/requests.log ./evidence/report-errors.txt

The broad search should show lines two and three. The derived output should be only 08:05 report 503. The input should still contain four lines and the derived output should contain one. The small program passed to awk checks the second and third fields in each input record and prints rows where both match. It fits this fixture's space-delimited shape. A production log might quote fields, use JSON or have more complicated delimiters. Confirm its structure before using a simple field selector. A count of lines is appropriate here because we created one newline-terminated record for each request.

The subshell's no-clobber setting helps protect an already existing regular destination. If you ran this block once, a second attempt can report that the output file already exists. Inspect the earlier result. Decide whether you need a new output name for a later check rather than overwriting it by habit. Keep the log as input and the report evidence as its own file. If a command redirects to the same object it plans to read, the shell can truncate it before the program starts. Using a different reviewed destination is part of the task.

Check a deliberate no-match in the defined sample. There are no records of kind summary. Search for that known word in the kind position as represented by this simple data. Capture the command status immediately. Compare it with a future failed-read result only if you can do so on an isolated path you know is absent. Use the distinct return meanings from the search tool's documentation. A final count command can finish successfully on empty input, so you need search evidence before interpreting a count.

if grep -nF -- ' summary ' ./source/requests.log; then
  no_match_status=0
else
  no_match_status=$?
fi
printf 'Summary search status: %s\n' "$no_match_status"

The status should be one. The sample was readable and none of its four records contained that requested text. In the handover, say one report failure out of the four total fixture records, with the 08:05 row. You can also say there were three report rows overall if you independently count them. Do not claim a production incident rate from fictional evidence. Giving the correct denominator is another way to make your result reproducible and avoid overstating what the exercise measured.

Demonstrate a denied directory search and its recovery

Imagine the next person can see the candidate name but says the file cannot be opened. A read depends on both the text file's read permission and search on the directories along the path. Use two controlled before-and-after reads to prove one such failure. Only do this on your own lab and as a non-root account. Confirm the current directory is the lab and that you own candidate before changing its mode. The block saves no persistent special permissions. It sets known practice modes, removes owner search, observes the denial and puts the intended search bit back.

if [ "$(id -u)" -ne 0 ] && [ -n "$practice_lab" ] && [ "$(pwd -P)" = "$(cd -- "$practice_lab" && pwd -P)" ]; then
  if chmod 750 ./candidate && chmod 640 ./candidate/index.html &&
    ls -ld -- ./candidate ./candidate/index.html && chmod u-x ./candidate; then
    if head -n 1 ./candidate/index.html; then
      printf '%s\n' 'The read succeeded. Inspect the process identity and policy.'
    else
      printf '%s\n' 'The read failed with owner search removed.'
    fi
    chmod u+x ./candidate && head -n 1 ./candidate/index.html
  fi
fi

In the normal case the file still has owner read in both tests. The first file read after the directory change reports permission denied, and the second shows the heading once the search bit is restored. The last successful read should use the same path and account as the earlier failed operation. This ties the difference to the directory permission you changed. If it succeeds unexpectedly with search removed, restore the intended mode and inspect the active identity and additional access layers. An unusual fixture should not become an excuse to broaden access on an unrelated path.

Explain the numeric result to the reviewer. Directory 750 lets its owner list, traverse and change entries. It grants list and search to its group. File 640 lets its owner read and write, with group read. Your private temporary lab root can still prevent a second user from traversing the whole path. Showing the middle bits doesn't prove another account can read the candidate. The hypothetical next crew may need a deliberate group setup and a directory tree intended for sharing. For this exercise, verify only your own ordinary read. It is enough to teach which object the missing bit belonged to.

For an additional paper question, suppose the directory remains searchable for Asha but she has no directory write. She can still modify contents if the report file is writable. An editor that writes via a new file may need directory write as well. A same-directory rename or removal changes directory entries. That is why file write alone does not authorize a rename. Connect each imagined operation to the corresponding directory or file. This reasoning is more useful than learning one permission number for every website.

Inspect identity and software availability without changing the host

Your handover should mention the account used in the results. Run id and identify the user number and active groups. If you want two separate views, ask for id -Gn and then ask for the same command with your login name as an argument. A configured account change can show up in the named lookup while the existing session still holds earlier credentials. Explain which one applies to your actual commands. Avoid adding real users, altering group membership or granting administrator rights just to answer this question. The current process gives you enough evidence to describe the identity check.

whoami
id
practice_login=$(id -un)
id -Gn
id -Gn "$practice_login"
if [ -r /etc/os-release ]; then
  grep -E '^(ID|VERSION_ID|PRETTY_NAME)=' /etc/os-release
fi
command -v git
command -v tree

Run the final lookups separately if your shell stops on an absent command. Write the operating system and release where it is available, the process identity and any resolved utility paths. The absence of a path shows what the current shell could look up. It does not establish whether a distribution package exists under another name or whether a program is installed outside the search path. On Ubuntu you could query an expected installed package with dpkg-query. On AL2023 you can use rpm -q for installed status. The choice follows the distribution check.

Suppose the reviewer wants to know what would happen if the tree utility were installed. Check the permitted package source and the existing installed state before planning a change. A package candidate displayed by the manager is available information. It does not say the package is installed. If your environment does not support the example's package commands, record this limitation and explain how the query would differ on a learning Linux system. The handover works with the standard list commands already used above. You need no new package to deliver it.

Read a command's reference as part of the evidence. For Bash's cd use help cd. For a file listing command, check its local man page where available. Find the option that reports a directory as an object and describe it in your own words. This prevents copying an option from a different implementation. A missing manual is a reason to find the appropriate official reference for the installed command. It is also a fact you can record without having to change the system.

Collect a known background job's status

Sometimes a support reviewer asks how they know a command launched in the background has finished. Demonstrate the difference between an operating system process and a job tracked by your shell. Start a short sleep in the practice shell and immediately capture the process ID that Bash reports. Print it, request a targeted process snapshot and wait for that same child. The delay is intentionally small. If you type each line separately, the child may finish before the snapshot. You can still examine its status through the shell that started it.

sleep 5 &
practice_pid=$!
printf 'Started child: %s\n' "$practice_pid"
ps -p "$practice_pid" -o pid,ppid,user,stat,etime,comm
jobs -l
if wait "$practice_pid"; then
  practice_job_status=0
else
  practice_job_status=$?
fi
printf 'Child completion status: %s\n' "$practice_job_status"

A normal completion should print status zero. During the sleep, the process snapshot can show a sleeping task with your shell as its parent. The job list belongs to this shell and can show a running or already completed job depending on timing. The number printed after launch refers to this demonstration child. Looking up all processes named sleep would produce candidates from other activity as well. No signal is needed to finish this exercise. If a longer real task requires control, identify the authorized job or service and read its appropriate stopping procedure first.

The reviewer might ask how the evidence would differ if a process terminated due to a signal. The shell's status can provide more information than the fact that a PID disappears from a snapshot. Some implementations encode signal termination as a value above 128. Bash commonly reports 143 for termination by TERM with number 15. That is an interpretation of the shell's completion result, not a test to perform on an unrelated process. In real work you may need the service or program's own status and logs too.

Update your handover with one line describing the launched command, its own captured child and the eventual status. If you ran this on a separate Bash session, mention that relationship. The same PID might name other work much later. Keeping a timestamp and recorded relationship is a better diagnostic than writing a number without the launch context. For practice you can also time the sleep and explain why a process that spends several seconds waiting may consume very little CPU.

Prepare and verify an optional three-line note

The oncoming shift wants a plain text note alongside the page for review. Use a scratch note in the evidence directory. Decide the content before editing. We need three lines, one identifying the new candidate time, one stating that there is one report failure in the fixture and one giving the scope. There is no requirement to apply this note to a service. The reviewer compares the printed contents and line count. Create a matching note with the editor available on your learning machine. If you have both editors, practise on two different names and compare them.

nano ./evidence/handover-note.txt
vim ./evidence/handover-note.txt

Run one command for the name you intend to edit. In GNU nano default-style bindings, type the three lines, use Write Out, confirm the exact name and exit. Check the keys displayed by your version. In Vim, press the insert key, type the lines, press Escape and request a write and quit from Normal mode. Use the following exact sample text. Enter only the two line breaks between the three sentences. Typical text editor settings end the saved final line with a newline. Confirm the saved copy before adding any more line breaks. If a key produces text where you expected a command, check the mode and undo the unwanted edit before writing.

New pickup time 06:45
One report failure in sample
Scope four fictional requests
cat -- ./evidence/handover-note.txt
wc -l ./evidence/handover-note.txt
grep -nFx -- 'New pickup time 06:45' ./evidence/handover-note.txt

The printed note should contain exactly those three records and the search should find the first line. The line count proves the expected newline count in this sample. It does not by itself prove you typed the intended sentences. Check both. To test deletion of only buffer changes, open the note again, add an unwanted fourth line and exit without saving it. Read the same path from the shell. The three stored lines should remain. This practice helps when someone expects a discarded change to undo a separate file write that was already completed.

If your editor refused to write, read the exact status message and check the directory and destination with your own identity. The evidence directory is writable by your lab account. An entirely new note needs both directory search and write. A later save method can also depend on the editor's backup and replacement choices. Verify the work in this owned fixture rather than escalating an editor or changing a system path. If there is no installed editor, you may create the exact practice note with a known text command and explain the planned save and verification from the editor reference.

Rehearse three incomplete handovers

A handover is more useful when it prepares the next person for a surprising result. Work through three alternate outcomes while your fixture is still present. Each exercise asks for evidence that distinguishes similar-looking symptoms. These are practice branches. Keep the sample source, candidate and retained version you already verified. To repeat a branch that changes files, start from a separate new practice directory so its result can be compared with the first run.

The log query cannot open its input

Start with the known summary search result from the lab. It printed no matching record and returned one because its input was readable and no row matched. Now choose the exercise filename below, which the setup never creates. Check that it is absent in the evidence folder and use it as a deliberate failed input read. This is a harmless missing path test. If that file does exist on your machine, skip the block and explain the predicted error. The empty result tells a different story this time.

if [ ! -e ./evidence/absent-request-sample.log ] && [ ! -L ./evidence/absent-request-sample.log ]; then
  if grep -nF -- ' summary ' ./evidence/absent-request-sample.log; then
    missing_status=0
  else
    missing_status=$?
  fi
  printf 'Missing input status: %s\n' "$missing_status"
fi

The tool should print an error saying the input is absent. GNU grep returns two in this situation. Other implementations can use an error status larger than one. In a handover, place this apart from the earlier result of no matches. The evidence supports “could not verify the requested rows because this source did not exist.” The first result, from the readable sample, supports “no summary row was found in the observed four records.” A script that treats both empty outputs as a count of zero would erase this distinction. The documented status and the diagnostic message can preserve it.

The replacement prompt was declined

In a separate run of this lab, decline the move's named overwrite prompt. Then use the existing checks without making another change. The destination keeps the old content and the staged candidate name remains. The retained before copy still matches the old destination. Now you have a successful preparation and an incomplete replacement. Say precisely which transition did not happen. If the reviewer asks why the new file is visible while the destination is still old, explain the difference between the staging path and the selected name.

Use the relative directory listing and targeted comparisons to recreate the stages. If you intentionally decline the replacement, the later cleanup block expects no extra staged file and will stop when the candidate directory is not empty. List the remaining contents. If you choose to clear that extra practice artifact, remove only the known staged file and then resume empty-directory cleanup. The need to do this shows why a narrow cleanup can be an effective final check of your understanding of the actual tree.

The same read works for the person writing the handover

Suppose another student reads the named file successfully and concludes everyone can read it. Your own fixture demonstrates a smaller fact. You own the temporary lab root and it commonly permits only you to traverse it. Group read on the file cannot let a colleague through an inaccessible parent. List the root and the candidate directory modes and explain why your success is expected. Decide what a deliberately shared training path would need to provide to the intended group. Describe the required access rather than making a broad mode change to your home directory.

Wrap up the three branches with a brief sentence for each. Include the signal you would observe and the next action you would choose in the practice environment. The goal is to distinguish a missing source, an incomplete replacement and a mismatched access identity. Each can look like a single wrong value to a novice. Evidence for the command's path, status and actor makes their causes easier to separate.

For a written extension, prepare a four-row record for the expected handover. In the first row state the source and candidate names and which comparison established equality. In the second state the previous time and where you can find it. In the third state the number of matching log rows and what the status and input showed. In the fourth state the exact identity and folder change that the second access test established. Group the material by the reader's question. A reviewer should be able to verify the candidate without having to rerun every lab command. If they want proof of one fact, your note should lead them to the shortest check for it.

Grade the handover and remove the fixture

Review the state like someone taking over the next shift. The candidate index contains 06:45 and matches the source. The retained before snapshot contains 06:30. The evidence extract contains exactly the one report status row. The rejected access in the permission experiment was linked to the folder, and the restored read was verified for the same ordinary user. The process finished and its status was collected from the correct shell. The optional note, if created, contains the expected facts and a scope statement. This is the standard for the practice deliverable.

For a short handover, report the action and result without exposing unrelated files. State how you verified equality and which diff line changed. Include the criteria and total records for the log extract. If a tool was unavailable, say how far you verified with the tools present. If an observation was inconclusive, identify the next smallest check. A future reviewer can use this information to reproduce what mattered. Avoid substituting a statement such as “everything is good” for the scope of the exercise.

Before cleanup, confirm the shell is in your named lab. Read the listing and final process status. If you made the optional note, remove just that note after checking whether you want to retain a copy. If you declined the replacement or stopped early, list the actual remaining paths. The cleanup below assumes a completed candidate and extract. It is designed to stop on missing inputs or unexpected extra files rather than broaden scope with a recursive operation. Answer prompts only for the named samples.

pwd
ls -la -- ./source ./candidate ./evidence
if [ -n "$practice_lab" ] && [ "$(pwd -P)" = "$(cd -- "$practice_lab" && pwd -P)" ]; then
  if [ -f ./evidence/handover-note.txt ]; then
    rm -i -- ./evidence/handover-note.txt
  fi
  rm -i -- ./source/index.html './source/pickup times.txt' ./source/requests.log \
    ./candidate/index.html ./evidence/index-before.html ./evidence/report-errors.txt &&
    rmdir -- ./source ./candidate ./evidence &&
    cd -- "$HOME" &&
    rmdir -- "$practice_lab"
fi

If you kept the optional note, its directory cannot be removed until it is empty. An editor may have created a recovery or backup file. Inspect anything unfamiliar before removing it and check whether it has work you want to preserve. After clearing a remaining known file, remove only the intended empty folders. Your final prompt should show a location outside the exercise. Keep your written review in a separate folder so you can use it to explain the exercise later.

Explain your practical results as interview answers

How do you know the candidate copy, rather than its filename, is correct?

I compare the new candidate's bytes with the known source and review the diff against the retained before version. The copy has the new time and the previous version remains distinct. Existence of the candidate path alone could describe yesterday's file or a declined replacement.

Why does the broad log search have two results and your evidence file one?

The broad search found both photo and report records with the status text. The extract required both report kind and exact status in the known fields. It matched the single 08:05 report. I include the name and size of the fixture and the fields checked in my conclusion.

What exact change restored your read after the access denial?

I put the owner's search bit back on the candidate directory. The file kept its read permission. I used the same account and path on the failed and successful reads, which isolates the directory search change in this fixture.

Which evidence confirms the background sample ended normally?

The shell that launched the child collected its status with wait. Zero was the normal completion here. The process listing and job view also showed the relationship while it ran. A different process with the same command name would not provide that evidence.

How would you explain this lab as part of a real publication workflow?

It shows how to prepare, compare, validate and record a draft under a scoped identity. For a real service I still need the owner's publication procedure, complete backup inputs if needed, application validation and verified user-facing behavior. My lab establishes exactly what the named practice files contain.

Check your understanding

1. Your candidate index has the expected name. What proves its bytes match the new source?

A. The current directory string alone
B. A successful byte comparison of the two exact paths
C. The file extension

Answer and reasoning

B. Compare the known source with the actual candidate. A name or file listing can exist even when its contents are older.

2. The broad search prints a photo record and a report record. Which test isolates the report error?

A. Count everything containing the number 503.
B. Use a package status check.
C. Match the kind and status fields in the documented input.

Answer and reasoning

C. The question includes both properties. In the controlled input the exact fields distinguish it from the photo failure.

3. Which piece of evidence confirms completion of the practice sleep?

A. The exit status collected from the original child with wait
B. The existence of a package candidate
C. A process name found on another host

Answer and reasoning

A. The original shell can collect its child's status. The reported zero describes the normal completion of this controlled example.

4. Why does an empty-directory removal stop if you left a note inside?

A. The file must be made executable first.
B. The tool requires the directory to have no entries left to remove.
C. The operating system must be upgraded.

Answer and reasoning

B. This deliberate restriction protects unexpected entries from broad removal. Inspect the contents and choose whether to keep or remove the exact note.

5. Which observation supports the claim that an editor saved the correct note?

A. The cursor moved to another row.
B. The editor's screen showed a bigger line number.
C. A new read of the saved path shows the expected three lines.

Answer and reasoning

C. The shell read verifies persistent contents. The display before saving only describes the editor's working buffer.

Revision cards

Check the workspace

Confirm the shell, host, identity and directory before writing files. Paths and names may resolve differently in another session.

Copy, compare, replace and retest

Identify the prior version and candidate. Compare the staged bytes before replacing an entry. Verify the named result afterwards.

Read the log's actual fields

Align the filter with the kind, status and time you need. Keep source and output separate. Record no-match status independently.

Prove a permission theory

Observe the same access request before and after one scoped change. Directory search and file read answer separate parts of the request.

Capture the child you launched

Use the captured child and original shell's job list for this practice. Collect the result, then record what happened.

Clear only your fixture

Use explicit names and require empty directories. Keep results you want to share outside the working directory before cleanup.

Official references