Linux vs Windows
You've now seen both systems from the inside. This lesson puts them side by side: where they made the same choices, where they differ, and which differences actually bite when you move code, scripts or files between them. None of it is about which system is "better": both are mature, preemptive, multi-user, virtual-memory operating systems with very different histories.
Design philosophy
| Linux | Windows | |
|---|---|---|
| Ancestry | Unix (1969) ideas, written from scratch in 1991 | VMS ideas, NT designed from 1988 |
| Kernel type | monolithic, loadable modules | hybrid (NT executive + kernel in one image) |
| Central abstraction | "everything is a file" (file descriptors) | "everything is an object" (handles) |
| Stable interface for programs | system calls (numbers never change) | Win32 API in DLLs (syscall numbers change) |
| Process creation | fork() + exec() |
CreateProcess() (one call, new image) |
| GUI | a separate user-space program (Wayland / X11 compositor) | part of the system (win32k.sys, DWM) |
| Configuration | text files in /etc and ~ |
the registry + some files |
| Software installation | package managers (apt, dnf, pacman) |
installers (MSI, MSIX), winget, Microsoft Store |
| Source | open (GPL-2.0) | closed |
Everything is a file vs everything is an object
On Linux, files, pipes, sockets, terminals, devices and even kernel information (/proc, /sys) are reached through file descriptors and the same read/write calls. The shell's power comes from that: anything can be piped into anything.
On Windows the kernel's Object Manager names files, events, mutexes, registry keys, processes and sections, and programs use handles with type-specific functions (ReadFile, RegQueryValueEx, WaitForSingleObject). Many Windows tools return structured data instead of text, which is why PowerShell passes objects through its pipeline while bash passes bytes.
Creating processes
Linux splits creation in two: fork() clones the current process (cheaply, with copy-on-write pages), then exec() replaces the clone's program. Between them the child can redirect files, change directories or drop privileges with ordinary calls. Windows does everything in one CreateProcess() call with a long list of parameters (command line, environment, inherited handles, startup info). This model counts the steps each needs to start sort with its output redirected to a file:
def linux_spawn(cmd, stdout_file):
return [
"fork() -> the child is a copy of the shell (copy-on-write)",
f"child: open('{stdout_file}') -> fd 3",
"child: dup2(3, 1); close(3) -> stdout now goes to the file",
f"child: execve('/usr/bin/{cmd}') -> the child becomes {cmd}",
"parent: waitpid(child)",
]
def windows_spawn(cmd, stdout_file):
return [
f"CreateFileW('{stdout_file}') -> handle, marked inheritable",
"STARTUPINFO.hStdOutput = that handle",
f"CreateProcessW('{cmd}.exe', ..., bInheritHandles=TRUE, &si)",
"parent: CloseHandle(file); WaitForSingleObject(process)",
]
for name, steps in [("Linux", linux_spawn("sort", "out.txt")),
("Windows", windows_spawn("sort", "out.txt"))]:
print(f"{name}:")
for i, s in enumerate(steps, 1):
print(f" {i}. {s}")Linux:
1. fork() -> the child is a copy of the shell (copy-on-write)
2. child: open('out.txt') -> fd 3
3. child: dup2(3, 1); close(3) -> stdout now goes to the file
4. child: execve('/usr/bin/sort') -> the child becomes sort
5. parent: waitpid(child)
Windows:
1. CreateFileW('out.txt') -> handle, marked inheritable
2. STARTUPINFO.hStdOutput = that handle
3. CreateProcessW('sort.exe', ..., bInheritHandles=TRUE, &si)
4. parent: CloseHandle(file); WaitForSingleObject(process)
File systems and paths
| Linux | Windows | |
|---|---|---|
| Root | one tree starting at / |
one tree per volume: C:\, D:\ (plus \\server\share) |
| Separator | / |
\ (most APIs also accept /) |
| Case | sensitive: Readme ≠ README |
insensitive but case-preserving (per-directory opt-in for WSL) |
| Forbidden name characters | only / and NUL |
`< > : " / \ |
| Main file system | ext4, XFS, Btrfs | NTFS (ReFS on servers) |
| Hidden files | name starts with . |
hidden attribute |
| Executable | x permission bit |
file extension (.exe, .bat, .ps1) |
| Max path | 4096 bytes | 260 characters by default (long paths opt-in) |
Case sensitivity is the classic trap: code that works on Windows because import "./Utils" finds utils.js fails on Linux. In the Linux sandbox:
mkdir demo && cd demo
echo one > Report.txt
echo two > report.txt
ls
cat REPORT.txt 2>&1Report.txt
report.txt
cat: REPORT.txt: No such file or directory
On NTFS the second echo would overwrite the first file, and type REPORT.txt would print two.
Line endings
Windows text files traditionally end lines with CR LF (\r\n, bytes 0d 0a); Linux and macOS use LF (\n). Most modern editors handle both, but shells don't: a bash script saved with CRLF fails with #39;\r': command not found, because the \r becomes part of each command. od -c makes the invisible bytes visible:
printf 'echo hello\r\necho world\r\n' > from-windows.sh
od -c from-windows.sh | head -n 2
tr -d '\r' < from-windows.sh > fixed.sh
od -c fixed.sh | head -n 2
bash fixed.sh0000000 e c h o h e l l o \r \n e c h o
0000020 w o r l d \r \n
0000000 e c h o h e l l o \n e c h o
0000020 w o r l d \n
hello
world
dos2unix does the same conversion, and Git can do it automatically (core.autocrlf, or better a .gitattributes file with * text=auto and *.sh text eol=lf).
Paths between the two worlds
When the two systems meet (WSL, Samba shares, cross-platform tools), paths must be converted. This function does what WSL's wslpath does for drive paths:
def to_wsl(win_path):
drive, rest = win_path[0].lower(), win_path[2:]
return f"/mnt/{drive}" + rest.replace("\\", "/")
def to_windows(wsl_path, distro="Ubuntu"):
if wsl_path.startswith("/mnt/") and len(wsl_path) > 5:
drive = wsl_path[5].upper()
return f"{drive}:" + wsl_path[6:].replace("/", "\\")
return f"\\\\wsl.localhost\\{distro}" + wsl_path.replace("/", "\\")
for p in [r"C:\Users\ada\Documents", r"D:\data\logs"]:
print(f"{p:<26} -> {to_wsl(p)}")
for p in ["/mnt/c/Program Files", "/home/ada/projects"]:
print(f"{p:<26} -> {to_windows(p)}")C:\Users\ada\Documents -> /mnt/c/Users/ada/Documents
D:\data\logs -> /mnt/d/data/logs
/mnt/c/Program Files -> C:\Program Files
/home/ada/projects -> \\wsl.localhost\Ubuntu\home\ada\projects
Daily administration
| Task | Linux | Windows |
|---|---|---|
| Shell | bash, zsh | PowerShell, CMD |
| Background services | systemd units, systemctl |
services, Get-Service, sc.exe |
| Logs | journalctl, /var/log |
Event Viewer, Get-WinEvent |
| Scheduled jobs | cron, systemd timers | Task Scheduler, schtasks |
| Users & permissions | UID/GID, rwx, sudo |
SIDs, ACLs, UAC |
| Processes | ps, top, kill |
Task Manager, Get-Process, Stop-Process |
| Kernel parameters | sysctl, /proc/sys |
registry, bcdedit |
| Signals / termination | SIGTERM, SIGKILL |
WM_CLOSE, Ctrl+C events, TerminateProcess |
| Updates | package manager updates everything | Windows Update + app updaters/winget |
| Remote shell | SSH | PowerShell Remoting (WinRM), OpenSSH, RDP |
Under the hood both kernels do the same jobs: preemptive priority scheduling, demand-paged virtual memory with copy-on-write, a page cache, journaling file systems, a TCP/IP stack, loadable drivers. The differences are mostly in the interfaces and conventions above, which is why WSL, Git's line-ending settings and cross-platform runtimes (Python, Node.js, .NET, Java) can hide most of them.
Learn more: WSL & Hyper-V · Processes · Signals & Console Events
Test yourself
A bash script edited on Windows fails with