Linux vs Windows and macOS: Key Differences

⚖️ Comparison of Linux with Other Operating Systems

Linux, along with Microsoft Windows and Apple macOS, forms the triad of major operating systems. For exam purposes, the comparison focuses on their fundamental differences in cost, source model, security, and primary use case.

Fundamental Distinctions (Source Model & Cost)

FeatureLinux (e.g., Ubuntu, Fedora)Microsoft Windows (Proprietary)Apple macOS (Proprietary)
Source ModelOpen source (source code is freely available, modifiable, and distributable).Closed source (proprietary; source code is hidden).Closed source (proprietary; based on a BSD UNIX core).
CostFree to obtain and use.Requires a paid license.Included with Apple hardware (which is typically costly).
LicensingGoverned by licenses like the GPL (General Public License), granting four freedoms.Governed by an EULA (End-User License Agreement), restricting usage and modification.Governed by an EULA.
HardwareMost flexible; runs on many architectures (x86, ARM, etc.), often reviving old hardware.Runs on a vast range of PC hardware.Least flexible; typically runs exclusively on Apple hardware.

Technical and Use-Case Comparison

FeatureLinuxWindowsmacOS
SecurityHighest. Robust UNIX-like permissions, rapid community-driven patch cycles, and a less common target for mainstream malware.Moderate. Most frequent target for malware due to a massive user base.High. Strong security based on its UNIX foundation.
StabilityHighest. Known for continuous uptime (years) in server environments.High in modern versions, but historically prone to issues.High; known for reliability and a polished user experience.
File SystemCase-sensitive (e.g., File.txtfile.txt).Case-insensitive (e.g., File.txt = file.txt).Case-insensitive by default, but supports case-sensitive volumes.
Primary ShellBash (most common), Zsh, Fish — powerful and scriptable.PowerShell / Command Prompt (or Bash via WSL).Zsh (modern default) / Bash — powerful, UNIX-like.
Primary UseServers, cloud computing, embedded systems, software development, academic research.General desktop, gaming, corporate/business productivity.Creative professionals (video/audio/design), consumer desktop.

Conclusion for Exam Purposes

In an examination, when comparing Linux to its proprietary counterparts, the core points to emphasize are:

  • Open Source vs. Proprietary: Linux’s transparency and freedom of modification (GPL).
  • Stability and Security: Linux’s multi-user/multitasking design and stringent permission model make it fundamentally more robust for mission-critical tasks (servers).
  • Command Line Power: The highly efficient and essential command-line interface (CLI), typically Bash, provides a level of control and automation superior for professional IT and development work.

💻 Essential Linux Commands

This list categorizes key Linux commands crucial for system administration and development, focusing on their function and common usage.

1. General-Purpose Commands

These commands handle basic system interaction, documentation, and information retrieval.

CommandFunctionKey Option/Usage
manDisplays the manual page (documentation) for any command or system component.man ls
infoProvides more detailed, structured documentation than man.info bash
dateDisplays or sets the system time and date.date
whoShows who is currently logged in to the system.who
clearClears the terminal screen.clear
echoPrints text or variables to the standard output.echo $PATH

2. Directory-Oriented Commands (Navigation & Structure)

These commands manage the hierarchical file-system structure.

CommandFunctionKey Option/Usage
pwdPrints working directory (shows current location).pwd
cdChanges directory.cd /home/user or cd .. (up one level)
lsLists directory contents.ls -l (long format) or ls -a (all files, including hidden)
mkdirMakes a new directory.mkdir new_folder
rmdirRemoves an empty directory.rmdir empty_folder
treeDisplays directory contents in a tree-like format (if installed).tree /etc

3. File-Oriented Commands (Manipulation & Content)

These commands handle file creation, copying, moving, deleting, and content viewing.

CommandFunctionKey Option/Usage
touchCreates an empty file or updates file timestamps.touch newfile.txt
catConcatenates and prints file contents to the terminal.cat file.txt
lessViews large files one screen at a time (allows scrolling).less logfile.log
cpCopies files and directories.cp source.txt dest/
mvMoves (renames) files and directories.mv oldname.txt newname.txt
rmRemoves (deletes) files.rm file.txt or rm -rf directory (force recursive delete)
grepSearches for a pattern within file contents.grep "keyword" file.txt
findSearches for files and directories based on various criteria.find /home -name "*.log"

4. Process-Oriented Commands

These commands manage and monitor running programs (processes).

CommandFunctionKey Option/Usage
psReports a snapshot of the currently running processes.ps aux (shows all processes)
topDisplays processes dynamically in real time (CPU/Memory usage).top
htopAn interactive, improved version of top (if installed).htop
killSends a signal (e.g., termination) to a process using its PID (Process ID).kill 1234 (default is signal 15, graceful termination)
killallSends a signal to all processes with a specific name.killall firefox
&Executes a command in the background.sleep 60 &

5. Communication-Oriented Commands

These commands facilitate user-to-user communication or network interaction.

CommandFunctionKey Option/Usage
sshSecure Shell: securely logs into a remote system.ssh user@server_ip
scpSecure Copy: securely transfers files between hosts.scp localfile.txt user@server:/tmp
pingTests network connectivity and measures packet round-trip time.ping google.com
wgetNon-interactively retrieves files from the web (downloading).wget <URL>
writeSends a message to another user’s terminal session.write username
wallWrite to all logged-in users’ terminals (administrator announcements).wall "System maintenance in 1 hour"

🔎 Regular Expressions & Filters in Linux

Filters and regular expressions (regex) are fundamental tools in Linux for processing text data, especially when dealing with command output, logs, and configuration files.

🔧 Simple Linux Filters

In Linux, a filter is a program that reads data from standard input (stdin), processes it, and writes the resulting data to standard output (stdout). Filters are often used in combination with the pipe operator (|).

CommandFunctionKey Option/UsageExample
moreUsed to display text output one screenful at a time.ls -l | more 
wcWord count: prints the number of lines, words, and bytes (characters) in a file.wc -l file.txtCounts only the lines in file.txt.
diffFinds the differences between two files, line by line.diff file1.txt file2.txtShows which lines differ and how to change them.
sortSorts the lines of text files.sort -r data.txtSorts the lines in data.txt in reverse alphabetical order.
uniqReports or omits repeated lines. It only works on adjacent identical lines, so it is often used after sort.sort names.txt | uniq 
grepGlobal Regular Expression Print: searches for lines matching a specified pattern (regular expression).grep -i "error" logfile.logSearches for “error” case-insensitively in the log file.

📜 Introducing Regular Expressions (Regex)

Regular expressions are specialized text strings used to describe and match patterns in other strings or text files. They are essential for advanced searching and data manipulation, especially with tools like grep, sed, and awk.

Basic Regex Components

Regex uses special characters, called metacharacters, to define patterns:

MetacharacterDescriptionExample PatternMatches
. (dot)Matches any single character (except a newline).a.cabc, a1c, a-c
*Matches the preceding item zero or more times.a*bb, ab, aaab
+Matches the preceding item one or more times (used with egrep/PCRE).a+bab, aaab (but not b)
?Matches the preceding item zero or one time (used with egrep/PCRE).colou?rcolor, colour
^Matches the pattern at the beginning of a line.^StartMatches “Start line” but not “The Start line”
$Matches the pattern at the end of a line.End$Matches “Line End” but not “End of line”
[ ]Character set: matches any one of the characters inside the brackets.[abc]Matches a, b, or c
[^ ]Negated character set: matches any character not inside the brackets.[^0-9]Matches any non-digit character.

Regex Tools in Linux

The grep utility supports three main types of regular expressions:

  • Basic Regular Expressions (BRE): The default for the standard grep command. It requires metacharacters like +, ?, |, and {} to be escaped with a backslash (\).
    Example: grep "a\{2,\}b" file matches ‘a’ appearing 2 or more times followed by ‘b’.
  • Extended Regular Expressions (ERE): Enabled using the egrep command or the grep -E option. This syntax simplifies usage by allowing metacharacters like +, ?, and | to be used without escaping.
    Example: egrep "a+b" file matches ‘a’ appearing 1 or more times followed by ‘b’.
  • Perl Compatible Regular Expressions (PCRE): Enabled using grep -P. This provides the most modern and powerful set of regex features.

🧠 Example Usage

To find all lines in a file that start with an uppercase letter followed by any number of lowercase letters:

grep -E "^[A-Z][a-z]*" mydata.txt
  • grep -E: uses extended regular expressions.
  • ^: matches the beginning of the line.
  • [A-Z]: matches one uppercase letter.
  • [a-z]*: matches zero or more lowercase letters.