Operating Systems and Networks Project in C.
- Project Overview
- Features
- Prerequisites
- Installation & Build
- Usage
- Built-in Commands
- Internal Architecture & Functions
- Key Implementation Highlights
- Code Organization
- Testing
- Contributing
- License
This is a Unix-style custom shell implemented in C as an Operating Systems and Networks Project. The shell replicates core functionalities of standard terminals including command parsing, background execution, built-in utilities, job control, history logging, aliasing, piping, redirection, and networked manual pages. It includes modular signal handling, CLI responsiveness, and persistent shell states.
- Dynamic Prompt — Displays
<user@host:cwd>
using~
for home directory - Built-in Commands — Includes
hop
,reveal
,log
,seek
,proclore
,alias
,activities
,ping
, and a bonusneonate
- Background Process Handling — Signals, exit notifications, job tracking
- External Command Execution — Uses
fork
andexec
, supports&
and time tracking - History Logging — Up to 15 entries, with support for purge and re-execution
- Aliasing — Dynamic alias creation and recall during sessions
- Redirection and Piping — Custom logic for both native and external commands
- Modular Codebase — Clean separation of logic across files
- Signal Safety — Handles
ctrl+C
,ctrl+Z
, andctrl+D
gracefully - iMan — Fetches formatted man pages via networking sockets
- Bonus: Neonate Mode — Real-time monitoring of system PIDs
- GCC Compiler (v9.0 or higher recommended)
- Unix/Linux-based OS
- Terminal with POSIX support
make
./a.out
Alternatively:
gcc *.c -o mysh
./mysh
Launch the shell using ./a.out. Sample usage:
<user@host:~> hop Documents
<user@host:~/Documents> reveal -la .
<user@host:~/Documents> sleep 5 &
<user@host:~/Documents> log
<user@host:~/Documents> alias ll = reveal -la
<user@host:~/Documents> ping google.com
<user@host:~/Documents> iMan ls
Use ctrl+D to exit safely.
Command | Description |
---|---|
hop |
Change directory (~ , . , .. , - , full path) |
reveal |
Enhanced ls with color, -a , -l flags |
log |
View past commands, purge log, or re-execute (log execute n ) |
proclore |
Inspect process details using /proc |
seek |
Recursive file/directory search with -d for directory-only mode |
alias |
Define and display dynamic aliases |
activities |
Show all shell-created background processes |
ping |
Ping utility from within the shell |
neonate |
Monitor latest PIDs in real time |
iMan |
Fetch formatted man pages using sockets |
functions.h
— Contains all library includes, globals, and function declarations
main.c
— Initializes shell, calls main loopmain-logic.c
— Handles the core input → parse → execute loop
hop.c
— Implements directory navigationreveal.c
— Customls
with sorting, coloring, and permission logiclog.c
— Persistent command logging systemproclore.c
— Process inspection from/proc/<pid>
seek.c
— Usesnftw()
for recursive searchalias.c
— Dynamic aliasing logic and storageactivities-ping.c
— Background process tracking and signal handlingneonate.c
— Real-time PID monitoringnetworking.c
— Fetches and formats man pages (iMan
)
syscom.c
— Executes system-level commands viaexec
redirection-piping.c
— Implements custom redirection and pipingmisc.c
— Time tracking and prompt formatting functions
- CLI remains intact even after asynchronous signals
- Logs include errors but ignore commands related to
log
itself - Only latest long-running commands get reported with execution time
- Redirection errors from built-in commands are redirected to file
- Aliases are stored dynamically and logged with original command
- Activities are sorted by PID (not lexicographically)
ctrl+D
only triggers exit when no foreground job is active- Global process array tracks all background shell jobs
- Signal handling ensures child/background processes are cleaned properly
.
├── Makefile
├── functions.h
├── main.c
├── main-logic.c
├── hop.c
├── reveal.c
├── log.c
├── syscom.c
├── proclore.c
├── seek.c
├── alias.c
├── redirection-piping.c
├── activities-ping.c
├── neonate.c
├── networking.c
├── misc.c
Each module handles a specific functionality to ensure readability and modularity.
- Sequential and piped command execution
- Foreground and background job management
- Error handling in custom commands
- Alias resolution and redefinition
- Persistent and accurate logging
- Neonate PID monitoring via
/proc
- Socket response validation for
iMan
Pull requests are welcome!
Please maintain modularity and consistency in naming and structure.
Document all added functions with inline comments.
This project is licensed under the MIT License.