# Linux and macOS Basics

> Chapter 6 of the Courseiva ITF-PLUS curriculum — https://courseiva.com/learn/itf-plus/linux-and-macos-basics

**Official objective:** 2.3 — Identify and use common Linux and macOS features and tools.

## Introduction

An operating system (OS) is the master software that manages every piece of hardware in a computer, from the keyboard to the screen to the internet connection. Linux and macOS are two major operating systems that IT professionals encounter daily, and the CompTIA Tech+ exam (FC0-U71) expects you to understand how they work, how they differ from Windows, and what basic tools they share. Mastering these concepts means you can confidently navigate any computer you’re handed on the job.

## The Shared Kitchen Analogy

When you move into a shared house, you either get a personal mini-fridge for your snacks or you share a big kitchen with clear rules. That difference? It’s the heart of Linux versus macOS. 

With macOS, Apple gives you the whole kitchen already set up: the fridge is stocked, the hob is induction, and the recipe book is locked to the shelf. You can cook a great meal (run your apps) but you cannot decide to swap the hob for a wok burner or rewrite the recipe book. Everything is smooth, consistent, and locked down. 

With Linux, you walk into an empty kitchen. The gas line is there, the water pipes are exposed, and you get a big toolbox. You want a wok burner? You install one. You want to rewrite every recipe? Go ahead. You can even tear down the wall between the kitchen and the living room if you have the skills. That freedom is powerful, but if you accidentally turn the gas on without lighting it, you could blow up the dinner. 

In the shared house analogy, the operating system (OS) is the house itself. The kernel is the building manager who controls who gets keys, when the gas turns on, and which rooms can be used. The command line (Terminal) is the master key set that lets you bypass the normal locks. This is exactly why an IT pro needs to know Linux basics: because servers (big, powerful computers that run websites and databases) almost always use Linux, and you need the master key set to fix broken things without a graphical user interface.

## Core explanation

An operating system (OS) is the foundational software that manages all the hardware and software on a computer. Think of it as the air traffic controller for your system: it decides which programs get access to the CPU (the brain of the computer), how much memory (RAM) each program gets, and how data flows to the hard drive or network. Without an OS, your computer is just a collection of inert metal and silicon. Linux and macOS are two prominent operating systems, both rooted in a family called Unix. 

Linux is an open-source operating system, meaning its source code (the human-readable instructions that make up the software) is freely available for anyone to see, modify, and distribute. This is a huge departure from proprietary systems like Windows or macOS, where the source code is kept secret by the company. Because Linux is open source, it has spawned hundreds of different versions, called distributions or distros. Popular distros include Ubuntu, Fedora, and Debian. Each distro packages the Linux kernel (the core of the OS) with different software, desktop environments (the look and feel of the interface), and tools. A server administrator might choose Ubuntu Server because it’s stable and well-supported, while a developer might prefer Fedora because it has the newest software packages. 

macOS, on the other hand, is a proprietary operating system made by Apple exclusively for Mac computers. It is built on a Unix foundation, which means it shares a lot of the same underlying plumbing as Linux, including a powerful command-line tool called the Terminal. The Terminal is a text-based interface that lets you type commands directly to the OS, bypassing the graphical user interface (GUI). Both Linux and macOS have a Terminal, and many of the commands are identical or very similar. This is why IT professionals who learn Linux commands can often work on macOS systems with little extra training. 

The most fundamental interface in Linux and macOS is the shell. The shell is a program that interprets the commands you type into the Terminal and sends them to the OS to execute. The most common shell is called Bash (Bourne Again SHell). When you open the Terminal on a Mac, you are usually dropped into a Bash shell, though newer versions of macOS use Z shell (zsh) as the default. Either way, the concept is the same: you type a command, press Enter, and the shell runs it for you. Common commands include 'ls' to list files and directories in your current location, 'cd' to change directories (think of navigating folders), 'mkdir' to create a new directory, and 'rm' to delete files or directories. 

Files and directories (folders) in Linux and macOS follow a single directory tree that starts at the root directory, represented by a forward slash (/). Every file on the system sits somewhere under that root. For example, the directory /home contains the personal folders for each user. On macOS, it might be /Users. This unified file system is different from Windows, which uses drive letters like C: and D:. Understanding the file hierarchy is critical because when you issue commands, you need to specify exact paths. An absolute path starts from the root, like /home/john/documents/report.txt. A relative path starts from your current directory, like ./documents/report.txt. 

Permissions are another key concept. Since Linux and macOS are multi-user systems (multiple people can use the same computer at different times or remotely), the OS must control who can read, write, or execute files. Each file has an owner, a group, and a set of permissions: read (r), write (w), and execute (x). You can see these permissions by typing 'ls -l'. For example, '-rwxr-xr--' means the owner can read, write, and execute; the group can read and execute; and everyone else can only read. To change permissions, you use the 'chmod' command (change mode). To change ownership, you use 'chown' (change owner). These concepts replace the simpler permissions model in Windows and are essential for system security. 

Package managers are how you install, update, and remove software in Linux. Different distros use different package managers. For example, Debian-based systems (like Ubuntu) use 'dpkg' at the lowest level and a front-end called APT (Advanced Package Tool). You might type 'sudo apt install firefox' to install the Firefox web browser. The 'sudo' prefix stands for 'superuser do' and gives you administrator privileges for that single command. Fedora-based systems use 'dnf'. macOS uses a package manager called Homebrew (installed separately) or you can install apps through the App Store. Understanding package management is crucial because it’s the standard way to add functionality to Linux servers without using a graphical interface. 

Finally, both Linux and macOS support remote access via SSH (Secure Shell). This allows an IT professional to log into a computer from across the room or across the world, using a terminal session. The command looks like 'ssh username@192.168.1.100'. Once connected, you can run all the same commands as if you were sitting at the machine. This is the backbone of modern server administration, cloud computing, and even some help-desk scenarios. The exam expects you to know that these tools exist and what they are used for, though you won’t be tested on memorising every command flag.

## Real-world context

Meet Priya, a junior IT support technician at a mid-sized company. Her boss hands her a ticket: ‘The web server hosting our main client portal is running slowly, and some users are getting errors.’ The web server runs Ubuntu Linux. Priya does not have physical access to the server because it’s in a data centre two hours away. She must fix it remotely. 

First, Priya opens the Terminal on her laptop and types ‘ssh priya@webserver.company.com’. She is prompted for her password and then a one-time code from her authenticator app (two-factor authentication). She is now connected to the server’s command line. She cannot see a desktop or click anything. Everything she does is typed. 

Step one: She wants to check what is running. She types ‘top’, which shows a real-time list of processes (running programs) and how much CPU and memory each one uses. She spots that a process called ‘httpd’ (the Apache web server) is using 99% of the CPU. That is the culprit. 

Step two: She needs to restart the web server gracefully. She types ‘sudo systemctl restart httpd’. The ‘systemctl’ command is used to manage services (background programs) on modern Linux systems. After a few seconds, the web service restarts. She checks the status with ‘sudo systemctl status httpd’ and sees it is ‘active (running)’. 

Step three: To ensure the slowdown does not happen again, she looks at the log files. Logs are files where the OS writes detailed information about what is happening. She types ‘cd /var/log’ to navigate to the log directory, then ‘cat apache2/error.log’ to view the error log. She sees repeated entries about ‘out of memory’ errors. The server’s RAM (memory) is maxing out. 

Step four: She opens a second Terminal window to the server and checks memory usage with ‘free -h’. The output shows 4 GB total RAM, with only 200 MB free. She decides to increase the server’s memory allocation. Since this is a virtual machine (a software-based computer running inside a bigger physical server), she opens a cloud management console in a web browser and allocates 8 GB of RAM to the virtual machine. Then she reboots the server with ‘sudo reboot’. 

Step five: After the reboot, she reconnects via SSH and runs the client website in a browser on her laptop. The site loads fast. She adds a comment to the ticket: ‘Increased RAM from 4GB to 8GB. Restarted Apache. No further errors found. Monitoring for next 24 hours.’ 

This scenario shows the daily reality for IT pros: they use the Linux command line to diagnose problems, manage services, view logs, and apply fixes without ever touching the physical machine. Without Linux basics, Priya would have needed to drive two hours, plug in a monitor and keyboard, and fix it manually – a huge waste of time. The exam tests your ability to recognise the names of these tools and what they do, not necessarily the exact syntax.

## Exam focus

The CompTIA Tech+ (FC0-U71) exam devotes Objective 2.3 to ‘Identify and use common Linux and macOS features and tools.’ Do not confuse this with the Linux+ or Server+ exams, which require deep command-line knowledge. Tech+ is meant as an entry-level literacy check: can you tell the difference between a command line and a GUI? Do you know what a package manager does? Can you name the main components of a Unix-like OS? 

The exam loves to test the following specific concepts: 
- The default command shell in macOS (currently zsh, but Bash is also accepted historically) and the fact that Linux commonly uses Bash. 
- The purpose of the ‘sudo’ command: to execute a command with superuser (administrator) privileges. A common trap is presenting ‘sudo’ as a user login process or a file editor. It is neither. 
- The package management tools: they will ask which command installs software on a Debian-based Linux system. The correct answer is ‘apt-get install’ or ‘apt install’. On macOS, they might ask for the built-in method (App Store) or Homebrew (third-party). 
- File permissions: recognise that ‘-rw-r--r--’ means the owner can read and write, the group can read, and others can read. They will give you a permission string and ask what the owner can do. 
- The root directory symbol: forward slash (/). On macOS and Linux, the file system starts at ‘/’. They will contrast this with Windows’s drive letters. 
- SSH (Secure Shell): you must know that SSH is a secure protocol for remote command-line access. They might ask which port it uses (22) or what tool you use to connect securely to a Linux server. 
- The difference between a graphical user interface (GUI) and a command-line interface (CLI). The exam may describe a scenario where an administrator needs to install software on dozens of servers remotely, and the best tool is a CLI because it can be scripted. 
- Process management: the ‘ps’ command lists running processes, and ‘kill’ stops a process by its process ID (PID). They might ask what command you use to see running processes. 
- The concept of ‘open source’ as it relates to Linux: that the source code is freely available. 

Common trap patterns: 
- They will offer ‘Windows PowerShell’ as a Linux shell answer. PowerShell is Windows-specific (though now available on Linux, it is not the default or traditional shell). 
- They might mix up ‘cd’ (change directory) with ‘dir’ (Windows command). On Linux and macOS, the command is ‘ls’ for listing, not ‘dir’. 
- They will try to trick you by saying ‘You need to be logged in as root all the time on Linux.’ The reality is that best practice is to use a standard account and elevate with ‘sudo’. 
- File extension confusion: Linux and macOS do not rely on file extensions (.exe, .dmg) to determine executability; they rely on the ‘execute’ permission bit. 

To memorise for the exam: 
- Shell: interprets commands 
- Kernel: core of the OS, manages hardware 
- Terminal: the application that provides a text window to the shell 
- Sudo: temporary administrator rights 
- SSH: secure remote login 
- Package manager: installs/uninstalls software 
- Permissions: r, w, x for owner, group, others

## Step by step

1. **Open the Terminal** — On macOS, you find Terminal in Applications > Utilities. On a Linux system (like Ubuntu), you can press Ctrl+Alt+T or find it in the applications menu. The Terminal is the gateway to the command-line interface (CLI), where you communicate with the OS by typing instead of clicking.
2. **Check your current directory with 'pwd'** — Type 'pwd' (print working directory) and press Enter. The output, such as '/Users/yourname', tells you exactly where you are in the file system. This is the first thing you should do when you start a session, so you know your starting point before making changes.
3. **List files with 'ls'** — Type 'ls' and press Enter to see all files and directories in your current location. To see hidden files (starting with a dot), type 'ls -a'. To see detailed information including permissions, type 'ls -l'. This command is the equivalent of opening a folder in a GUI to see its contents.
4. **Navigate to the Documents folder with 'cd'** — Type 'cd Documents' (case-sensitive) and press Enter. The 'cd' command (change directory) moves you into a subfolder. You can use 'cd ..' (two dots) to go up one level to the parent folder. This replaces double-clicking folders in a graphical interface.
5. **Create a new directory for note-taking** — Type 'mkdir study-notes' and press Enter. This creates a new folder called 'study-notes' inside your current directory. To verify, type 'ls' again and you should see it listed. This is how you organise files without using a mouse.
6. **Create a text file using 'echo' and a redirect** — Type 'echo "Linux and macOS Basics" > notes.txt' and press Enter. This creates a new file called notes.txt containing the quoted text. The '>' symbol redirects the output of the echo command into a file. If the file already exists, it overwrites it. Use '>>' to append instead, which adds data to the end of an existing file without deleting its content.
7. **View the file content with 'cat'** — Type 'cat notes.txt' and press Enter. The content of the file appears in the Terminal. 'cat' is short for concatenate, but its most common use is to display file contents on screen. For longer files, you might use 'less', which lets you scroll through the text page by page.

## Comparisons

### Bash (Bourne Again SHell) vs Zsh (Z Shell)

**Bash (Bourne Again SHell):**
- Default shell in many older Linux distros and early macOS versions
- Uses .bashrc for configuration file
- Supports basic tab completion but less advanced than Zsh

**Zsh (Z Shell):**
- Default shell in macOS since Catalina (2019)
- Uses .zshrc for configuration file
- Offers more advanced tab completion, spelling correction, and theming via Oh My Zsh

### apt (Advanced Package Tool) vs dnf (Dandified YUM)

**apt (Advanced Package Tool):**
- Used by Debian-based Linux distros (Ubuntu, Debian)
- Commands: apt install, apt update, apt upgrade
- Uses .deb package format

**dnf (Dandified YUM):**
- Used by Red Hat-based Linux distros (Fedora, CentOS)
- Commands: dnf install, dnf update, dnf upgrade
- Uses .rpm package format

### SSH (Secure Shell) vs RDP (Remote Desktop Protocol)

**SSH (Secure Shell):**
- Provides command-line remote access to Linux and macOS
- Uses port 22 by default
- Encrypts all traffic; lightweight, works on slow connections

**RDP (Remote Desktop Protocol):**
- Provides graphical remote desktop access to Windows
- Uses port 3389 by default
- Encrypts traffic but requires more bandwidth for the graphical interface

### Linux vs macOS

**Linux:**
- Open-source OS with many distributions
- Primarily used on servers, supercomputers, and developer desktops
- Package management varies by distro (apt, dnf, pacman)

**macOS:**
- Proprietary OS only on Apple hardware
- Primarily used for personal computers, creative work, and development
- Package management via App Store or Homebrew (third-party)

## Diagram

_Flowchart showing how a command travels from the user through the shell and kernel to the hardware and back as output._

```mermaid
flowchart TD
    A[User types a command in Terminal] --> B[Shell interprets the command]
    B --> C{Is sudo needed?}
    C -- Yes --> D[Elevate permissions temporarily]
    C -- No --> E[Execute command with user permissions]
    D --> E
    E --> F[Kernel processes the command]
    F --> G[Hardware (CPU, RAM, Disk) responds]
    G --> H[Output shown in Terminal]
    H --> A
```

## Common misconceptions

- **Misconception:** Linux is just like Windows but free, so all Windows software runs on it. **Reality:** Linux is a completely different operating system with a different kernel and different software ecosystem. Windows programs (.exe files) do not run natively on Linux. You need special compatibility layers like Wine to run some Windows programs, and they often don’t work perfectly. (Many beginners are familiar only with Windows and assume that ‘operating system’ is a single concept where all software is interchangeable. They don’t realise that software is compiled specifically for the OS’s kernel.)
- **Misconception:** The command ‘sudo’ stands for ‘super user’ and means I should always be logged in as root. **Reality:** ‘sudo’ stands for ‘superuser do’. It allows a permitted user to execute a single command with elevated privileges without logging in as the root user permanently. Best practice is to stay as a normal user and only use sudo when necessary for security. (The name ‘sudo’ sounds like ‘super user do’, leading people to think it means ‘I am now the super user’. They don’t grasp the principle of least privilege, which is a core security concept.)
- **Misconception:** MacOS is completely different from Linux, so knowing macOS won’t help with Linux. **Reality:** macOS is based on a Unix-like kernel (Darwin) and shares many fundamental command-line tools with Linux (ls, cd, chmod, grep, etc.). An IT professional comfortable with the macOS Terminal will find Linux very familiar, though the package managers and some administration tools differ. (Beginners see the difference in GUI and branding (Apple vs. open source) and assume the underlying systems are unrelated. They don’t know the historical lineage of Unix and POSIX standards.)
- **Misconception:** You need to be a programmer to use Linux or macOS command line. **Reality:** Using the command line is more like using a text-based remote control than programming. You type commands to get things done (list files, install software, check disk space). You don’t need to write code; you just need to know what commands to type and what they do. Many IT support roles require only basic command knowledge, not programming skills. (The black screen with blinking text looks intimidating and is often associated in pop culture with ‘hacking’ or ‘coding’. New users assume it requires programming expertise when it’s actually a simple, learnable skill.)
- **Misconception:** Linux and macOS don’t have viruses or malware, so you don’t need security tools. **Reality:** Both Linux and macOS are susceptible to malware, though the threat landscape is smaller due to market share. Linux servers are commonly targeted by hackers for cryptocurrency miners and botnets. macOS has seen an increase in adware and Trojans. Both systems require security practices: regular updates, strong passwords, and cautious software installation. (The myth originated from the early 2000s when Windows was the primary target. New users often hear ‘Linux is virus-free’ and take it as an absolute truth, not a relative safety based on lower usage numbers.)

## Key takeaways

- The command line (Terminal) on both Linux and macOS lets you control the computer by typing commands rather than clicking icons, which is essential for efficient server management and automation.
- ‘sudo’ gives you temporary administrator rights for a single command; never stay logged in as the root user because it reduces security.
- File permissions in Linux and macOS are set for three roles (owner, group, others) and three actions (read, write, execute), visible with the ‘ls -l’ command.
- The root directory is represented by a forward slash (/) on Linux and macOS, unlike Windows which uses drive letters like C:.
- SSH (Secure Shell) is the standard way to remotely control a Linux or macOS server from anywhere using encrypted communication on port 22.
- Package managers like ‘apt’ (Linux Debian) and ‘brew’ (macOS) handle installing, updating, and removing software from the command line.
- The kernel is the core of the operating system, responsible for managing hardware and memory, while the shell is the interface that interprets your commands.
- Linux is open-source, meaning anyone can view and modify its source code, which leads to many different distributions (distros) like Ubuntu and Fedora.

## FAQ

**Is Linux the same as Unix?**

No, Linux is a Unix-like operating system, but it is not Unix. Linux was written from scratch to behave like Unix, but it does not use the original Unix code. macOS is a certified Unix operating system (since macOS 10.5 in 2007), meaning it adheres to the official Single UNIX Specification.

**Can I run macOS on a regular PC?**

Technically yes, but it violates Apple’s End User Licence Agreement (EULA) and is generally not supported. It’s also tricky because macOS is written specifically for Apple hardware. In IT, server administrators would use Linux instead of trying to run macOS on non-Apple hardware.

**Do I need to memorise every Linux command for the Tech+ exam?**

No. The Tech+ exam expects you to know what common tools are used for (like ls for listing, cd for changing directory, sudo for admin tasks), but not the exact syntax of every flag. Focus on the purpose of each command and the concept of the command line.

**Why do IT professionals prefer Linux for servers?**

Linux is free, open-source, highly customisable, and extremely stable. It can run on older hardware, supports a huge range of software, and is less resource-hungry than Windows Server. Most importantly, the command line allows for automation through scripts, which is critical for managing many servers.

**What is the difference between a shell and a terminal?**

A terminal is the application window you open (like the Terminal app on a Mac). A shell is the program that runs inside that window and interprets the commands you type. Bash and Zsh are popular shells. You can change the shell without changing the terminal application.

**How do I install software on Linux without a graphical store?**

You use a package manager. For example, on Ubuntu, you type 'sudo apt install package-name'. The package manager handles downloading the software, resolving dependencies (other software it needs), and installing it. On macOS, you can use Homebrew with 'brew install package-name'.

**What does 'cd ~' do?**

The tilde (~) is a shortcut for your home directory (e.g., /home/username or /Users/username). Typing 'cd ~' or just 'cd' will take you straight to your home folder from anywhere in the file system.

## Check your understanding

1. **What command would you use to list all files, including hidden ones, in a Linux or macOS terminal?**

   Answer: The 'ls -a' command lists all files and directories, including hidden ones (those starting with a dot).

2. **If you see file permissions '-rwxr-xr--', what can the group do with the file?**

   Answer: The group can read (r) and execute (x) the file, but cannot write to it.

3. **What does the 'sudo' command do in Linux and macOS?**

   Answer: It allows a permitted user to execute a single command with superuser (administrator) privileges without logging in as root.

4. **Which protocol and default port are used for secure remote command-line access to a Linux server?**

   Answer: SSH (Secure Shell) uses TCP port 22 by default.

5. **On a Debian-based Linux system (like Ubuntu), what command installs a software package called 'firefox'?**

   Answer: The command is 'sudo apt install firefox' (or 'sudo apt-get install firefox').

---

Interactive version with quiz and diagrams: https://courseiva.com/learn/itf-plus/linux-and-macos-basics
