Synopsis
Keep the course files in a directory named unix-practice under the account’s home directory. Use an ordinary account and the /bin/sh session from A first shell session. The following exercises use the names notes and copies inside the practice directory.
Make a place to work
Create the practice directory.
mkdir "$HOME/unix-practice"A successful mkdir normally prints nothing. If the directory already exists from an earlier lesson, keep it. If the name belongs to unrelated work, use a fresh practice account. Enter the directory and check the resulting path.
cd "$HOME/unix-practice"
pwdThe path should end in /unix-practice. If cd reports an error, the shell stays in the previous directory. Correct the path before creating any files.
Create the two subdirectories and list them.
mkdir -p notes copies
lsLook for copies and notes. The -p option permits either directory to exist already.
Follow relative paths
Change into notes, then inspect its location.
cd notes
pwdThe path now ends in /unix-practice/notes. A name beginning with / is an absolute path. A relative path, such as notes, starts at the current directory. A single dot names the current directory. Two dots name its parent.
Return to the practice directory.
cd ..
pwdThe final component should again be unix-practice. From any other directory, cd "$HOME/unix-practice" returns directly to the same place.
Copy a name containing a space
Use a disposable field note for this exercise. List the two directories before creating the file.
ls notes copiesThe next command replaces any previous practice copy of notes/field notes.txt. The shell opens that destination for output when it reads >. Single quotes preserve the space in the filename.
printf '%s\n' 'north meadow' > 'notes/field notes.txt'Copy the note into copies. The trailing slash names the destination directory. Start with an empty copies directory, or confirm that its existing practice copies may be replaced.
cp 'notes/field notes.txt' copies/
ls copiesLook for field notes.txt. Rename the copy and list both names with a wildcard.
mv 'copies/field notes.txt' copies/meadow.txt
ls notes/*.txt copies/*.txtThe result includes notes/field notes.txt and copies/meadow.txt. The shell expands each unquoted * to matching names before it runs ls. A space inside a matching filename stays part of that filename. The quoted path in the cp command names one file explicitly.
Remove only the copy
Confirm the target before removing it.
ls -l copies/meadow.txtCheck that the path names the copy. Remove that single file and list what remains in each directory.
rm copies/meadow.txt
ls copies
ls notesThe first listing should be empty after a fresh run. The second should still contain field notes.txt. The rm command removes the named entry without moving it to a desktop trash folder. If the wrong practice copy disappears, recreate it from the surviving note.
Continue with Read, edit, and find text.