A practical assignment for understanding operating systems concepts through shell implementation and system programming.
This project demonstrates core operating systems principles including process management, system calls, and shell implementation. Students work on building a functional shell that interacts with the OS kernel.
- Understand process creation and management
- Learn about system calls and their use
- Implement command parsing and execution
- Work with file descriptors and redirection
- Handle process synchronization and signals
Prints the names and logins of the program authors.
authors- Shows full names and loginsauthors -l- Shows only loginsauthors -n- Shows only names
Prints the PID (Process ID) of the shell process.
Prints the PPID (Parent Process ID) of the shell.
Displays current date and time.
date- Shows date (DD/MM/YYYY) and time (hh:mm:ss)date -d- Shows only the datedate -t- Shows only the time
Prints system information obtained via uname system call (system name, machine, node name, version, release).
Displays available commands or detailed help for a specific command.
help- Lists all available commandshelp <command>- Shows help for specific command
Changes the current working directory (uses chdir system call).
cd- Without arguments, displays current working directorycd <path>- Changes to specified directory
Prints the current working directory.
Creates a new directory with rwx permissions for owner and rx for others.
Creates a new file with read/write permissions for all users.
Lists directory contents with optional formatting flags.
-hid- Include hidden files-long- Show long format with ownership and permissions-link- Display symbolic link targets-acc- Show access times
Displays detailed information about specific files.
-long- Show long listing (hardlinks, inode, user, group, permissions)-acc- Show access time-link- Show symbolic link target
Lists directories recursively with subdirectories shown after parent content.
Lists directories recursively with subdirectories shown before parent content.
Deletes files and empty directories.
Recursively deletes a directory and all its contents.
Opens a file and adds it to the shell's open file list.
cr- Create file if it doesn't existex- Exclusive accessro- Read-onlywo- Write-onlyrw- Read/Writeap- Append modetr- Truncate file- No arguments - Lists all open files
Closes a file descriptor and removes it from the open file list.
- No arguments - Lists open files
Duplicates a file descriptor using the dup system call.
Allocates memory blocks using various methods.
allocate -malloc <size>- Allocate memory via mallocallocate -createshared <key> <size>- Create shared memory with key and sizeallocate -shared <key>- Attach to existing shared memoryallocate -mmap <filename> <permissions>- Memory-map a file (permissions: r/w/x)- No arguments - Lists all allocated memory blocks
Deallocates memory blocks.
deallocate -malloc <size>- Free malloc block of sizedeallocate -shared <key>- Detach shared memorydeallocate -delkey <key>- Delete shared memory from systemdeallocate -mmap <filename>- Unmap filedeallocate <address>- Free memory at specific address
Fills memory with a character starting at address for specified bytes.
- Default size: 128 bytes
- Default character: 'a'
Displays memory contents in hexadecimal and ASCII format.
- Default size: 128 bytes
Reads file contents into memory at specified address.
Writes memory contents to a file.
Reads from file descriptor into memory address.
Writes from memory address to file descriptor.
Displays memory-related information.
-funcs- Shows addresses of 3 program and 3 library functions-vars- Shows addresses of local, global, and static variables-pmap- Executes pmap/procstat/vmmap to show process memory map-blocks- Lists allocated memory blocks-all- Shows everything
Executes a recursive function n times, displaying stack addresses for automatic and static arrays.
Creates a child process using fork system call and waits for it to complete.
Executes a program in the foreground, waits for completion, and displays exit status.
Executes a program in the foreground with a specified priority.
Executes a program in the background.
Executes a program in the background with a specified priority.
Lists all background processes currently running (PID, owner, priority, creation date, command).
Terminates or signals a background process.
Executes a program without creating a new process (replaces current shell).
Manages the executable search list (directories where shell looks for programs).
search- Lists current directoriessearch -add <directory>- Adds directory to search listsearch -del <directory>- Removes directory from search listsearch -clear- Clears entire search listsearch -path- Imports directories from PATH environment variable
Displays real and effective user IDs of the current process.
Changes the effective UID of the process.
setuid -l- Shows current credentials
Displays environment variable values and memory addresses accessed via environ, getenv(), and main() arguments.
Modifies environment variables.
-a- Add or modify (direct environment modification)-e- Modify if exists (direct environment modification)-p- Use putenv() to modify
Substitutes one environment variable with another.
-a- Always substitute-e- Substitute only if variable exists
Displays process environment.
- No arguments - Shows all environment variables
-addr- Shows address of environ pointer-environ- Shows indexed environ array
Shows command history or executes a previous command.
historic- Displays all commands with index numbershistoric <N>- Executes command number Nhistoric -<N>- Shows last N commands
Terminates the shell and frees all allocated resources.
MIT License - See LICENSE file for details