Make a Change You Can Explain
A service setting is often just text in a file. Before automating changes, you need to know which file you are reading, what a command changes and where its output goes. We will make a small release-note configuration, keep an original, and extract one setting. No application reads it yet.
Resume the named guest from the workspace lesson.
Use Bash as ubuntu, not root. All commands below run inside that guest.
Run each line and inspect it before continuing. No downloads or new services
are needed. From any guest directory:
cd "$HOME/vecta-devops"
pwd -P
mkdir file-practice
cd file-practice
The physical parent must be /home/ubuntu/vecta-devops. Stop if cd fails or
the path differs. file-practice is a new child, not another home directory.
If it already exists, inspect your earlier work with ls -la file-practice
from the parent; do not recreate or overwrite it. To resume, enter that known
directory and continue at the first missing output. -a includes hidden names;
-l gives details. Hidden does not mean encrypted or protected.
Names Point Somewhere
original.conf is a relative path, interpreted from the current directory.
/home/ubuntu/vecta-devops/file-practice/original.conf is an absolute path.
Both can name the same file. .. refers to the parent directory, so
../file-practice/original.conf also works here. A new terminal does not inherit
this terminal's location. Use pwd -P before reasoning about relative names.
The suffix .conf is a naming convention, not a special file type. The contents
and the program reading them determine their meaning. We choose three plain
name=value lines. They are synthetic data, not shell instructions to execute.
printf '%s\n' 'service=release-board' 'environment=practice' 'port=8800' > original.conf
cat original.conf
cp -i original.conf working.conf
printf prints each supplied value followed by a newline. Single quotes keep
the values literal. Bash handles >: it creates the target, or empties an
existing target before writing. Run that creation only when original.conf
does not exist. cat reads it back. cp copies it; -i asks before overwriting
an existing destination. Answer n if you encounter earlier work unexpectedly.
Copying is not version control, but it gives this small exercise an original
to compare against. Neither file should contain credentials.
Output Is Not Always a File
Commands normally send results to standard output and diagnostics to standard error. Both often appear in the terminal, which can hide their different purposes. Standard input is the stream a command can read.

Read left to right: source file, matching lines, count. The separate diagnostic branch explains why a visible error is not itself a matched configuration line.
grep -n '^port=' working.conf
grep '^port=' working.conf | wc -l
grep selects matching lines. ^ anchors the pattern to the start, so a
comment containing port= elsewhere does not count. Quotes stop the shell
interpreting the pattern first. -n adds the line number: expect 3:port=8800.
The pipe, |, connects grep's standard output to the next command's
standard input. wc -l counts newline-terminated lines, so the second result
should be 1, not the number of characters or the port value.
The pipe does not edit working.conf. By default it does not carry grep's error
stream either. If a missing file produces an error and wc prints 0, that
does not prove the configuration has no port. Inspect the earlier diagnostic.
We will teach explicit pipeline failure handling in the scripting lessons.
Change the Copy, Not the Evidence
Append one harmless setting to your owned working copy, then compare:
printf '%s\n' 'log_level=info' >> working.conf
cat working.conf
wc -l original.conf working.conf
>> appends instead of replacing. Expect three lines in the original and four
in the copy. Rerunning the append creates a duplicate; it is not an update that
finds and replaces a key. If you already appended it, do not repeat that step.
Open the working file in a guest text editor you have available to inspect a
mistake, or keep it and create a differently named fresh copy of the original.
Do not edit host files by confusing an editor's host and guest locations.
Capture a single setting in a separate new file:
grep '^port=' working.conf > port-selection.txt
cat port-selection.txt
The output file should contain port=8800. The reader and writer must not be
the same file: redirecting a command back into its own input can truncate the
input before it is read. The current command reads working.conf and writes
port-selection.txt, deliberately distinct names. Inspect that output name
before rerunning because > replaces it.
When a Result Surprises You
| Symptom | First useful check |
|---|---|
| No such file | pwd -P and ls -la; check spelling, case and the current directory. |
| Permission denied | Recheck guest user and owner with id -un and ls -l; do not add sudo. |
| No matches | Check the actual file with cat; an anchored pattern and a substring are different questions. |
| Five lines in the copy | Look for a repeated append rather than assuming the original changed. |
| Original unexpectedly empty | Stop writes. Look for a mistaken redirection target; reconstruct only this synthetic fixture, not real missing data. |
To leave, retain the three small files as evidence and use the workspace pause
procedure. There is no background process here. Optional cleanup, only inside
your verified file-practice directory after inspecting its contents, removes
these named exercise files, not the whole workspace:
rm -i port-selection.txt working.conf original.conf
cd ..
rmdir file-practice
rm -i asks before each file removal; confirm only these disposable outputs.
rmdir refuses if another file remains. Inspect the remainder rather than
adding a recursive force-delete flag.
Try a Different Question
Without modifying the original, find the environment line in the working copy.
Explain whether a pipe to wc -l returns the environment value or a count.
Then predict what happens if the append step is run twice.
Answer and Reasoning
Use grep '^environment=' working.conf to select environment=practice.
Piping that output to wc -l yields one matching line, not the word practice.
Two appends produce two log_level=info lines, making five lines in the copy;
the original still has three. An append has no knowledge of configuration keys.
Next we will distinguish file ownership from the identity of a running process.