Advanced
Searching inLabs
How to search
  • Search a task or a tool (lvm, selinux, @podman); filter by level and by book or course.
  • With an empty search box, a filter alone lists the labs — for example all hard labs of one course.
  • "two words" finds the exact phrase.
  • Plain words find names, texts and examples.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search
Try:

Lab 10.1The Linux Command Line, Chapter 10

Part 1 practice: files, pipes, permissions and processes

Level
Easy
40 min
Machines
any Linux system
Status
Not started

Goal

Use everything from Part 1 in one session: make a practice tree with brace expansion, copy and link files with wildcards, save output and errors with redirection, count with a pipeline, set permissions for a shared folder, and control a background job with signals. Work as a normal user; only the shared folder needs sudo.

Before you start

  • Open a terminal as a normal user. Work in your home directory.
  • If you have no sudo rights, skip task 6 or do it in your home directory with your own group.

Tasks

  1. Make the directory ~/lab1 with the subdirectories 2026-01 to 2026-12 in one command.
  2. Copy all files from /etc whose names end in .conf into ~/lab1/2026-01. Errors (for example "Permission denied") must go to the file ~/lab1/errors.txt, not to the screen.
  3. Count how many .conf files you copied. Save only the number in ~/lab1/count.txt.
  4. In ~/lab1, make a hard link hosts-hard and a symbolic link hosts-sym to a copy of /etc/hosts called hosts. Delete hosts and show which link still works.
  5. Show the 5 biggest files in /usr/bin (biggest first) and save the list in ~/lab1/big.txt and show it on the screen at the same time.
  6. Make the directory /srv/team for the group team (make the group). Members of the group may make and change files; new files must belong to the group; others have no access.
  7. Start sleep 600 in the background. List your jobs, bring it to the foreground, pause it, send it back to the background, and end it with the signal TERM.

Check your work

ls ~/lab1
cat ~/lab1/count.txt
cat ~/lab1/hosts-hard | head -2
ls -l ~/lab1/hosts-sym
cat ~/lab1/big.txt
ls -ld /srv/team
jobs
  • ls ~/lab1 shows 2026-01 … 2026-12, count.txt, errors.txt, big.txt, hosts-hard and hosts-sym.
  • hosts-hard still shows the text; hosts-sym is broken.
  • /srv/team shows drwxrws--- and the group team.
  • jobs shows nothing at the end.

Hints

Show the hints
  • Brace expansion: {01..12}.
  • 2> redirects only the error stream. cp with many files into a directory: cp files... dir.
  • ls dir | wc -l counts names.
  • ls -lS sorts by size; head -5 takes the first 5; tee writes to a file and the screen.
  • Mode 2770 = setgid + rwx for owner and group.
  • Ctrl-z pauses; bg, fg, kill %1.

Solution

Show the solution
  1. Make the tree with brace expansion.
    mkdir -p ~/lab1/2026-{01..12}
  2. Copy with a wildcard and send errors to a file.
    cp /etc/*.conf ~/lab1/2026-01/ 2> ~/lab1/errors.txt
  3. Count with a pipeline.
    ls ~/lab1/2026-01 | wc -l > ~/lab1/count.txt
  4. Make the links, delete the original, test both.
    cd ~/lab1
    cp /etc/hosts hosts
    ln hosts hosts-hard
    ln -s hosts hosts-sym
    rm hosts
    cat hosts-hard
    cat hosts-sym
    cat: hosts-sym: No such file or directory
  5. Sort by size and save with tee.
    ls -lS /usr/bin | head -6 | tail -5 | tee ~/lab1/big.txt
  6. Make the group and the shared folder.
    sudo groupadd team
    sudo usermod -aG team "$USER"
    sudo mkdir -p /srv/team
    sudo chown root:team /srv/team
    sudo chmod 2770 /srv/team
  7. Control the job.
    sleep 600 &
    jobs
    fg %1
    ^Z
    bg %1
    kill -TERM %1
    jobs

My notes

No notes yet.

Lessons for this lab

Commands in this lab