Mini Shell is a fully functional command-line shell written in C, built from scratch to explore Unix system programming, process management, and signal handling.
It provides core shell functionalities including command execution, I/O redirection, pipelines, background jobs, and command history navigation β all implemented at a low level using POSIX APIs.
β Command Execution
- Execute system commands just like in bash (e.g.,
ls,cat,grep, etc.)
β Built-in Commands
cdβ Change directoryhelpβ List built-in commandsexitβ Exit the shelljobsβ List background jobsfgβ Bring a background job to the foregroundbgβ Resume a stopped job in the backgroundhistoryβ View command history
β Input/Output Redirection
- Output redirection:
>and>> - Input redirection:
< - Error redirection:
2> - Combined redirection:
&>and&>> - File descriptor duplication:
2>&1
β Pipelines
- Chain commands using pipes, e.g.: cat file.txt | grep "hello" | wc -l
β Background & Foreground Jobs
Run commands in background using & sleep 10 & Manage and resume jobs with fg and bg
β Command History
Navigate through previous commands using the Up/Down arrow keys
Persistent history saved in ~/.mini_shell_history
β Signal Handling
Graceful handling of Ctrl+C and Ctrl+D
Proper process reaping with SIGCHLD handler
π§ Learning Objectives This project was designed to deeply understand:
Process creation and management (fork, execvp, waitpid)
Inter-process communication via pipes
Terminal control with termios
Signal handling (SIGCHLD, SIGINT)
Dynamic memory management in C
Building REPL (ReadβEvalβPrint Loop) systems
π§© Build make mini-shell
βοΈ Requirements GCC or Clang compiler POSIX-compatible environment (Linux, macOS, WSL)
π License This project is licensed under the MIT License β feel free to use, modify, and distribute it with attribution.