GitHub - mertugr/OS-Shell: Operating System Shell · GitHub
Skip to content

mertugr/OS-Shell

Folders and files

Repository files navigation

OS-Shell

A small UNIX-like shell written in C++ that simulates an in-memory file system with persistence. The file tree is held in memory while the shell is running and serialized to filesystem_state.txt on exit, so it is restored on the next launch.

Build

Requires a C++11 compiler (tested with g++).

make compile

Or directly:

g++ -std=c++11 -Wall -Wextra -o shell main.cpp

make alone will clean, compile, and launch the shell.

Run

./shell

A prompt like 02:47:32 /> is shown — the current time and the working directory inside the simulated file system.

Type help to see the command list, or exit to save state and quit.

Commands

Command Description
ls List contents of the current directory
pwd Print the current directory path
cd <path> Change directory (.. for parent, / for root)
mkdir <name> Create a new directory
touch <name> Create an empty regular file
cat <name> Display file contents
echo <name> <text> Write text to a file (overwrites existing)
cp <src> <dst> Copy a file
link <src> <dst> Create a soft link pointing to src
rm <name> Remove a file, directory, or link
help Show the command list
exit Save state to disk and quit

Features

  • Three file types: regular files, directories, and soft links.
  • Persistence: on exit, the entire tree (including soft links) is written to filesystem_state.txt and restored on startup.
  • Per-directory disk quota: each directory is capped at 10 MB of direct content; addFile rejects with an error if the limit is exceeded.
  • Broken-link detection: if a soft link's target is removed with rm, the link is marked broken and cat reports it instead of crashing.
  • Duplicate-name protection: creating two entries with the same name in the same directory is rejected.

Project layout

.
├── main.cpp       # all shell, file-system, and serialization code
├── makefile       # clean/compile/run targets
├── .gitattributes
├── .gitignore
└── README.md

About

Operating System Shell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors