macOS and Linux Hands-On Lab

← Back to Forge macOS & Linux -- Hands-On Lab INTERACTIVE
Score: 0 / 20
1

Navigating the Linux File System

Linux organizes everything under a single root directory (/). Knowing how to move through directories and list their contents is the foundation of every Linux task.

TERMINAL REFERENCE
$ pwd # Print working directory $ ls # List files in current dir $ ls -la # List all files with details $ cd /etc # Change to /etc directory $ cd .. # Go up one directory level $ cd ~ # Go to home directory $ mkdir projects # Create a new directory $ rm file.txt # Delete a file $ rm -r folder/ # Delete a directory recursively
Q1. What command prints your current working directory?
Q2. You are in /home/student. What command lists ALL files (including hidden) with full details?
Q3. What command creates a new directory called backups inside /home/student?
Q4. What is the absolute path to the root user's home directory in Linux?
Hint -- Home Directories

Regular users live under /home/username. The root (admin) user is special -- its home is /root, not /home/root.

2

File Permissions

Linux uses a permission system with three levels: owner, group, and others. Each level can have read (r), write (w), and execute (x) permissions.

PERMISSION EXAMPLE
$ ls -l report.txt -rw-r--r-- 1 student staff 2048 Apr 10 09:15 report.txt # Breaking it down: # -rw-r--r-- = type | owner(rw-) | group(r--) | others(r--) # owner: read+write | group: read | others: read $ chmod 755 script.sh # rwxr-xr-x $ chmod u+x script.sh # Add execute for owner $ chown student file.txt # Change owner
Numeric permissions: r=4, w=2, x=1. Add them per level. Example: 755 = owner(7=rwx), group(5=r-x), others(5=r-x).
Q5. A file shows -rwxr-x---. What is the numeric (octal) permission?
Q6. What command gives the owner read/write/execute and everyone else NO permissions?
Q7. What command changes the owner of data.csv to the user admin?
Hint -- Octal Math

r=4, w=2, x=1. For rwx: 4+2+1=7. For r-x: 4+0+1=5. For ---: 0+0+0=0.

3

Package Management (apt)

Debian-based distros (Ubuntu, Linux Mint) use apt to install, update, and remove software. Understanding package management is critical for system administration.

APT COMMANDS
$ sudo apt update # Refresh package lists $ sudo apt upgrade # Upgrade installed packages $ sudo apt install nginx # Install a package $ sudo apt remove nginx # Remove a package $ apt search "web server" # Search for packages $ apt list --installed # List installed packages
Q8. Before installing any new software, what command should you run first to refresh the package lists?
Q9. What command installs the openssh-server package?
Q10. What command removes the apache2 package from the system?
Hint -- apt update vs apt upgrade

apt update refreshes the list of available packages. apt upgrade actually installs newer versions. Always update before upgrade.

4

Process Management

Every running program in Linux is a process. Knowing how to view, monitor, and terminate processes is essential for troubleshooting.

PROCESS COMMANDS
$ ps aux # List all running processes $ top # Live process monitor (press q to quit) $ kill 1234 # Send SIGTERM to PID 1234 $ kill -9 1234 # Force kill (SIGKILL) PID 1234 $ ps aux | grep nginx # Find processes by name
Q11. What command shows a live, real-time view of running processes, CPU usage, and memory?
Q12. A stuck process has PID 5678. What command force-kills it immediately?
Q13. What command lists all running processes with full details (user, PID, CPU, memory)?
Q14. What signal number does kill -9 send, and what is it called?
Hint -- SIGTERM vs SIGKILL

kill PID sends SIGTERM (signal 15) -- a polite "please stop." kill -9 PID sends SIGKILL -- an immediate forced termination. Always try SIGTERM first.

5

macOS Equivalents

macOS is built on a Unix foundation (Darwin/BSD). Many Linux commands work the same in the macOS Terminal, but the GUI and package management differ.

Key macOS differences: The Finder replaces the Linux file manager. Homebrew (brew) replaces apt. System Preferences (now System Settings) replaces config files for most user settings. The macOS file system root is / just like Linux, but user files live under /Users/ instead of /home/.
macOS vs LINUX COMPARISON
# Package management Linux: sudo apt install git macOS: brew install git # Home directory Linux: /home/student macOS: /Users/student # System monitor Linux: top / htop macOS: top / Activity Monitor (GUI) # Software updates Linux: sudo apt update && sudo apt upgrade macOS: softwareupdate -l
Q15. What is the macOS package manager installed via the Terminal (used to install tools like git, python, etc.)?
Q16. On macOS, what is the full path to a user named jsmith's home directory?
Q17. What macOS command installs the wget package using Homebrew?
Q18. What is the macOS GUI application for monitoring CPU, memory, and disk activity (equivalent to Task Manager)?
Q19. What command lists available macOS software updates from the Terminal?
Q20. True or False: The macOS Terminal supports standard Linux commands like ls, cd, pwd, and grep.
Hint -- Unix Foundation

macOS is built on Darwin, a Unix-based kernel. Most standard Unix/Linux commands work natively in the macOS Terminal because they share the same POSIX foundation.

Lab Complete

Answer all 20 questions to unlock completion.