UNIX
UNIX turned small tools and a uniform file model into an operating system philosophy. The kernel stays small; the shell composes everything else.
In plain English
UNIX is a toolbox of small tools that connect like pipe pieces.
By the end you will be able to
- Explain the UNIX kernel and shell split.
- Describe the “everything is a file” model.
- Trace fork, exec, and pipe composition.
- Know the role of permissions and multiuser design.
Kernel, shell, and tools
The UNIX kernel manages processes, memory, files, and devices. The shell is a user-level command interpreter that reads commands and launches programs. Small utilities such as grep, sort, and wc do one job and compose through pipes. This design keeps the kernel interface small and lets users build workflows from simple parts.
Everything is a file
Regular files, directories, devices, and pipes are accessed through a common file-descriptor interface: open, read, write, close, seek. A device can be read like a file. This uniformity is powerful, but it also means some operations do not map cleanly to every object.
fork, exec, and pipes
fork() duplicates the current process. exec() replaces the process image with a new program. A shell forks a child, the child execs the command, and the parent waits. A pipe connects the standard output of one process to the standard input of another. Redirection changes the file descriptors before exec.
pid = fork();
if (pid == 0) {
dup2(pipe_write, STDOUT_FILENO);
execvp("grep", argv);
} else {
waitpid(pid, ...);
}Key takeaways
- The kernel provides core services; the shell is a user program.
- UNIX exposes files, devices, and pipes through a common descriptor interface.
- fork creates, exec replaces, and wait collects.
- Pipes compose small tools.
- Permissions and multiuser design are built into the model.
Common pitfalls
- Confusing the shell with the kernel.
- Thinking fork runs a new program; exec does that.
- Assuming every “file” supports every file operation.
Kernel notes
- Explain the kernel/shell split.
- Trace a shell pipeline.
- Know the difference between fork and exec.
Quick check
1. What does the UNIX shell do?
2. Which call replaces the current process image with a new program?