Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Mini Unix Shell in C

A lightweight Unix-like shell implemented in C using POSIX system calls. This project demonstrates fundamental operating system concepts such as process creation, inter-process communication, file descriptor management, and signal handling.

✨ Features

  • Execute external commands using fork() and execvp()
  • Built-in commands:
    • cd
    • pwd
    • help
    • exit
  • Input redirection (<)
  • Output redirection (>)
  • Append output redirection (>>)
  • Command pipelines (|)
  • Background process execution (&)
  • Signal handling (Ctrl+C / SIGINT)
  • Modular command parsing and execution

🛠 Technologies Used

  • C
  • POSIX System Calls
  • GCC
  • Linux

📚 Operating System Concepts Demonstrated

  • Process Creation (fork)
  • Program Execution (execvp)
  • Parent-Child Process Synchronization (wait, waitpid)
  • Pipes and Inter-Process Communication (pipe)
  • File Descriptor Duplication (dup2)
  • File Operations (open, close)
  • Signal Handling (sigaction)
  • Input/Output Redirection

🚀 Building the Project

Compile using GCC:

gcc shell.c -o shell

▶️ Running

./shell

Example prompt:

Madhan-Shell :>

💻 Example Commands

Execute a command

ls

Change directory

cd Documents

Print current directory

pwd

Input redirection

sort < input.txt

Output redirection

ls > files.txt

Append output

echo Hello >> output.txt

Pipeline

cat file.txt | grep hello | wc -l

Background process

sleep 10 &

📁 Project Structure

.
├── shell.c
└── README.md

📌 Future Enhancements

  • Command history
  • Tab completion
  • Environment variable expansion
  • Wildcard (*) support
  • Job control (jobs, fg, bg)
  • Command chaining (&&, ||, ;)
  • Quote-aware command parsing

🎯 Learning Outcomes

This project provided hands-on experience with:

  • Process management in Unix/Linux
  • Inter-process communication
  • Shell command parsing
  • File descriptor manipulation
  • Signal handling
  • POSIX programming

📄 License

This project is open source and available under the MIT License.

About

A Unix-like shell implemented in C supporting command execution, pipes, I/O redirection, background processes, built-in commands, and signal handling.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages