This is a Linux Shell implemented in C.
make
./shell_yeah
quit
-
ls [-l -a] <dir1> <dir2>- List files and Directoryls: List of all the files and directories in the current directory in alphabetical orderls -a: Hidden filesls -l: Long listingls -al/l -la/ls -l -a/ls -a -l: Long listing with hidden files
-
cd <dir>- Change Directorycd ..: Change to previous directorycd .: Remain in current directorycd: Change to directory to ~/
-
echo [arguments]- Print in Terminalecho: Print "\n"echo "text": Print "text"echo 'text': Print 'text'echo text: Print text
-
history [number]- Display History of Commandshistory: Last 10 commandshistory [1-20]: Last n commands
-
pwd- Present Working Directory -
pinfo [pid]- Process Informationpinfo: Process information about the shellpinfo <pid>: Process information about process with given pid
-
setenv [var] [value]- Sets value of environment variablesetenv [var]: Default value = " "setenv [var] [value]: var = value
-
unsetenv [var]- Unsets value of environment variable -
jobs- Prints a list of all running jobs -
kjobs [job_num] [sig_num]- Sends signal val to that process with job_num -
overkill- Kills all background process -
bg [job_num]- Changes a Stopped background job to a Running -
fg [job_num]- Brings a background job to foreground -
<command> &- Run Process in Background -
<command1> | <command1>- Multiple Piping allowed -
Redirection- I/O Redirection allowed<: Input redirection>: Output redirection>>: Append
CTRL-C- Sends SIGINT signal to the current foreground job
-
headers.h- Header files
- Global variables
- Function declarations
-
main.c- main(): Main function to initialise variables and call the loop
- shell_loop(): Runs the main loop of the code for the continuous execution of the shell
-
bgfg.c- bg(): Changes a Stopped background job to a Running
- fg(): Brings a background job to foreground
-
background.c- background(): Forks the existing process and runs a child process in the background. Once the child terminates, the exit status of the child process prints on the screen.
-
foreground.c- foreground(): Forks the existing process and runs a child process in the foreground. The parent process resumes once the child terminates and waits till then.
-
cd.c- cd(): Changes the directory based on absolute or relative path provided
-
echo.c- echo(): Prints a string argument on the terminal (stdout). Handles cases with and without quotes.
-
env.c- set(): Changes value of environment variable
- unset(): Detroys the environment variables
-
ls.c- ls(): Initialises flags for listing directories specified by absolute or relative path
- print_ls(): Prints the files in directory according to arguments
-
jobs.c- print_jobs(): Called when child process dies to print status
- kjob(): Sends signal val to that process with given job_num
- overkill(): Kills all background process at once
-
pinfo.c- pinfo(): Prints the info of the process according to arguments
-
piping.c- piping():
-
pwd.c- pwd(): Print the present working directory
-
redirection.c- redirection(): Allows redirection
-
signals.c- print_status():
- ctrlC():
-
history.c- read_history(): Loads history from previous session.
- update_history(): Updates history
- history(): Prints the history according to arguments
- write_history(): Stores last 20 commands in hist.txt
-
history.txt- Stores upto 20 used commands