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"./shell
Or use the provided script:
./run-shell
UNIX Shell > ls -la UNIX Shell > pwd UNIX Shell > echo "Hello World"
UNIX Shell > ls ; pwd ; whoami
UNIX Shell > mkdir test && cd test && touch file.txt
UNIX Shell > cat < input.txt UNIX Shell > ls -la > output.txt UNIX Shell > echo "append this" >> output.txt
UNIX 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! π