A custom Unix-like shell developed in C that replicates core functionalities of standard Linux shells while providing several custom utilities for process management, file exploration, and system monitoring.
The project explores fundamental Operating Systems concepts such as process creation, signal handling, inter-process communication, terminal control, filesystem traversal, and command execution.
- Execute standard Linux system commands.
- Support for multiple commands in a single input using
;. - Background execution using
&. - Dynamic shell prompt displaying:
- Username
- System hostname
- Current working directory.
- Relative path handling similar to conventional Unix shells.
- Robust tokenization and parsing logic.
- Handles:
- Multiple spaces and tabs.
- Quoted strings.
- Multiple commands in a single line.
- Supports combinations of:
- Background processes
- Pipes
- Redirection
Custom directory navigation command.
Supports:
hop .
hop ..
hop ~
hop <directory>Allows sequential navigation through multiple directories.
Custom file listing utility similar to ls.
Supports:
reveal
reveal -a
reveal -l
reveal -laFeatures:
- Hidden file listing (
-a) - Detailed file information (
-l) - Multiple occurrences of flags handled gracefully
Examples:
reveal
reveal -aaa
reveal -l
reveal -la
reveal -alllBehavior:
| Command | Equivalent |
|---|---|
| reveal | reveal -a |
| reveal -aaa | reveal -a |
| reveal -laa | reveal -l |
| reveal -alll | reveal -l |
Command history management utility.
Features:
- Stores last 15 commands.
- Displays command history.
- Clears history.
- Re-executes previous commands.
Displays information about a process.
Usage:
proclore
proclore <pid>Information displayed:
- Process status
- Process group
- Memory usage
- Executable path
Uses the Linux /proc filesystem.
Recursive file and directory search utility.
Usage:
seek <flags> <search_term> <directory>Features:
- Search files
- Search directories
- Permission checks
- Search with or without extensions
Examples:
seek main .
seek -f main .
seek -d src .Displays all processes spawned by the shell.
Information shown:
- Command name
- PID
- Process state
Output is maintained in lexicographic order.
Example:
activitiesSample output:
sleep : 12345 : Running
vim : 12350 : Stopped
Sends signals to processes.
Usage:
ping <pid> <signal_number>Example:
ping 12345 9Supported signal numbers:
0 - 31
Brings a background process to the foreground.
Usage:
fg <pid>Resumes a stopped process in the background.
Usage:
bg <pid>Monitors newly created processes in the system.
Usage:
neonate -n <time_interval>Example:
neonate -n 3Uses:
/procreaddir()select()
to periodically display newly created process IDs.
Fetches Linux man pages from the internet using sockets.
Usage:
iMan <command>Example:
iMan grepRetrieves documentation from:
and prints the contents directly to the terminal.
Supports standard Unix redirection operators.
command > output.txtcommand >> output.txtcommand < input.txtsort < input.txt > output.txtSupports arbitrary-length pipelines.
Examples:
cat file.txt | grep errorcat file.txt | grep error | sortcat file.txt | grep error | sort | uniqPipelines are executed from left to right using process chaining and inter-process communication.
Supports combinations of pipes and redirection.
Examples:
cat file.txt | grep error > output.txtsort < input.txt | uniq > output.txtcat log.txt | grep warning | sort > warnings.txtSupports:
- Foreground processes
- Background processes
- Process suspension
- Process continuation
Example:
sleep 60 &Output:
[1] 12345
The shell correctly handles common terminal signals.
- Terminates foreground process.
- Shell remains active.
- Stops foreground process.
- Moves process to background job list.
- Gracefully exits the shell.
- Terminates active child processes.
Supports shell customization through a .myshrc file.
Example:
alias ll="reveal -la"Example:
mk_hop()
{
mkdir $1
hop $1
}Example:
hop_seek()
{
hop $1
seek $2 .
}This project extensively uses:
- Process creation using
fork() - Program execution using
execvp() - Process synchronization using
wait()andwaitpid() - Signal handling using
signal()andkill() - Inter-process communication using
pipe() - Filesystem traversal using
opendir()andreaddir() - Process introspection through
/proc - Terminal management using
tcgetattr()andtcsetattr() - Socket programming for online man-page retrieval
.
├── src/
│ ├── shell.c
│ ├── parser.c
│ ├── hop.c
│ ├── reveal.c
│ ├── seek.c
│ ├── proclore.c
│ ├── activities.c
│ ├── neonate.c
│ ├── ping.c
│ ├── iman.c
│ ├── redirection.c
│ ├── pipes.c
│ └── signals.c
│
├── include/
│ └── *.h
│
├── myshrc
│
└── README.md
Compile using GCC:
gcc *.c -o myshOr using Make:
make./myshuser@system:~> reveal -la
user@system:~> seek main .
user@system:~> sleep 30 &
[1] 12453
user@system:~> activities
sleep : 12453 : Running
user@system:~> cat file.txt | grep error | sort > output.txt
user@system:~> proclore 12453- Written entirely in C.
- Modular architecture with separate source and header files.
- Linux process management and job control.
- Custom command implementation.
- Arbitrary-length pipeline support.
- Combined pipe and redirection support.
- Online man-page retrieval using sockets.
- Persistent command history management.
- Extensive error handling for robust shell execution.
- Tab completion
- Environment variable expansion
- Shell scripting support
- Command auto-suggestions
- Advanced job scheduler
- Command timing and profiling
- Plugin architecture for custom commands
Prakhar Gupta
B.Tech, Electronics and Communication Engineering
Indian Institute of Information Technology Design and Manufacturing (IIITDM) Kancheepuram