Skip to content

Joshuaaaar/Custom-Unix-Style-Terminal-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Custom Unix-Style Terminal

A Unix-style command-line shell implemented in C for Linux, designed to replicate core functionality of standard shells such as Bash. This project emphasizes systems programming concepts including process management, signal handling, memory safety, and inter-process communication.

Overview

This project implements a fully functional command-line shell that provides interactive access to the operating system. The shell supports built-in commands, external program execution, background processes, pipes, and basic networking capabilities.

The implementation was developed incrementally, with increasing system-level complexity and strict requirements on correctness, robustness, and memory safety.

See it working

https://youtu.be/GlzD4TRzkZY (First half of the video is demo , second half is explaning code structure)

https://youtu.be/rpkVHCI94vI (First half of the video is demo, second half is explaning code structure)

Features

Core Shell Functionality

  • Interactive command prompt with continuous input processing
  • Command parsing and execution for both built-in and system commands
  • Robust error handling for invalid commands and edge cases
  • Graceful termination on user exit or end-of-input

Built-in Commands

  • echo — print text to standard output
  • cd — change directories with support for relative and parent paths
  • ls — directory listing with optional recursive traversal and depth control
  • cat — display file contents or read from standard input
  • wc — count words, characters, and lines from files or piped input
  • ps — list processes launched by the shell
  • kill — send signals to running processes
  • exit — terminate the shell

Process Management

  • Execution of external programs using fork and exec
  • Background process execution using &
  • Job tracking with completion notifications
  • Signal handling to prevent shell termination on interrupts (e.g., Ctrl+C)

Pipes and I/O

  • Support for Unix-style pipes (|) between commands
  • Input and output redirection
  • Proper handling of standard input streams for piped commands

Environment Variables

  • Definition, replacement, and expansion of environment variables
  • Dynamic memory allocation for variable storage
  • Safe handling of undefined variables

Networking Support

  • Background TCP server initialization
  • Client connections with multiple concurrent clients
  • Message passing between server, clients, and shell
  • Graceful server startup and shutdown

Implementation Details

  • Written entirely in C
  • Compiled using gcc with strict warning and sanitizer flags
  • Uses low-level system calls (fork, exec, pipe, wait, signal)
  • Memory safety verified using AddressSanitizer and debugging tools
  • Designed to never crash regardless of user input

Build Instructions

To compile the shell:

make

To clean build artificats run

make clean

The build process produces a single executable.

Usage

Run the executable and interact with the shell through the command line. The shell behaves similarly to standard Linux shells while supporting additional custom features.

Debugging and Testing

Diagnosed runtime bugs and memory leaks using GDB

Tested extensively against edge cases and invalid input

Verified correct behavior across concurrent processes and signal handling

Author

Joshua Ramnauth Computer Science and Statistics at the University of Toronto

About

A Bash-like Unix shell built in C featuring command parsing, concurrent process execution, I/O redirection, and signal handling on Linux.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors