Skip to content

A powerful mini shell written in C that supports command execution, pipelines, background and foreground jobs, input/output redirection, history navigation, and signal handling.

License

Notifications You must be signed in to change notification settings

TheNameIsRKS/mini-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mini Shell β€” A Lightweight Unix-Like Shell in C

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.


πŸš€ Features

βœ… Command Execution

  • Execute system commands just like in bash (e.g., ls, cat, grep, etc.)

βœ… Built-in Commands

  • cd β€” Change directory
  • help β€” List built-in commands
  • exit β€” Exit the shell
  • jobs β€” List background jobs
  • fg β€” Bring a background job to the foreground
  • bg β€” Resume a stopped job in the background
  • history β€” 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

▢️ Run ./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.

About

A powerful mini shell written in C that supports command execution, pipelines, background and foreground jobs, input/output redirection, history navigation, and signal handling.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages