Skip to content

Day 3 Lab Workbook: Registration, File Commands, and the Filesystem


1. Lab Overview

Item Detail
Lab title Register a RHEL system and manage files across the filesystem
Objective Register a system with Red Hat, verify repository access, create and manage files and directories safely, and identify the purpose of key directories
Skills tested rhc and subscription-manager, repository verification, redirection and append, reading files, copying, moving, and removing, path navigation, filesystem hierarchy
Estimated time 90 to 120 minutes
Difficulty Beginner to intermediate
Required environment A RHEL 9 or 10 virtual machine with internet access
Prerequisites Days 1 and 2 completed; a Red Hat account with a usable subscription for Tasks 1 to 3

2. Lab Environment and Safety

Requirements

  • A disposable RHEL VM (your own VM from Day 2 is ideal).
  • A regular user with sudo rights.
  • Internet access.
  • For Tasks 1 to 3: Red Hat account credentials with an entitlement. Tasks 4 to 8 need no account.

Assumptions (not verified for your environment)

  • The VM is not already registered. If it is registered (for example, the hosted course lab may manage registration differently), check the state first and adapt Tasks 1 to 3.
  • The command-line assistant package is available for your RHEL release.
  • Files named in tasks, such as /etc/services and /usr/lib/tmpfiles.d/tmp.conf, exist on typical systems. Confirm before relying on them.

Safety

  • Work only in a directory you create, ~/day3-lab. Do not delete or overwrite anything outside it.
  • Several commands are destructive (>, rm, rm -r, rm -rf, mv over an existing file). Read every command twice before pressing Enter.
  • Do not type your Red Hat password on the command line. Let the tools prompt you.
  • Never send passwords or other secrets to the command-line assistant.
  • Do not disable SELinux or the firewall.
  • Unregister the VM when you finish so a test system does not stay attached to your account.

3. Practice Tasks

Try each task from the requirements first. Solutions are in the last section.

Task 1: Register with the Red Hat connector

Scenario: A new VM cannot install packages and you have been asked to enable access to Red Hat content.

Requirements:

  • Record the repository list before registering.
  • Register the system using the Red Hat connector.
  • Confirm that the connection is active.
  • Record the repository list after registering.
  • Save the before and after observations in ~/day3-lab/registration.txt.

Hints:

  • You need elevated privileges for registration.
  • A repository listing command exists in dnf.
  • Create the ~/day3-lab directory first if it does not exist.

Success criteria: The file shows no (or an error for) repositories before registration and a list of repositories afterward, and the connector reports an active connection.


Task 2: Switch to Subscription Manager

Scenario: A colleague's documentation uses the traditional registration tool, and you need to show you can use both.

Requirements:

  • Remove the current connection.
  • Register again, this time with Subscription Manager.
  • Verify registration status and identity.
  • Verify repository access again.

Hints:

  • Disconnecting with one tool and re-registering with another is allowed, but verify the state in between.

Success criteria: Status and identity commands show a registered system, and the repository list is not empty.


Task 3: Ask the command-line assistant (optional)

Scenario: You need to remember how to open a firewall service and want to see how the assistant answers.

Requirements:

  • Install the command-line assistant.
  • Ask it one plain-English question about opening a firewall service.
  • Compare the suggested command with the manual page before running anything.
  • Write one sentence in ~/day3-lab/assistant.txt about whether the answer matched the manual page.

Hints:

  • The question goes in quotes.
  • The manual pages for firewall-cmd are the reference.

Success criteria: You received an answer, compared it with the manual page, and recorded your conclusion. If the assistant is unavailable on your release, write that finding instead.


Task 4: Build a directory tree

Scenario: You are preparing a workspace for a small application.

Requirements:

  • Inside ~/day3-lab, create earth/asia/india/telangana using one command.
  • Create three sibling directories named config, logs, and data inside a directory named app using one command.
  • Show the whole structure.
  • Starting in telangana, return to ~/day3-lab using only relative paths. Then enter app/logs using an absolute path.

Hints:

  • One option makes missing parent directories.
  • ~ refers to your home directory.

Success criteria: The recursive listing shows both trees, and pwd confirms you reached each location.


Task 5: Redirect and append

Scenario: You are keeping a simple activity log and must never lose earlier entries.

Requirements:

  • Create ~/day3-lab/app/logs/activity.log containing the line service started.
  • Add a second line service checked without losing the first.
  • Create ~/day3-lab/notes.txt using keyboard input, with two lines of your choice.
  • Demonstrate (on a different scratch file) what happens when you use the wrong operator and overwrite content.

Hints:

  • Two operators are involved. One keeps existing content.
  • A keyboard-input file needs an end-of-input signal.

Success criteria: activity.log shows both lines in order. notes.txt shows your two lines. The scratch file demonstrates the overwrite.


Task 6: Read files in different ways

Scenario: You must inspect a long file quickly and pull out its beginning and end.

Requirements:

  • Create a file ~/day3-lab/numbers.txt containing the numbers 1 to 30, one per line.
  • Show the first 5 lines and the last 5 lines.
  • Show the file in reverse order.
  • Page through the whole file in a viewer that lets you scroll backward, and search it for the number 17. Then quit.
  • Show the first 10 lines of /etc/services (if it exists).

Hints:

  • seq can generate numbers, and redirection can save them.
  • Two paging tools exist, but only one scrolls backward easily.

Success criteria: Your outputs match the expected lines, and you can name which tool you used for paging and how you quit.


Task 7: Copy, rename, move, and remove safely

Scenario: You need to back up and reorganize files without risking real data.

Requirements:

  • Copy activity.log into the data directory.
  • Copy the entire app directory to app-backup (inside ~/day3-lab).
  • Rename notes.txt to notes-old.txt.
  • Move notes-old.txt into app/config.
  • Try to remove the non-empty app-backup/logs directory with the command that only removes empty directories and read the result. Then remove app-backup correctly.
  • After each step, list the affected directory to confirm the result.

Hints:

  • Copying a directory needs an extra option.
  • Renaming and moving use the same command.
  • Only remove paths inside ~/day3-lab.

Success criteria: The final listing shows the expected files, app-backup is gone, and you saw the "not empty" error and can explain it.


Task 8: Explore the filesystem hierarchy

Scenario: A new teammate asks where configuration, logs, home directories, and temporary files live.

Requirements:

  • List the top-level directories of the filesystem.
  • Find out whether /bin and /sbin are real directories or symbolic links, and where they point.
  • For each directory below, write one line in ~/day3-lab/fhs.txt explaining what it holds: /boot, /dev, /etc, /home, /root, /run, /tmp, /usr, /var, /var/tmp.
  • Find the cleanup age configured for /tmp and /var/tmp on your system.

Hints:

  • A long listing with the directory itself (not its contents) shows link targets.
  • The cleanup rules are in a systemd tmpfiles configuration file.

Success criteria: Your file has ten accurate lines, and you report the actual cleanup values from your system (not assumed values).


4. Troubleshooting Challenges

Perform these only inside ~/day3-lab.

Challenge A: The vanished log

A colleague says their log file lost its old entries after they added a line.

Setup: Create ~/day3-lab/ch-a.log with three lines. Then add a fourth line using the wrong operator.

Your job: Explain what happened, state whether the data can be recovered, and describe how to prevent it.

Success criteria: You identify the operator, say that the earlier content is gone (and that a backup would have saved it), and give a prevention method.

Challenge B: The directory that will not delete

Setup: Create ~/day3-lab/stubborn/inner/file.txt.

Your job: Try to remove stubborn with rmdir, explain the result, and remove it using an appropriate command after listing its contents.

Success criteria: You read the error, explain it, and remove only the intended directory.

Challenge C: The copy that skipped a directory

Setup: Create ~/day3-lab/src/sub/a.txt. Try cp src dest.

Your job: Explain the message, fix the command, and verify the result.

Success criteria: dest contains the full copy with sub/a.txt.

Challenge D: The package that will not install

Setup: Unregister the VM (after Task 2), then try to install a small package of your choice.

Your job: Diagnose why the install fails, state the registration check you would run, restore the registration, and confirm the install now works.

Success criteria: You tie the failure to missing registration, you used a status command to show it, and the install succeeds after you register again.


5. Final Practical Challenge

Scenario: You are setting up a small project workspace on a newly built RHEL VM and must leave a verifiable record.

Requirements: Using only the requirements below, build the following inside ~/day3-lab/final:

  1. A directory structure project/{src,docs,logs,backup} created with a minimal number of commands.
  2. A file project/src/main.txt containing three lines of your choice.
  3. A log file project/logs/events.log with one entry per action you perform below, appended in order.
  4. A copy of main.txt in backup, and a renamed copy of it called main-v1.txt in docs.
  5. A file project/docs/summary.txt that contains, in your own words, the purpose of /etc, /var, and /tmp.
  6. A final file project/docs/status.txt showing the current registration status of the VM (use the appropriate command) and the first 3 lines of main.txt.
  7. Confirm all of it with one recursive listing.

Choose the commands yourself. Do not copy the notes without understanding each option.

Success criteria: The listing shows the exact structure, events.log has an entry for each action in order, no earlier content was overwritten, and status.txt matches current system state.


6. Verification Checklist

  • [ ] I recorded the repository list before and after registering.
  • [ ] I registered with rhc and verified with a status command.
  • [ ] I registered with Subscription Manager and checked status and identity.
  • [ ] I compared the assistant's answer with a manual page (or noted it was unavailable).
  • [ ] I created nested directories with one command each.
  • [ ] I used > and >> correctly and saw the effect of each.
  • [ ] I used head, tail, tac, and a pager on a file.
  • [ ] I copied a directory with -r, renamed a file, and moved a file.
  • [ ] I saw rmdir refuse a non-empty directory.
  • [ ] I identified /bin and /sbin as links (or documented what my system shows).
  • [ ] I found the actual cleanup ages for /tmp and /var/tmp.
  • [ ] I completed Challenges A to D.
  • [ ] My final workspace matches the requirements.
  • [ ] I only deleted or overwrote items inside ~/day3-lab.
  • [ ] I unregistered or disconnected the VM when finished.

7. Solutions and Answer Key

Try the tasks first. Output varies by system, so expected results describe what to look for. Replace placeholders with your own values.

Task 1 solution

Approach: Capture the starting state, register, verify.

mkdir -p ~/day3-lab
{ echo "BEFORE:"; sudo dnf repolist 2>&1; } > ~/day3-lab/registration.txt
sudo rhc connect
sudo rhc status
{ echo; echo "AFTER:"; sudo dnf repolist 2>&1; } >> ~/day3-lab/registration.txt
cat ~/day3-lab/registration.txt

Explanation: 2>&1 includes error messages in the file. The first group uses > to start the file, and the second uses >> to append, so the "before" results are kept.

Verification: rhc status reports a connection, and the "AFTER" section lists repositories.

Rollback: sudo rhc disconnect


Task 2 solution

sudo rhc disconnect
sudo subscription-manager register
sudo subscription-manager status
sudo subscription-manager identity
sudo dnf repolist

Explanation: Disconnecting first avoids an "already registered" conflict. The register command prompts for credentials.

Verification: Status reports registration, identity shows the system's identity, and dnf repolist lists repositories.

If repositories are missing: Check the subscription in your Red Hat account and the output of subscription-manager status.


Task 3 solution

sudo dnf install command-line-assistant -y
c "how do I allow the http service through the firewall permanently?"
man firewall-cmd
echo "Answer matched the manual page for --add-service and --permanent." > ~/day3-lab/assistant.txt

Write the real conclusion in the file based on your comparison. Do not copy the sentence above unless it is true for what you observed.

Explanation: The manual page is the authority. Look for --add-service, --permanent, and --reload.

If the assistant is unavailable: Run rpm -q command-line-assistant and record your finding.

Cleanup: None required.


Task 4 solution

cd ~/day3-lab
mkdir -p earth/asia/india/telangana
mkdir -p app/{config,logs,data}
ls -R
cd earth/asia/india/telangana && pwd
cd ../../../..
pwd
cd /home/<your-user>/day3-lab/app/logs
pwd

Explanation: -p creates parents. The braces in app/{config,logs,data} expand to three directories. From telangana, four .. levels reach ~/day3-lab. The final cd uses an absolute path, which starts with /.

Verification: ls -R shows both trees, and each pwd matches the expected location.


Task 5 solution

cd ~/day3-lab
echo "service started" > app/logs/activity.log
echo "service checked" >> app/logs/activity.log
cat app/logs/activity.log

cat > notes.txt
# type two lines, then press Ctrl+D on a new line
cat notes.txt

echo "keep me" > scratch.txt
echo "oops" > scratch.txt
cat scratch.txt

Explanation: The first > creates the log and >> appends. cat > notes.txt reads from the keyboard until Ctrl+D. The scratch demo shows that the second > replaced "keep me".

Verification: activity.log has both lines in order, notes.txt has your lines, and scratch.txt contains only oops.

Cleanup: rm scratch.txt (a file you created).


Task 6 solution

cd ~/day3-lab
seq 1 30 > numbers.txt
head -n 5 numbers.txt
tail -n 5 numbers.txt
tac numbers.txt
less numbers.txt        # type /17 and press Enter to search; press q to quit
head -n 10 /etc/services

Explanation: seq 1 30 prints 1 to 30, and > saves it. less scrolls both ways and supports / search. q quits. more pages forward only and is less convenient for searching.

Verification: head shows 1 to 5, tail shows 26 to 30, and tac starts at 30.


Task 7 solution

cd ~/day3-lab
cp app/logs/activity.log app/data/
ls app/data
cp -r app app-backup
ls app-backup
mv notes.txt notes-old.txt
mv notes-old.txt app/config/
ls app/config
rmdir app-backup/logs        # expected to fail: directory not empty
rm -r app-backup
ls

Explanation: cp -r copies directories recursively. A rename is a move to a new name. rmdir refuses non-empty directories, so it protected the files. rm -r app-backup removes the directory and its contents, and the path is inside ~/day3-lab, so it is safe.

Verification: ls no longer shows app-backup, and app/config contains notes-old.txt.


Task 8 solution

ls /
ls -ld /bin /sbin
cat /usr/lib/tmpfiles.d/tmp.conf

If that path does not exist:

systemd-tmpfiles --cat-config | grep -i tmp

Example content for fhs.txt (write your own wording):

/boot  - kernel and boot files
/dev   - device files representing hardware
/etc   - system-wide configuration files
/home  - home directories of regular users
/root  - home directory of the root user
/run   - runtime data, cleared at reboot
/tmp   - temporary files, cleaned automatically
/usr   - installed software and libraries
/var   - variable data such as logs and caches
/var/tmp - temporary files kept longer than /tmp

Explanation: ls -ld shows the directory entry itself. An l at the start of the line and an arrow -> show a symbolic link. The tmpfiles configuration lines for /tmp and /var/tmp include an age value (for example, a number followed by d).

Verification: Report the exact ages you see on your system.


Challenge A solution

cd ~/day3-lab
printf "1\n2\n3\n" > ch-a.log
echo "4" > ch-a.log
cat ch-a.log

Cause: > overwrote the file, so lines 1 to 3 were lost. They cannot be recovered from the shell unless you have a backup. Prevention: use >> to append, make a copy first (cp ch-a.log ch-a.log.bak), or use cp -i-style careful habits. Some shells offer a noclobber setting that blocks overwriting. Check your shell's documentation.


Challenge B solution

cd ~/day3-lab
mkdir -p stubborn/inner && touch stubborn/inner/file.txt
rmdir stubborn          # fails: directory not empty
ls -R stubborn
rm -r stubborn
ls

Explanation: rmdir only removes empty directories. After checking the contents, rm -r removes the directory and everything in it.


Challenge C solution

cd ~/day3-lab
mkdir -p src/sub && touch src/sub/a.txt
cp src dest              # fails: -r not specified
cp -r src dest
ls -R dest

Explanation: cp refuses to copy a directory without -r.


Challenge D solution

sudo subscription-manager unregister
sudo dnf install -y tree        # expected to fail: system not registered
sudo subscription-manager status
sudo subscription-manager register
sudo dnf install -y tree

Explanation: Without registration, the system cannot reach Red Hat repositories, so the package cannot be found or downloaded. subscription-manager status shows the unregistered state. (tree is only an example package. Use any small package from your repositories.)

Verification: The second install succeeds after registering.

Cleanup: sudo dnf remove -y tree if you do not want it.


Final practical challenge solution

mkdir -p ~/day3-lab/final/project/{src,docs,logs,backup}
cd ~/day3-lab/final/project

echo "created directory structure" > logs/events.log

printf "line one\nline two\nline three\n" > src/main.txt
echo "created src/main.txt" >> logs/events.log

cp src/main.txt backup/
echo "copied main.txt to backup" >> logs/events.log

cp src/main.txt docs/main-v1.txt
echo "copied main.txt to docs as main-v1.txt" >> logs/events.log

cat > docs/summary.txt <<'EOF'
/etc holds system-wide configuration files.
/var holds variable data such as logs and caches that persists across reboots.
/tmp holds temporary files that are cleaned automatically.
EOF
echo "wrote docs/summary.txt" >> logs/events.log

{ echo "Registration status:"; sudo subscription-manager status; echo; echo "First 3 lines of main.txt:"; head -n 3 src/main.txt; } > docs/status.txt
echo "wrote docs/status.txt" >> logs/events.log

ls -R ~/day3-lab/final
cat logs/events.log

Explanation: {src,docs,logs,backup} creates the four directories in one command. The first log entry uses > to start the log, and every later entry uses >> so no earlier entry is lost. The <<'EOF' block (a here-document) writes several lines to a file without opening an editor. Grouping commands in braces sends all of their output to a single file.

Verification: The listing shows the required structure, events.log has the entries in order, and status.txt matches what sudo subscription-manager status reports now.

Cleanup:

rm -r ~/day3-lab
sudo subscription-manager unregister     # when you are finished practicing

Remove only ~/day3-lab, which you created.


8. Extended Practice Drills

Short, independent drills for repeated practice. Do them in order or jump to the group you need. Work only inside your lab directory, read each drill carefully, and check your result with a command before looking at the answer list in section 9.

Setup (run once):

mkdir -p ~/day3-lab/drills && cd ~/day3-lab/drills

A. Registration checks

  1. Show whether the system is registered with Subscription Manager.
  2. Show the connector state.
  3. List available repositories.
  4. Show the system's registration identity.
  5. Display the options of rhc connect.
  6. Find the register section in the Subscription Manager manual page.
  7. Check whether bash-completion is installed.
  8. Check whether the command-line assistant package is installed.
  9. In one sentence, why does dnf fail on an unregistered RHEL system?
  10. Why should you unregister disposable test VMs?

B. Creating files

  1. Create an empty file empty.txt.
  2. Create three files f1, f2, f3 with one command.
  3. Show the full timestamp of f1, wait two seconds, touch it, and show the timestamp again.
  4. Create hello.txt containing hello.
  5. Add the line world to hello.txt without losing hello.
  6. Create k.txt from keyboard input with two lines.
  7. Append a third line to k.txt from the keyboard.
  8. Show hello.txt and k.txt.
  9. Overwrite a scratch file on purpose to see the effect.
  10. Append twice to a scratch file and confirm both lines stay.

C. Creating directories

  1. Create a/b/c/d with one command.
  2. Create x/one, x/two, x/three with one command.
  3. Try mkdir p/q/r without -p. What happens?
  4. Run mkdir -p a/b/c/d again. What happens?
  5. Show the structure of a recursively.
  6. Show the directory entry for a itself rather than its contents.

D. Reading files

  1. Create hundred.txt with the numbers 1 to 100, one per line.
  2. Show the first 10 lines.
  3. Show the first 3 lines.
  4. Show the last 10 lines.
  5. Show the last 3 lines.
  6. Show the file in reverse order.
  7. Page through the file with less. Jump to the end, to the start, search for 50, then quit.
  8. Page through it with more. How do you advance and quit?
  9. Count the lines in hundred.txt.
  10. Show lines 10 to 12 using head and tail together.
  11. Show the first 5 lines of /etc/services if it exists.
  12. Show the last 5 lines of /etc/passwd.

E. Listing and navigating

  1. Show a long listing of the current directory.
  2. Show hidden files too.
  3. Show a long listing including hidden files.
  4. Show human-readable sizes in a long listing.
  5. Create .secret and show that plain ls hides it but ls -a shows it.
  6. Print your location.
  7. Enter a/b/c/d using a relative path and print your location.
  8. Go up one level, then two levels, then three levels.
  9. Return to the previous directory.
  10. Go to your home directory two different ways.
  11. Reach the same directory with one absolute and one relative path.

F. Copying and moving

  1. Copy hello.txt to copy.txt.
  2. Copy it again with a prompt before overwriting.
  3. Copy the directory a to a-copy.
  4. Create box and copy f1, f2, f3 into it.
  5. Rename copy.txt to renamed.txt.
  6. Move renamed.txt into box.
  7. Rename the directory a-copy to a-moved.
  8. Move a file with a prompt before overwriting.
  9. Try cp a a-fail (a directory without -r). Explain the message.

G. Removing safely

  1. Remove f1.
  2. Remove f2 with a confirmation prompt.
  3. Compare rm nothing.txt with rm -f nothing.txt for a file that does not exist.
  4. Create empty and remove it with the command that only removes empty directories.
  5. Try rmdir a. Explain the result.
  6. Remove a-moved and everything in it.
  7. Before any rm -r, which command should you run first?
  8. Show whether rm, cp, and mv are aliased in your shell.
  9. Why is rm -rf dangerous?

H. Filesystem hierarchy

  1. List the top-level directories.
  2. Are /bin and /sbin real directories or links?
  3. Show the first 10 entries of /etc.
  4. List home directories.
  5. Show the owner and permissions of /root itself.
  6. List some log files.
  7. List the contents of /boot.
  8. Show the first 10 entries of /dev.
  9. Show the first 10 entries of /run.
  10. Find the cleanup ages configured for /tmp and /var/tmp.
  11. Create a file in /tmp and in /var/tmp, list them, then remove only those two files.
  12. Explain the difference between / and /root.
  13. Match each to its purpose: /etc, /var, /usr, /run, /boot, /dev.

I. Integrated drills

  1. Create ~/day3-lab/drills/log and append five timestamped lines to events.log using date.
  2. Make a backup copy of log named log-backup and confirm both exist.
  3. Show the newest two entries of the log.
  4. Show the log in reverse order.
  5. Rename log-backup to log-old and move it into box.
  6. Write a file fhs-notes.txt with one line each for /etc, /var, /tmp, /home, /root.
  7. Confirm every change with one recursive listing.
  8. Clean up everything you created in this drill directory.

9. Drill Answer Key

Answers show one valid approach. Output varies by system, so compare the meaning of your output, not exact text. Commands marked with sudo need elevated privileges.

A. Registration checks

  1. sudo subscription-manager status
  2. sudo rhc status
  3. sudo dnf repolist
  4. sudo subscription-manager identity
  5. rhc connect --help
  6. man subscription-manager, then /register and Enter.
  7. rpm -q bash-completion
  8. rpm -q command-line-assistant
  9. It cannot reach Red Hat's repositories without a registered, entitled system.
  10. So old test systems do not clutter your Red Hat account.

B. Creating files

  1. touch empty.txt
  2. touch f1 f2 f3
  3. ls -l --time-style=full-iso f1; sleep 2; touch f1; ls -l --time-style=full-iso f1 (only the time changes).
  4. echo "hello" > hello.txt
  5. echo "world" >> hello.txt
  6. cat > k.txt, type two lines, press Ctrl+D.
  7. cat >> k.txt, type the line, press Ctrl+D.
  8. cat hello.txt k.txt
  9. echo one > s.txt; echo two > s.txt; cat s.txt (only two remains).
  10. echo one > t.txt; echo two >> t.txt; echo three >> t.txt; cat t.txt

C. Creating directories

  1. mkdir -p a/b/c/d
  2. mkdir -p x/{one,two,three}
  3. It fails because p and p/q do not exist (No such file or directory).
  4. No error. -p does not complain when the directory exists.
  5. ls -R a
  6. ls -ld a

D. Reading files

  1. seq 1 100 > hundred.txt
  2. head hundred.txt
  3. head -n 3 hundred.txt
  4. tail hundred.txt
  5. tail -n 3 hundred.txt
  6. tac hundred.txt
  7. less hundred.txt; G (end), g (start), /50 then Enter, q.
  8. more hundred.txt; Space advances a page; q quits.
  9. wc -l hundred.txt (prints 100).
  10. head -n 12 hundred.txt | tail -n 3 (the pipe | passes output to the next command).
  11. head -n 5 /etc/services
  12. tail -n 5 /etc/passwd

E. Listing and navigating

  1. ls -l
  2. ls -a
  3. ls -la
  4. ls -lh
  5. touch .secret; ls; ls -a
  6. pwd
  7. cd a/b/c/d; pwd
  8. cd .., cd ../.., cd ../../.. (run pwd after each).
  9. cd -
  10. cd and cd ~
  11. Absolute: cd ~/day3-lab/drills/a. Relative (from drills): cd a.

F. Copying and moving

  1. cp hello.txt copy.txt
  2. cp -i hello.txt copy.txt (answer n).
  3. cp -r a a-copy
  4. mkdir box; cp f1 f2 f3 box/
  5. mv copy.txt renamed.txt
  6. mv renamed.txt box/
  7. mv a-copy a-moved
  8. mv -i <source> <destination>
  9. It refuses to copy a directory without -r.

G. Removing safely

  1. rm f1
  2. rm -i f2 (answer y).
  3. The first prints an error. The second stays silent.
  4. mkdir empty; rmdir empty
  5. It fails: the directory is not empty.
  6. rm -r a-moved
  7. List the target, for example ls -R <path>, and confirm the path with pwd.
  8. alias or type rm cp mv
  9. It removes without prompting and cannot be undone. A wrong path can destroy important data.

H. Filesystem hierarchy

  1. ls /
  2. ls -ld /bin /sbin (on modern RHEL they are symbolic links into /usr).
  3. ls /etc | head
  4. ls /home
  5. sudo ls -ld /root
  6. sudo ls /var/log | head
  7. ls /boot
  8. ls /dev | head
  9. ls /run | head
  10. cat /usr/lib/tmpfiles.d/tmp.conf (or systemd-tmpfiles --cat-config | grep -i tmp).
  11. touch /tmp/drill-tmp /var/tmp/drill-vartmp; ls -l /tmp/drill-tmp /var/tmp/drill-vartmp; rm /tmp/drill-tmp /var/tmp/drill-vartmp
  12. / is the top of the whole tree. /root is the home directory of the root user.
  13. Configuration; variable data (logs, caches); installed software and libraries; runtime data cleared at reboot; boot files; device files.

I. Integrated drills

  1. mkdir -p log; for i in 1 2 3 4 5; do echo "$(date) entry $i" >> log/events.log; done; cat log/events.log
  2. cp -r log log-backup; ls -R log log-backup
  3. tail -n 2 log/events.log
  4. tac log/events.log
  5. mv log-backup log-old; mv log-old box/
  6. Use echo "/etc - configuration" > fhs-notes.txt then >> for the rest, and cat fhs-notes.txt.
  7. ls -R ~/day3-lab/drills
  8. cd ~ && rm -r ~/day3-lab/drills (removes only the practice directory you created; check the path first).