Skip to content

A lightweight, interactive Unix-like shell implemented in C for mastering Linux system calls. Provides robust command execution, background job management, and support for special variables ($$, $?). Includes signal handling, process control, and inter-process communication via pipes.

License

Notifications You must be signed in to change notification settings

SanjaiScript/-MiniShell-Interactive-Unix-like-Shell-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniShell – Interactive Unix-like Shell


Description

MiniShell (msh) is a minimalistic Unix-like shell implemented in C as part of the Linux Internal module.
It allows execution of built-in commands, external programs, background jobs, and supports signals, pipes, and job control.

The project helps in understanding system calls, process management, signal handling, and command parsing.


Features

  • Customizable prompt (PS1)
  • Built-in commands: cd, pwd, exit
  • Special variables:
    • $$ – PID of msh
    • $? – Exit status of last command
    • $SHELL – Shell executable path
  • Background process support (&)
  • Job control commands: jobs, fg, bg
  • Signal handling: Ctrl+C (SIGINT), Ctrl+Z (SIGTSTP)
  • Pipe functionality: Multiple processes communication (ls | wc, ls -l /dev | grep tty | wc -l)

Installation

  1. Clone the repository:

bash git clone [email protected]:SanjaiScript/-MiniShell-Interactive-Unix-like-Shell-.git


Navigate to the project folder:

cd MiniShell-Interactive-Unix-like-Shell


Compile the C files:

gcc *.c -o msh


Usage

Run the shell: ./msh


Sample commands inside MiniShell:

msh> pwd

msh> echo Hello World!

msh> ls -l | grep ".c"

msh> sleep 10 &

msh> jobs

msh> fg

msh> exit


Change prompt:

PS1=NewPrompt>

Debug / Sample Output


MiniShell> pwd /home/linux_engineer

MiniShell> ls -l -rw-r--r-- 1 user user 1024 Jan 12 12:00 main.c

MiniShell> sleep 10 & DEBUG: Created background process with PID 12345

MiniShell> jobs [1]+ 12345 Running sleep 10 &

MiniShell> fg Bringing PID 12345 to foreground

MiniShell> exit INFO: Exiting MiniShell. Goodbye!


Author

Sanjai Kumar M @SanjaiScript

About

A lightweight, interactive Unix-like shell implemented in C for mastering Linux system calls. Provides robust command execution, background job management, and support for special variables ($$, $?). Includes signal handling, process control, and inter-process communication via pipes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages