This is a simple shell project that allows you to execute basic commands. Below, you'll find some information on how to use the shell and understand its output.
- Compilation: Using
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hshto compile all the files.
ebrahim@ebrahim-desktop:~/medium-shell/simple_shell$ gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh
ebrahim@ebrahim-desktop:~/medium-shell/simple_shell$
- Run the Shell: To start the shell, run the executable
hshin your terminal.
ebrahim@ebrahim-desktop:~/medium-shell/simple_shell$ ./hsh
😃:~$
- Execute Commands: You can execute various commands like
ls,echo,printenvorenvwithin the shell.
😃:~$ ls
error.c execution.c exit.c hsh main.c path.c prompt.c shell.h string1.c string2.c white_space.c
😃:~$
- Listing Files: You can use the
ls -lacommand to list detailed information about files.
😃:~$ ls -la
total 68
drwx------ 2 ebrahim ebrahim 4096 Nov 5 10:15 .
drwxrwxr-x 4 ebrahim ebrahim 4096 Nov 4 09:54 ..
-rw-rw-r-- 1 ebrahim ebrahim 1439 Nov 9 21:23 error.c
-rw-rw-r-- 1 ebrahim ebrahim 639 Nov 9 21:14 execution.c
-rw-rw-r-- 1 ebrahim ebrahim 264 Nov 11 14:36 exit.c
-rwxrwxr-x 1 ebrahim ebrahim 17320 Nov 10 10:15 hsh
-rw-rw-r-- 1 ebrahim ebrahim 294 Nov 4 11:09 main.c
-rw-rw-r-- 1 ebrahim ebrahim 456 Nov 9 21:01 path.c
-rw-rw-r-- 1 ebrahim ebrahim 1123 Nov 4 10:15 prompt.c
-rw-rw-r-- 1 ebrahim ebrahim 792 Nov 4 10:05 shell.h
-rw-rw-r-- 1 ebrahim ebrahim 1528 Nov 6 10:09 string1.c
-rw-rw-r-- 1 ebrahim ebrahim 1009 Nov 6 10:11 string2.c
-rw-rw-r-- 1 ebrahim ebrahim 430 Nov 9 15:30 white_space.c
😃:~$
- Exiting the Shell: To exit the shell, type
exit.
😃:~$ exit
ebrahim@ebrahim-desktop:~/medium-shell/simple_shell$
- Echo command: You can execute the
echocommand to display your argument on the stdout.
😃:~$ echo "love"
"love"
😃:~$ echo "$USER"
"$USER"
😃:~$
- Printing the environment: Insert
envorprintenvto display the systems environment.
😃:~$ env
SHELL=/bin/bash
SESSION_MANAGER=local/ebrahim-desktop:@/tmp/.ICE-unix/2171,unix/ebrahim-desktop:/tmp/.ICE-unix/2171
QT_ACCESSIBILITY=1
COLORTERM=truecolor
...
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
GDMSESSION=cinnamon
ORIGINAL_XDG_CURRENT_DESKTOP=X-Cinnamon
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
TERM_PROGRAM=vscode
_=./hsh
😃:~$
- Cancel running program: By pressing
ctrl + cyou will stop the current running program and start on a new line.
😃:~$ ^C
😟:~$ ^C
😟:~$ ^C
😟:~$ ^C
😟:~$
😃:~$
- The shell supports basic commands like
ls,echo,printenvandenv. - You can list files with detailed information using
ls -la. - There are more commands that can be executed, try it out and see...
Feel free to explore and use this simple shell for your command-line needs! If you have any questions, refer to the code or feel free to reach out. Happy coding!
- Ebrahim Rhode 1ebrahimr@gmail.com