A Unix-style command-line shell implemented in C for Linux, designed to replicate core functionality of standard shells such as Bash. This project emphasizes systems programming concepts including process management, signal handling, memory safety, and inter-process communication.
This project implements a fully functional command-line shell that provides interactive access to the operating system. The shell supports built-in commands, external program execution, background processes, pipes, and basic networking capabilities.
The implementation was developed incrementally, with increasing system-level complexity and strict requirements on correctness, robustness, and memory safety.
https://youtu.be/GlzD4TRzkZY (First half of the video is demo , second half is explaning code structure)
https://youtu.be/rpkVHCI94vI (First half of the video is demo, second half is explaning code structure)
- Interactive command prompt with continuous input processing
- Command parsing and execution for both built-in and system commands
- Robust error handling for invalid commands and edge cases
- Graceful termination on user exit or end-of-input
echo— print text to standard outputcd— change directories with support for relative and parent pathsls— directory listing with optional recursive traversal and depth controlcat— display file contents or read from standard inputwc— count words, characters, and lines from files or piped inputps— list processes launched by the shellkill— send signals to running processesexit— terminate the shell
- Execution of external programs using
forkandexec - Background process execution using
& - Job tracking with completion notifications
- Signal handling to prevent shell termination on interrupts (e.g., Ctrl+C)
- Support for Unix-style pipes (
|) between commands - Input and output redirection
- Proper handling of standard input streams for piped commands
- Definition, replacement, and expansion of environment variables
- Dynamic memory allocation for variable storage
- Safe handling of undefined variables
- Background TCP server initialization
- Client connections with multiple concurrent clients
- Message passing between server, clients, and shell
- Graceful server startup and shutdown
- Written entirely in C
- Compiled using
gccwith strict warning and sanitizer flags - Uses low-level system calls (
fork,exec,pipe,wait,signal) - Memory safety verified using AddressSanitizer and debugging tools
- Designed to never crash regardless of user input
To compile the shell:
makeTo clean build artificats run
make clean
The build process produces a single executable.
Run the executable and interact with the shell through the command line. The shell behaves similarly to standard Linux shells while supporting additional custom features.
Diagnosed runtime bugs and memory leaks using GDB
Tested extensively against edge cases and invalid input
Verified correct behavior across concurrent processes and signal handling
Joshua Ramnauth Computer Science and Statistics at the University of Toronto