Mini Shell is a lightweight Unix-like command-line interpreter implemented in C. It supports execution of built-in and external commands, piping, signal handling, and a dynamic prompt that displays the current working directory.
This project was developed as part of advanced C and Linux systems programming practice.
- Custom shell prompt (minishell:)
- Dynamic prompt showing current working directory
- Built-in commands (
cd,pwd,echo,exit, etc.) - Execution of external commands using
fork()andexecvp() - Pipe (|) support
- Signal handling (SIGINT, SIGTSTP)
- Process synchronization using wait()
- Input parsing and error handling
- C Programming
- Linux System Calls
- Process Management
- Signals
- File Descriptors and Pipes
minishell/
├── *.c
├── *.h
├── src/
│ ├── *.o
├── Makefile
├── README.md
└── .gitignore
The shell prompt is constructed by concatenating a static identifier (minishell:) with the current working directory.
To optimize performance, the prompt is initialized before the main loop and updated only when the directory changes, i.e., after a successful cd command. This avoids unnecessary getcwd() calls on every iteration while keeping the prompt accurate.
make
./minishell
minishell:/home/pankaj$ pwd
/home/pankaj
minishell:/home/pankaj$ cd projects
minishell:/home/pankaj/projects$ ls | grep shell
minishell:/home/pankaj/projects$ echo Hello World
Hello World
- Understanding how Unix shells interpret and execute commands
- Hands-on experience with fork(), execvp(), and wait()
- Practical implementation of pipes and signal handling
- Improved modular programming and debugging skills
- Exposure to real-world Linux system programming concepts
Pankaj Kumar B.Tech – Electronics & Communication Engineering, Embedded Systems and Linux Programming Enthusiast