Chapter 3: Linux Basic Commands
Common Mistakes I See Students Make
Friends, students almost always make these mistakes in their first week of Linux. Read them once – later, on the server, both your time and your data will be saved.
मित्रांनो, Linux च्या पहिल्या आठवड्यात स्टुडंट्स या चुका हमखास करतात. एकदा वाचून ठेवा – पुढे सर्व्हरवर तुमचा वेळ आणि डेटा दोन्ही वाचतील.
दोस्तों, Linux के पहले हफ़्ते में स्टूडेंट्स ये गलतियाँ पक्का करते हैं. एक बार पढ़कर रखो – आगे सर्वर पर आपका टाइम और डेटा दोनों बचेंगे.
- Using a different spelling from the name on disk. Most Linux filesystems distinguish upper and lower case. Verify the exact name in the environment you are using.
- Granting every mode bit when a read fails. Identify the user, action and resolved path. Check the parent directory search, the file read mode, and any additional access controls that apply.
- Using
usermod -Gwhen the request was to append a group. It can replace other supplementary memberships. Check the account before and after an approved change. A fresh session can be needed to see those memberships in use. - Running everything as root with
sudo -iand then creating files that the normal user or web server cannot edit. - Choosing a package tool before identifying the release. Read
/etc/os-release. Ubuntu uses APT. Amazon Linux 2023 uses DNF. - Entering a Vim command in Insert mode. Press Escape to return to Normal mode. Choose whether to write or discard changes based on the buffer. An earlier successful save remains on disk.
rm -rfwith a wrong path. There is no recycle bin — read the command twice before pressing Enter.
Check the first failure
- Identify the host, user and shell location. Confirm whether the expected path refers to a link, a directory or a regular file.
- Read the first diagnostic and the relevant command's documented status. Make a small test that distinguishes the plausible explanations.
- Record file contents and access before a change. Choose one scoped action and repeat the same check after it.
The worked troubleshooting exercise below gives you two releases, a report copy and a small log to examine using this sequence.
Pause on the first unexpected result
Asha is preparing the dairy's collection timetable. She has a yesterday copy for comparison and a today copy ready for review. A teammate opens the report and still sees yesterday's pickup time. In a hurry, the trainee tries a different folder, copies a file with a similar name, broadens permissions and restarts a process. When the issue remains, nobody knows which of those steps changed the situation. This is an ordinary beginner problem. The first confusing result starts a chain of guesses.
There is a better way to work through the same ticket. Read the request and the output you already have. Write down what you thought the command would do and the exact result it gave. Identify which host and account ran it, which path it used and what operation it attempted. Then make the smallest observation that can prove one explanation. If you do make a change, verify that particular effect before choosing a second action. This preserves the evidence a teammate needs if your first explanation turns out to be wrong.
The exercises below use a fictional timetable, a private temporary directory and one shell. They cover path mistakes, mistaken copies, misleading empty searches, file access, process ownership and confused edits. You can repeat all the lab actions locally in Bash using an ordinary account. The permissions demonstration expects a non-root shell. Each mistake has a predictable symptom, a small check and a way to explain the result. Advanced services do not appear in the fixture. We will mention them when it helps explain why a successful local check does not by itself repair a live application.
Keep a simple record as you go. For each result, note the command, resolved path or selected process, status and visible evidence. Add what you expect to see next. The record does not have to be long. “Old file contains 06:30, today file contains 06:45, read old path from current link” is already more actionable than “update failed.” It gives a peer the exact question to reproduce. A read-only check on a disposable fixture is a useful habit to build before a learner touches a shared server.
Set up two releases that can be told apart
Put files with the same name in two different release directories. The contents deliberately differ. The directory names make it easy to tell which release contains which version. We also prepare a separate review directory for practice copies and a small request log. Create your own new directory under your home. The later change and cleanup steps apply to this directory only. If you cannot create it, stop and use the example outputs instead.
mistake_lab=$(mktemp -d "$HOME/linux-mistakes-lesson.XXXXXXXX") &&
cd -- "$mistake_lab" &&
mkdir -p -- ./release/old ./release/today ./review &&
printf '%s\n' 'Collection starts at 06:30.' > './release/old/pickup report.txt' &&
printf '%s\n' 'Collection starts at 06:45.' > './release/today/pickup report.txt' &&
printf '%s\n' 'kind=report status=200' 'kind=photo status=503' 'kind=report status=200' > ./requests.log &&
ln -s release/old ./current &&
pwd && ls -ld -- ./current ./release/old ./release/today ./review
The first command creates a directory with a randomly chosen suffix. The following steps run only if that command and the change into the directory succeed. Read the printed path and make sure it matches the newly created lab. The link named current is a symbolic link, a filesystem object that refers to another path. It starts by pointing to the previous release. Its target release/old is relative to the directory containing the link. We will observe that relationship. You do not need to update the link to understand the difference between the candidate and the currently selected version.
cat -- './current/pickup report.txt'
cat -- './release/today/pickup report.txt'
ls -ld -- ./current
(cd -- ./current && pwd -P)
The first read should show 06:30. The second shows 06:45. The link listing shows its direction, while the final line prints the physical directory reached by following it. The parentheses run the navigation in a separate shell context so your surrounding shell stays in the lab root. This makes the next listed commands use the paths we intend. If they show two identical collection times, check the fixture setup and your working directory before interpreting anything about a release.
Check where the command ran before repairing the file
Linux commonly distinguishes upper and lower case in names on its filesystems. The directory called home is normally a different name from Home. Some filesystems or configurations perform case-insensitive lookups, which is why a typo can appear to work on a learner's laptop and fail on the Linux host. Always use the exact name you see in the target environment. Completion and a directory listing can show the characters the shell or filesystem sees.
A path beginning with a slash is an absolute path in the current process's filesystem context. A relative path starts from the process's working directory. A name beginning with a tilde has shell expansion behavior, such as referring to the current user's home when used in an appropriate position. If the expected file is missing, ask whether the path is relative, whether the previous directory change succeeded and whether you are in the right shell. In SSH work, the local computer and the connected host both have a current directory and a home directory. The visible prompt is customizable, so it can be a useful hint without being the whole check.
In the lab, the command cd ./release/today from its root moves you to the newer candidate. After changing into the link ./current, normal shell navigation can retain the link's spelling as a logical path. The physical view from pwd -P can show the resolved target. Check both when the two paths matter. A relative command that seems correct while you picture today's folder may be operating in yesterday's folder. On a shared deployment the link can change, so record which path was selected when you observed the issue.
A failed cd usually leaves the shell in its previous directory. A separate command on the next line can still run. If the next command writes, copies or removes a file, this creates the common wrong-directory mistake. Connect dependent steps with a success check, such as a suitable conditional or &&, and verify the working directory before changing data. The training setup prints that path only after all its preceding dependent creation steps complete. The lesson uses the printed path as a deliberate checkpoint.
Space handling is another part of selecting the exact name. The sample report has a space. Without quotes, the shell can split a typed name into separate arguments before the command receives them. Quotes or appropriate completion preserve the intended path. Putting a path into a variable does not automatically protect its later expansion in Bash. Use quotes at the point where you pass the variable. In a lab, inspect one full path with a long listing or a read before applying a change. That confirms the same object you will use in the next step.
Verify the destination before and after copying
Students often say they copied the release and already see a file named report in the review area. A matching name gives limited evidence. An unrelated copy can have the same name and the previous text. Write the source and the exact destination before running the copy. If the destination already exists, determine whether the plan is to keep, compare or replace that version. When you pass an existing directory as the destination to a normal copying command, it can place the source under that directory using the source name. Passing a new specific file path requests the different name you typed.
cp -i './release/today/pickup report.txt' './review/pickup review.txt'
ls -l -- './release/today/pickup report.txt' './review/pickup review.txt'
cmp './release/today/pickup report.txt' './review/pickup review.txt'
Confirm the source and destination are the separate files you intended. The interactive option lets the tool ask before replacing an existing file. In a fresh fixture the target name should be new and the command should finish without a prompt. If it asks to overwrite in this exercise, decline and inspect the previous copy first. The comparison normally prints nothing and succeeds if the bytes match. Re-read the intended time from the copy if you want to attach it directly to your practice note. A file presence check and a content check answer different questions.
File attributes are yet another part of the check. Two files can have the same text and different mode, user, group or timestamps. If a service expected the older ownership or permission settings, replacing a file can change what it can open even though the new text looks fine. A real backup should preserve the required data and attributes, have a known source revision and be testable under the owner's restore procedure. Our temporary exercise only needs to prove the input data and copy are exactly equal. It is intentionally smaller than a live deployment.
For a cleanup task, use an explicit target and verify its path. Ordinary shell removal bypasses a desktop trash workflow unless you intentionally use a separate tool that provides one. A recursive command can reach many objects at once. The later cleanup uses interactive removal of named scratch files and asks the filesystem to remove only empty directories. That lets an unexpected file stop the process. This is often a better beginner habit than starting with a recursive force operation for a directory whose contents and ownership are not confirmed.
Distinguish no match from a failed read
Our small request log has two records for the report and one for a photo. A learner searches for the text 503 and correctly finds one line. They then report that the timetable returned that status. That conclusion ignores the line's kind field. The photo was the request with that status in this fixture. See how easy it is for an accurate search to answer an incomplete question. First read a few records and understand their layout. Choose the field or literal text pattern that represents the requested operation.
head -n 3 ./requests.log
grep -nF -- 'status=503' ./requests.log
if grep -nF -- 'kind=report status=503' ./requests.log; then
search_status=0
else
search_status=$?
fi
printf 'Report error search status: %s\n' "$search_status"
The first search should print the photo row at line two. The second should print no matching rows and store status one. In the fixture, fields always occur in the chosen order with a space between them, so the fixed two-field text is a suitable small test. A real log format may have other order, fields and delimiters. Some contain a quoted field with spaces inside it. Choose a parser appropriate to that format before counting. Our test demonstrates why your filter must match the report's question as well as the input's structure.
Capture an exit status immediately. If you print a label before reading the earlier result, you will read the status from the printing command instead. A pipeline can also complicate the interpretation. For example, the last command in a normal Bash pipeline can receive an empty input and finish successfully, while the search before it found no match or could not read a file. You can inspect components separately while learning. If you are writing a script, read Bash's pipeline status behavior and the individual command's documented return meanings. Then test a true match, a known no-match and a deliberate missing input in a disposable directory.
If the error search produced no output, ask what else would need to be true for a useful conclusion. We need the correct host and input path, a log covering the relevant time, and a successful file read. We also need the filter to correspond to the report's kind and status. A zero count from the wrong file tells you very little. State the scope with the result. “No matching report 503 in this three-record fixture” is exactly what the program did and leaves the real service diagnosis open until real evidence is available.
Notice when the shell changes an output file first
A common data loss mistake starts with a sensible filter. A learner reads a report, searches within it and wants to save the matching lines. Then they choose the same path for both input and output. In an ordinary redirection using a single greater-than sign, the shell opens the destination for output before the tool reads its input. If the destination is the same existing file, it can truncate the file at that moment. The search may receive an empty input and produce an empty output. The unexpected result came from when the shell opened the destination, rather than from the filter's text matching.
Instead, use a separate reviewed destination when producing derived output, and keep the original available for a check. In our fixture we can make another text path in the review area that is distinct from the original log. Make sure it is a new name first. A protective shell option can help refuse overwriting an existing file in this small example. The surrounding parentheses keep that setting local to the subshell.
(
set -o noclobber
grep -F -- 'kind=report ' ./requests.log > ./review/report-rows.txt
)
wc -l ./requests.log ./review/report-rows.txt
With a fresh output name, the input log should still contain three lines and the derived file should contain two. If you already ran the block, the shell may refuse to use the existing regular output file under the option we enabled. This is a useful signal to inspect that prior result instead of silently overwriting it. Use the shell's exact documentation for exceptions and available redirection forms. The main habit is to know which input and output each command opens before you paste it into a real terminal.
Now apply the reasoning to a report editor. A saved edit can already replace a file when you exit without saving a later buffer change. A redirection can already change an output path before a later command errors. Returning to the prompt does not undo either of those earlier effects. Verify the exact files that could have changed before trying something else. In the lab you can compare copies or recreate the known sample. In a shared service follow the recovery process using the known backup or source revision. A prompt confirms that the shell is ready to accept work. It does not report that everything behind it returned to the original state.
Diagnose an access error under the right identity
A failure to read the review copy is not automatically a wrong file mode. The process must find the path and have search permission on the folders along it. Then it needs read access on the file, according to its own credentials and other policy. A common mistake is to test with an administrator shell and use that success as evidence that the website worker can read the file. A process under a more powerful identity can pass a check that the intended process still fails. Determine who performed the failing operation and what they attempted.
Use the lab to create a specific difference. The original report remains readable and the review copy is in the intended location. Remove the owner's search bit from the review folder to make the normal unprivileged open refuse to reach the file. Then restore it. Before running the commands verify you are in the unique lab and working under your normal account. This test should give you a denial and then a successful read without changing the file's mode or contents.
if [ "$(id -u)" -ne 0 ] && [ -n "$mistake_lab" ] && [ "$(pwd -P)" = "$(cd -- "$mistake_lab" && pwd -P)" ]; then
ls -ld -- ./review './review/pickup review.txt'
if chmod u-x ./review; then
if cat -- './review/pickup review.txt'; then
printf '%s\n' 'The read succeeded. Check the active identity and policy.'
else
printf '%s\n' 'The read failed while parent search was removed.'
fi
chmod u+x ./review && cat -- './review/pickup review.txt'
fi
fi
The first read should fail at path search and the restored read should show the newer time. If the experiment reported an unexpected result, restore the search bit on the intended practice directory and check the identity and ownership. In the ordinary scenario, granting extra access to the file inside the inaccessible folder would fail to repair the missing search bit. A file-level change alone cannot apply to its parent directory. A live service may also have an access control list, a security label or a different service policy. Check those when the observed identity and normal mode checks predict a result you do not see.
Group membership changes have a separate beginner trap. A named lookup can show that a user was added to a team while an older process still has the groups it received when it started. Compare active and configured memberships using the appropriate form of id. For a planned local account addition, the append option used with supplementary groups preserves memberships that should remain. Replacing the list can remove other supplementary roles. Pick a fresh authorized session for the retest. Avoid altering an administrator group when the intended job is only reading a timetable.
Check a copied command before it reaches the shell
A printed example can include things you should not type. A leading dollar sign may represent the terminal prompt. A following line can be example output. A long printed line may wrap at the edge of a browser or terminal without forming a second command. Quotes copied from formatted text can be a different character from the straight quotes Bash expects. A dash before an option has to be the character the utility uses. These details look small on screen. They decide what the shell parses and often explain an error before any file operation begins.
Suppose the handover note contains a command and its expected output below it. A trainee pastes both lines. After the first succeeds, the shell reads the expected output as another command. The second error can make them believe the first one failed too. Run one intention at a time and attach each response to the command that produced it. Inspect the terminal history as text if you need to reconstruct what ran. Avoid replaying an earlier command until you have checked its path, options and effects in the current session. A previously valid command can become dangerous in a different directory.
Use the existing sample file to see the argument boundaries without writing anything. The first line below prints each supplied argument inside angle markers. The second line gives the same print format an unquoted report name with a space. Notice that the formatting command repeats its format for the separate arguments. This is a safe way to model what another tool might receive, even when its own error message does not show the argument split.
printf '<%s>\n' './review/pickup review.txt'
printf '<%s>\n' ./review/pickup review.txt
The first command prints one line showing the whole name. The second prints two lines, one for the partial path and one for the second word. Now imagine passing those tokens to a copy command. The extra argument can change which operand the tool treats as destination. Fix the argument in the shell before reasoning about permissions or the application's file format. A literal path can be protected by quoting it. When using a variable expansion, double quotes let the value be substituted while preserving it as one argument in the ordinary case.
Practice another read-only reasoning task. A wildcard is normally expanded by the shell before an external command starts. A pattern in an accidental current directory can select a different set of files. Hidden files may be omitted depending on the pattern and shell settings. A literal asterisk intended for grep is different from a file wildcard intended for shell expansion. Check the active directory and choose the intended kind of pattern. If you are preparing a selection for a file operation, run a harmless inspection of the exact selected entries and consider how an empty match behaves in your shell. Do not assume a command with a wildcard always selects the same number of paths.
Preserve the before version and test the recovery you actually need
The next mistake is assuming the original can always be retrieved later. A copy whose destination already exists can overwrite it. An editor can save into the wrong path. A redirection can truncate an input. The recovery you need depends on what the operation changed. The first questions are which exact object was affected and whether a verified previous version exists. Do not immediately make additional changes to related files while trying to guess. Record the observed contents and metadata, then use the appropriate recovery source under the owner of the data.
In our lab we can check the source of a previous version explicitly. The old release has the named report with the earlier pickup time. The new release has the approved sample change. A trainee who wants to restore today's contents to the review copy should first compare today's known source with the candidate they intend to use. A trainee who wants to roll back the whole selected release needs to understand the link or deployment configuration and what else it selects. Those are different recovery requests. One file difference does not establish that an entire restore is complete.
A file-level backup can have requirements beyond the bytes themselves. A program may need a particular user or group owner, a mode, a related config include file or a security label. Some filesystem copy commands can preserve selected attributes with appropriate options and permissions. Others only give you a data copy with newly created attributes. Always read the tool documentation and verify the required properties. A retained filename ending in .bak does not describe which version it contains. Identify the revision and confirm what it can restore. An empty or overwritten copy offers no recovery evidence just because the name looks familiar.
In the learning lab, the earlier cmp gives a byte comparison for one file. You can read the time and compare the old and new versions with a diff. The expected difference is only the pickup time. For a real recovery, verify the restored service through an authorized operation after the files are in place. A correct local file, readable at the expected path, is an essential observation for our story. A visitor can still be directed to a different release or return a cached result. Decide what success means at the user's point of view and record the request you used to test it.
One good recovery note includes the actual affected path, the chosen prior revision, the expected ownership and mode, how you compared the contents and the result of verifying the reader. It is also useful to note operations you already observed so a teammate can avoid repeating a change. In practice, a short evidence chain can explain why no restore was needed at all. In our report problem the current link pointed elsewhere while the candidate and its review copy were already correct. The evidence lets the maintainer choose the smallest real change.
Check what the command would change before calling it a fix
When a command reports that an option is unknown, installing a package can sound like a quick solution. First identify the distribution and the command actually executing. Ubuntu commonly uses APT and Amazon Linux 2023 uses DNF. A YUM command found in a previous lesson or a guide may refer to a different release. An installed tool can reject a newer option. A package source can have no matching candidate under its configured repositories. Compare those observations before planning an install or an upgrade. Refreshing package metadata and upgrading packages are separate operations.
Read-only commands can show you an application's program path and a live instance of it. A successful command lookup means the shell can resolve something by that name. It does not say whether a service started it. A list of processes matching a name can include unrelated work. If a student launches a demonstration sleep, save the exact child ID when the shell starts it and track it in that shell. On a managed service use the service owner's procedure and latest instance evidence. A broad signal or an unconditional restart can affect work outside the ticket.
A similar mistake happens when a learner opens a real configuration in an editor to “just take a look.” Some editors place a writable buffer under the same filename. If the intended action is reading, choose a viewer or a supported read-only interface. If the intended action is editing, confirm the exact file and prepare a verified before version first. In Vim, use Escape to return from Insert mode before you enter a command. Decide whether to write or discard any unsaved changes. If you saved earlier, discarding a later edit leaves that earlier write on disk. An editor's display and an application's loaded state are also different evidence.
Before a command that changes a shared machine, say aloud what it touches and what proves the goal. For example, “The authorized step changes the report's named draft path. I will compare that file against the approved revision and verify the published request after deployment.” If your explanation starts without a path, account or affected resource, collect that detail first. If you cannot state what output or status should look like, test in a representative non-production fixture. That can reveal a mistaken option before it changes the actual service.
Retest one theory and keep useful evidence
In our main exercise, which observation explains the stale time? The current link resolves to the old directory and the old path contains 06:30. The candidate today path and the review copy both contain 06:45. The comparison can prove that the review copy matches today. We do not need to change file modes or remove the old release to reach that conclusion. In a real rollout a separate approved publication step may change which release is selected. If the source or configuration is not yours to alter, the useful next deliverable is the evidence for the maintainer.
Read this sample note and see which details make it reproducible. “At the time of review, the current link resolved to release old. Opening the timetable through that path returned 06:30. Reading the today candidate returned 06:45, and the review copy matched it. The review log contained one photo error, with no report error in the sample. The report source is correct for today, and the selected path still serves the old time.” The report scopes each claim to the observation. It does not promise that changing a link will fix every possible visitor route without an application test.
Practise writing a second note for the access experiment. State which directory you temporarily changed, which identity ran the read and why its exact response changed after restoration. Include the long listing from before if relevant. Next compare your note with the redirection problem. One is a denial before the target could be opened. The other is a destination change that happens before the search runs. Both may produce a file that appears empty or inaccessible to a novice. The sequence of operations helps you distinguish the cause.
Write one follow-up question for yourself that you can answer with a harmless change to the fixture. For example, make a new log line for a report request with another status and predict whether each search would match. Or select only the newer path and repeat the expected time check without using the symlink. If you create another practice file, keep its exact name for cleanup. Each exercise is useful when it tests one hypothesis and teaches why the output is evidence for it.
Clear the recorded fixture and leave other files available
Before cleanup, list the lab's directories and the link. Confirm the review directory has its owner search bit restored. The block below names every normal fixture entry and checks that you are still in the unique lab. The link is removed by its own name. Its target is addressed separately as a known exercise directory, so the object relationship remains explicit. If you ran only some of the exercise, an absent file may cause this combined block to stop. Inspect the exact resulting tree before continuing with any remainder.
pwd
ls -la -- ./release/old ./release/today ./review
ls -ld -- ./current
if [ -n "$mistake_lab" ] && [ "$(pwd -P)" = "$(cd -- "$mistake_lab" && pwd -P)" ]; then
rm -i -- './release/old/pickup report.txt' './release/today/pickup report.txt' \
'./review/pickup review.txt' ./review/report-rows.txt ./requests.log ./current &&
rmdir -- ./release/old ./release/today ./release ./review &&
cd -- "$HOME" &&
rmdir -- "$mistake_lab"
fi
Answer the prompts only for the entries you identified. The removal of each directory requires it to be empty. If you created a further test file and want to retain it, the directory can stay. If you decide to clear it, check the file name and its contents first. When cleanup completes, the shell is in your home directory and the temporary lab path is gone. Keep any written practice notes somewhere you chose outside the folder before you remove the fixture.
Interview questions with worked answers
The same file name has different contents in two terminal windows. Where do you look first?
I check the machine, account and working directory in both windows. If a path contains a symlink, compare its resolved target. Then read both exact files and compare them. In the report lab the current link pointed to the older release. Reading through the link and opening the candidate path legitimately produce different values.
Why can a copied file exist while still being the wrong version?
A name and presence check do not identify the source bytes. I confirm both source and destination and compare their contents. If the target existed before, I check whether the copy actually replaced it. I also confirm the path a reader uses. A review copy can be correct while the active release still points somewhere else.
When does an empty search output mean there were genuinely no matches?
It is meaningful when the intended readable input was scanned, the filter represents the question and the tool returned its documented no-match status. I capture that status immediately and preserve relevant diagnostic text. I include the input time window and path in the conclusion so a later reader knows what the search covered.
How can a file become empty even though the reader command did not run successfully?
The shell opens output destinations for redirection and can truncate an existing file before it launches a command. If the path was also the input, the data can already be gone. I would stop, preserve evidence and use a verified recovery source. For normal derived output I use a separately reviewed destination and compare the result.
How do you know a permission change actually solved the intended problem?
I identify the account, operation and path from the failure. I repeat the same authorized operation after the smallest relevant change. Reading with a different more powerful account would show a different check. In our lab restoring search on the parent made the original file read succeed with no change to the file.
Check your understanding
1. Your directory change reports a failure. What is the next useful action before a file edit?
A. Open the familiar filename from wherever the shell is.
B. Check the working directory and resolve the intended path.
C. Upgrade all system packages.
Answer and reasoning
B. A failed directory change can leave the old location active. Verify the real path before running an operation that changes files.
2. A generic search finds a 503 photo record. What does this prove about report requests?
A. The report returned the same status.
B. The report has no error anywhere.
C. The photo record matched. Search the relevant report records separately.
Answer and reasoning
C. The request kind is part of the evidence. Keep the input, time and condition in your result.
3. The review copy has readable file permissions, but an ordinary user cannot get through its parent. What should you check?
A. Directory search along the resolved path for that identity.
B. The filename's modification time only.
C. A more powerful user's successful read.
Answer and reasoning
A. The kernel needs to reach the target before it can apply its file permissions. Look at the path and the identity that failed.
4. Which output target best protects your original when testing a filter?
A. The existing source path.
B. A separate, reviewed lab output path.
C. Whatever file the shell expands first.
Answer and reasoning
B. A separate target avoids truncating the input by opening it for output. Compare the source and the resulting data afterward.
5. Why might an old shell still lack a newly approved supplementary group?
A. It keeps the process credentials it started with.
B. File read permission changes the user's account name.
C. Every update to a group requires a new package manager.
Answer and reasoning
A. Compare the named lookup with the actual process's group list. Establish a new authorized session to verify the intended membership.
Revision cards
Read the first error
Identify the step that failed before changing another part of the system. Preserve the exact path, action and output.
Verify which file a name resolves to
Check the host, account, working directory and full name. A symbolic link or different directory can select another release.
Evidence has a scope
Check the actual input and the documented result. A search for a status on one route cannot report every other route's behavior.
Output is a file operation
A shell can open or truncate a destination before starting the command. Choose a separate known output path and inspect the effect.
Use the intended identity
Check directory traversal and file modes as the user or service that needs access. Record whether the group is active in its process.
Retest one change
Compare before and after with the same authorized operation. Preserve the confirmed scope for a later teammate.
Official references
- Bash command status, quoting, paths and redirection
- Linux pathname lookup and directory search
- GNU copy behavior and interactive replacement
- Linux file open and truncation behavior
- GNU grep search modes and exit status
- Linux process user and group credentials
- Shadow-utils supplementary group changes
- Amazon Linux package management by release
- Vim writing, buffers and quitting