A custom UNIX shell implementation built from scratch in C as part of BRACU CSE321 (Operating Systems) Lab.
| Feature | Description |
|---|---|
| Command Prompt | Interactive shell prompt (UNIX Shell >) for user input |
| Command Execution | Parse and execute system commands using fork() and exec() |
| Multiple Commands | Execute multiple commands inline using semicolon (;) separator |
| Logical AND | Sequential command execution with && (stops on failure) |
| Input Redirection | Redirect input from files using < operator |
| Output Redirection | Redirect output to files using > (overwrite) or >> (append) |
| Piping | Chain commands with | for unlimited pipe operations |
| Signal Handling | Graceful CTRL+C handling without shell termination |
| Command History | Maintains history of last 20 executed commands |
- GCC compiler
- Linux/Unix environment (or WSL on Windows)
gcc -o shell "UNIX Shell.c"./shellOr use the provided script:
./run-shellUNIX Shell > ls -la
UNIX Shell > pwd
UNIX Shell > echo "Hello World"UNIX Shell > ls ; pwd ; whoamiUNIX Shell > mkdir test && cd test && touch file.txtUNIX Shell > cat < input.txt
UNIX Shell > ls -la > output.txt
UNIX Shell > echo "append this" >> output.txtUNIX Shell > ls -la | grep ".c"
UNIX Shell > cat file.txt | sort | uniq
UNIX Shell > ps aux | grep bash | head -5| Command | Description |
|---|---|
cd [dir] |
Change directory (defaults to $HOME if no argument) |
history |
Display command history (last 20 commands) |
ABOUT |
Show program details and contributor information |
EXIT |
Terminate the shell gracefully |
| Name | Student ID | GitHub |
|---|---|---|
| Al Saihan Tajvi | 23301219 | — |
| Farhan Zarif | 23301692 | @Faustus-Faber |
| Sadik Mina Dweep | 22101837 | @sadikmina |
- ✅ Command prompt display and user input handling
- ✅ Command parsing and execution using
fork()andexec()system calls - ✅ Multiple inline commands with semicolon (
;) separator - ✅ Sequential command execution with logical AND (
&&)
- ✅ Input redirection (
<) usingdup()anddup2() - ✅ Output redirection (
>,>>) usingdup()anddup2() - ✅ Command piping (
|) supporting unlimited pipes
- ✅ Signal handling (
CTRL+C) usingsignal()andsigaction() - ✅ Command history maintenance and display
This project was developed for educational purposes as part of the CSE321 Operating Systems course at BRAC University.
It was an incredible experience collaborating on this project! 🚀
