Skip to content

anoushkanarang/Linux-Shell

Repository files navigation

Linux Shell

This is an implementation of a basic Linux Shell in C using Linux System Calls and inbuilt C libraries

HOW TO RUN?

DEPENDENCIES
  1. Git
  2. GCC Compiler
Clone this repository using the command
git clone https://github.com/anoushkanarang/Linux-Shell.git
Change the current working directory to Linux-Shell
cd Linux-Shell
run make to execute the program
make

ABOUT

  • shell.c stores the source code of the shell.
  • getcat.c, getdate.c, getls.c, getmkdir.c and getrm.c contain source code for cat, date, ls, mkdir, rm (external) commands respectively.
  • Description.txt contains description of each command executed in the shell.
  • writehistory.txt stores the history of the shell.
  • The remaining text files store the data to be displayed when the help flag of respective commands is called.
  • Makefile is used for compilation.

COMMANDS IMPLEMENTED

INTERNAL
  1. exit command is used to exit the shell where it is currently running.
  2. history command is used to view the commands previously executed on the shell.
    FLAGS IMPLEMENTED
    • --help: displays the help related information.
    • -c: clears the history.
  3. echo command is used to display line of text/string that are passed as an argument.
    FLAGS IMPLEMENTED
    • -e: interprets \n as a new line character and prints everything after \n in a new line, doesn’t take inverted commas into account.
    • -E: prints everything and doesn’t take inverted commas into account.
  4. pwd command is used to print the current directory.
    FLAGS IMPLEMENTED
    • --help: displays the help related information.
    • -L: Softlink for the pwd command.
  5. cd command is used to change current working directory.
    FLAGS IMPLEMENTED
    • --help: displays the help related information.
    • -L: Softlink for the cd command.
EXTERNAL
  1. date command is used to display the system date and time.
    FLAGS IMPLEMENTED
    • --help: displays the help related information.
    • -u: displays date, time in UTC.
  2. cat command reads data from the file and gives their content as output.
    FLAGS IMPLEMENTED
    • --help: displays the help related information.
    • -n: displays the contents of a file preceding with line numbers.
  3. mkdir command is used to create directories.
    FLAGS IMPLEMENTED
    • --help: displays the help related information.
    • -v: It displays a message for every directory created (if the creation was successful or not)
  4. ls command lists directory contents of files and directories.
    FLAGS IMPLEMENTED
    • --help: displays the help related information.
    • -1: used to list each directory in a new line.
  5. rm command is used to remove files, directories, symbolic links from the file system.
    FLAGS IMPLEMENTED
    • --help: displays the help related information.
    • -i: makes the command ask the user for confirmation before removing each file, you have to press y for confirm deletion, any other key leaves the file un-deleted.

Sample Test Case

  echo hello world
  ls -1
  date -u
  mkdir five six seven
  pwd --help
  cat -n date.txt
  date
  history
  cd five
  pwd
  rm five
  exit

About

Implementation of Linux Shell in C.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published