Skip to content

I've created a Mini Shell in C, mimicking popular shells like Bash. This project acts as a gateway between users and the OS, executing diverse commands. It's a flexible base for future enhancements.

Notifications You must be signed in to change notification settings

ameyagidh/Linux-Shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Linux-Shell

Linux Shell

Youtube Video link https://youtu.be/p4SxIsuDCMs

ssh [email protected]

How to Run this program locally

  1. Install Clang compiler
  2. cd Assignment_6
  3. cd part1
  4. clang -o prog shell.c
  5. Congratulations you are now in the minishell

Introduction

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.

Images

Screenshot 2024-02-23 at 2 22 02 AM

Clear command

Screenshot 2024-02-23 at 2 14 05 AM

cat command

Screenshot 2024-02-23 at 2 14 28 AM

history command shows the commands used

Screenshot 2024-02-23 at 2 16 23 AM

nl command counts the number of lines in the file shell.c

Screenshot 2024-02-23 at 2 16 53 AM

exit

Screenshot 2024-02-23 at 2 21 17 AM

Features

Here's an overview of the key features of this Mini Shell:

Task 1 - Signals

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.

Task 2 - Mini-Shell

This Mini Shell project is designed to provide a user-friendly command-line interface with several important features:

  1. Prompt: The shell displays the prompt "mini-shell>" before each command, providing a clear indication of where user input is expected.

  2. Input Limit: The maximum input size is set to 80 characters per line, ensuring efficient parsing and execution.

  3. Signal Handling: I've implemented a signal handler that responds to Ctrl+C. When the user presses Ctrl+C, the shell displays "mini-shell terminated" and ensures that all child processes are terminated as well.

  4. Foreground Execution: By default, child processes run in the foreground until their execution is completed. This behavior mimics typical shell behavior.

  5. Pipes: The shell supports pipes (|) for chaining commands together. Users can create pipelines to process data through a series of commands.

  6. 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.
  7. Error Handling: The shell provides informative error messages for command not found and offers suggestions for similar commands.

Usage

To use this Mini Shell:

  1. Compile the shell program.

    gcc mini-shell.c -o mini-shell
  2. Run the shell.

    ./mini-shell
  3. 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.

About

I've created a Mini Shell in C, mimicking popular shells like Bash. This project acts as a gateway between users and the OS, executing diverse commands. It's a flexible base for future enhancements.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages