SKP is a Linux BASH like shell written in C. It implements all shell commands and supports pipelining. It also supports foreground and background processes
gcccompiler to run C program.unixbased OS/Environment
- Compile
shell.cfile usinggcc shell.c -o shellcommand to compile. - Run
./shellto execute the shell.
-
Many commands are inbuilt which are explained in the following section. All the other commands which are to be executed in foreground are implemented using
execvp. So, all the commands available in Bash can be executed in SKP. -
The prompt for taking the next command displays the
username,hostnameand thepresent working directory. -
SKP provides option to run processes in background by appeding
&to the end of your command. -
Piping is provided and handled manually from scratch.
-
STATUS(success or failure) of the previous command is displayed along the prompt for the next command. :) of green color denotes success and :( of red color denotes failure. -
SKP provides colorful display giving it a modern look. It also display different color for directories and files when
lscommand is executed.
-
clear- Clears the screen of the shell.
-
pwd- Prints the current working directory.
- Uses the
getcwd()system call.
-
cd [location]- Changes the current working directory to the mentioned directory.
- Implemented using
chdir()system call.
-
ls [-l] [Directory]- Lists all the files and directories in the mentioned directory/directories. If no parameters are passed, lists the contents of current directory.
-lflag lists the long format ofls, providing additional details such as permissions, owner, time of creation etc.- The flags and directories can be provided in any order.
- The output is color coded to distinguish between directories and files.
- Uses the
opendir()andreaddirsystem call
-
history [num]- Gives the
numnumber of previous commands run. Ifnumis not mentioned, prints entire history of commands. - The content is stored in history.txt. It is created when shell is started if it's not existing already.
- Gives the
-
env- Lists all environment variables present in the current session of the shell.
-
mkdir <path>/directoryname- Creates a new empty directory in the
pathgiven with the specified name. - Throws error if folder with same name already exist in that path.
- Implemented using
mkdir()system call.
- Creates a new empty directory in the
-
rmdir <path>/directoryname- Removes the directory in the
pathgiven with the specified name. - Throws error if directory with the specified name doesn't exist in that path.
- Implemented using
rmdir()system call.
- Removes the directory in the
-
exit- Quits the terminal.
- Use this command to ensure proper closing (killing all persisting background processes).
- Ctrl + D provides the same functionality.
- If the first command is
exit, all other arguments are ignored and shell is killed.
-
Any command ending with
&is treated as a background process the shell does not wait for its execution. If such a process requests terminal control, it will be automatically suspended in the background. The shell keeps track of all background processes and alerts the user on their completion. -
| is used for piping of commands, i.e,
stdoutof one command serves asstdinfor the next.
Example:pwd | grep -o "/" | wc -l -
Ctrl + D is an
EOFcharacter and terminates the shell.
-
piping
Contains the implementation of piping usingpipesystem call anddupsystem call. -
background
Implementation of background processes indentified by&. Creates a new child process usingfork()and the shell does not wait for its completion. -
trim
Trailing and leading whitespaces are trimmed from the commands. The quotes are also removed from the commands. -
history.txt
This file contains all previously executed command. The file is opened inreadandappendmode to read from and write to it respectively. This ensures that history is preserved across sessions.
- Arrow keys for command-recall
- Tab for auto completion
stdout/stdin/stderr redirectionusing<and>.- Support multiple commands separted by
;. - Chaining of commands using logical operators like
AND,OR,etc. - Aliasing
- Code Vault YT Playlist
- StackOverflow - for helping in fixing every error I got.
- Linux Man Page



