The shell accepts user commands and executes each command in a separate process, providing basic shell functionalities including process handling, internal commands, and a history feature.
- Command Execution: Executes user commands in separate child processes using
fork()
andexecvp()
. - Background Execution: Allows commands to run in the background by appending
&
at the end of the command. - Internal Commands:
exit
: Exit the shell program.pwd
: Display the current working directory.cd
: Change the current working directory.help
: Display help information on internal commands.
- Shell Prompt: Displays the current working directory in the shell prompt.
- History Feature: Maintains a history of the 10 most recent commands.
history
: Display the 10 most recent commands.!n
: Re-run the command numberedn
from the history.!!
: Re-run the previous command.!-
: Clear all previous commands from the history.
- Signal Handling: Custom signal handler for
SIGINT
to display help information whenCtrl+C
is pressed.
- Linux operating system
- GCC compiler
-
Clone the repository:
git clone https://github.com/ahmad-masud/Linux-Shell cd Linux-Shell
-
Build the project:
make
-
Run the shell:
./shell
- To run a command, simply type it at the prompt and press Enter.
- To run a command in the background, append
&
at the end of the command. - Use internal commands like
pwd
,cd
,exit
, andhelp
as needed. - Use
history
to view recent commands and!n
to re-run a specific command from the history.
/home/user$ ls -l
/home/user$ cd /usr
/usr$ pwd
/usr
/usr$ history
30 history
29 cd /usr
28 ls -l
...
/usr$ !28
ls -l
shell.c
: Main source code for the shell.Makefile
: Build instructions for the project.test_shell.sh
: Testing file for shell.
This project is licensed under the MIT License - see the LICENSE file for details.