Linux Shell
Youtube Video link https://youtu.be/p4SxIsuDCMs
- Install Clang compiler
- cd Assignment_6
- cd part1
- clang -o prog shell.c
- Congratulations you are now in the minishell
I've developed a Mini Shell in C, a command-line interface inspired by popular shells like Bash. This Mini Shell project serves as a bridge between users and the operating system, allowing them to execute various commands. It's a versatile and expandable project that can be used as a foundation for further development.
Here's an overview of the key features of this Mini Shell:
I've implemented a signal handler in the shell, allowing it to respond to signals sent to processes. Signal handlers are essential for managing processes and handling events in the operating system. For instance, pressing Ctrl+C
sends a signal that can be caught and handled by the shell's signal handler.
This Mini Shell project is designed to provide a user-friendly command-line interface with several important features:
-
Prompt: The shell displays the prompt "mini-shell>" before each command, providing a clear indication of where user input is expected.
-
Input Limit: The maximum input size is set to 80 characters per line, ensuring efficient parsing and execution.
-
Signal Handling: I've implemented a signal handler that responds to
Ctrl+C
. When the user pressesCtrl+C
, the shell displays "mini-shell terminated" and ensures that all child processes are terminated as well. -
Foreground Execution: By default, child processes run in the foreground until their execution is completed. This behavior mimics typical shell behavior.
-
Pipes: The shell supports pipes (
|
) for chaining commands together. Users can create pipelines to process data through a series of commands. -
Built-in Commands:
cd
: Change the current working directory.help
: Display information about available built-in commands.exit
: Terminate the shell.history
: Keep track of user input commands and display them upon request.
-
Error Handling: The shell provides informative error messages for command not found and offers suggestions for similar commands.
To use this Mini Shell:
-
Compile the shell program.
gcc mini-shell.c -o mini-shell
-
Run the shell.
./mini-shell
-
Start typing commands with the "mini-shell>" prompt.
You can test various commands, including built-in commands like cd
, help
, exit
, and the custom history
command. Experiment with pipes to chain commands together and explore the shell's functionality.