Browse Source

0-shel subject and audit

content-update
MSilva95 3 years ago committed by Christopher Fremond
parent
commit
a6f8d93533
  1. 81
      subjects/0-shell/README.md
  2. 85
      subjects/0-shell/audit/README.md
  3. 50
      subjects/0-shell/job-control/README.md

81
subjects/0-shell/README.md

@ -0,0 +1,81 @@
## 0-shell
### Objective
The objective of this project is for you to create a simple [shell](https://en.wikipedia.org/wiki/Shell_script).
Through the `0-shell` you will get to the core of the `Unix` system and explore an important part of this system’s API witch is the process creation and synchronization.
Executing a command inside a shell implies creating a new process, which execution and final state will be monitored by its parents process. This set of functions will be the key to success for your project.
For this project you will only have to create a simple `Unix` interpreter where you can run some of the most known commands. For this part of the project, no advanced functions, pipes or redirection will be asked, you can add them if you like.
### Instructions
- You must program a mini `Unix` interpreter.
- This interpreter must display a simple `$` and wait until you type a command line witch will be validated by pressing enter.
- The `$` will be shown again only once the command has been completely executed.
- The command lines are simple, you will not have pipes, redirection or any other advanced functions.
- You must manage the errors, by displaying a message adapted to the error output.
- You must implement the following commands that will behave exactly like the originals:
- echo
- cd
- ls
- pwd
- cat
- cp
- rm
- mv
- mkdir
- exit
- You must manage the program interruption `Ctrl + D`.
- The project has to be written in a compiled language like (C, Rust, go or other), no semi compiled language like (Pearl and others) are allowed.
- The code must respect the [good practices](https://public.01-edu.org/subjects/good-practices/)
This project will help you learn about:
- Shell
- Operating systems services
- Command-line interfaces
- Unix system
- Process creation and synchronization
- Commands syntax
- Scripting language
### Bonus
You can also do more bonus features like:
- Manage the interruption `Ctrl + C`
- Auto complete when you are writing
- Add piping
- Add redirection
- Have your path behind the `$` like (~/Desktop/0-shell $)
- Add colors for the directories or errors
- Other advanced commands you may like.
### Usage
```
student$ ./0-shell
$ cd dev
$ pwd
dev
$ ls -l
total 0
crw------- 1 root root 10, 58 fev 5 09:21 acpi_thermal_rel
crw-r--r-- 1 root root 10, 235 fev 5 09:21 autofs
drwxr-xr-x 2 root root 540 fev 5 09:21 block
crw------- 1 root root 10, 234 fev 5 09:21 btrfs-control
drwxr-xr-x 3 root root 60 fev 5 09:20 bus
drwxr-xr-x 2 root root 4400 fev 5 09:21 char
crw------- 1 root root 5, 1 fev 5 09:21 console
lrwxrwxrwx 1 root root 11 fev 5 09:20 core -> /proc/kcore
drwxr-xr-x 2 root root 60 fev 5 09:20 cpu
crw------- 1 root root 10, 59 fev 5 09:21 cpu_dma_latency
$ something
Command 'something' not found
$ echo "Hello There"
Hello There
$ exit
student$
```

85
subjects/0-shell/audit/README.md

@ -0,0 +1,85 @@
#### Functional
##### Open the project folder and confirm if the project was written in a compiled programming language.
###### Can you confirm that the project was written in a compiled programming language?
##### Open a terminal and run the project.
###### Can you confirm that the project runs and displays a unix interpreter?
##### Open a terminal and run the project.
###### Can you confirm that this interpreter displays at least a simple `$` and waits for you to type a command?
##### Try to open the project and run a command at your choice.
###### Can you confirm that the interpreter only validates the command if you type enter?
##### Try to open the project and run the command `exit`.
###### Can you confirm that the interpreter terminates properly and gives back the parent's shell?
##### Try to open the project and run the command `echo "something!"`. Do the same in your computer terminal.
###### Can you confirm that the displayed message of the project is exactly the same as the computer terminal?
##### Try to open the project and run the command `echo something else` (without double quotes). Do the same in your computer terminal.
###### Can you confirm that the displayed message of the project is exactly the same as the computer terminal?
##### Try to open the project and run the command `pwd`.
###### Can you confirm that the interpreter displayed the current path?
##### Try to open the project and enter a directory at your choice by using the command `cd dir/at/your/choice`.
###### Can you confirm that the interpreter took you to the correct path? Use `pwd` to confirm.
##### Try to open the project and run only the command `cd`.
###### Can you confirm that the interpreter took you to the users home folder? Use `pwd` to confirm.
##### Try to open the project and run the command `ls` in a directory at your choice. Do the same in your computer terminal.
###### Can you confirm that the output is the same in the project and in your computer terminal?
##### Try to open the project and run the command `ls -l -a -F` in a directory at your choice. Do the same in your computer terminal.
###### Can you confirm that the output is the same in the project and in your computer terminal?
##### Try to open the project and run the commands `mkdir new_folder1` and `mkdir new_folder2` in a directory at your choice.
###### Can you confirm that the directory `new_folder1` and `new_folder2` were created?
##### Try to open the project and run the command `cat new_folder1/new_doc`. Do the same in your computer terminal.
###### Can you confirm that the output is the same in the project and in your computer terminal?
##### Create a document inside the `new_folder1` called `new_doc.txt` with som random text inside. Try to open the project and run the command `cp new_doc.txt ../folder2` to copy the document to the folder `new_folder2`.
###### Can you confirm that the document `new_doc.txt` is inside the `new_folder2`?
##### Try to open the project and run the commands `mv new_folder2 new_folder1` to move the directory `new_folder2` inside of the directory `new_folder1`.
###### Can you confirm that the directory `new_folder2` is inside of the directory `new_folder1`?
##### Try to open the project and run the command `rm -r new_folder1` to remove what was created above.
###### Can you confirm that the directory `new_folder1` was removed?
#### Bonus
###### +Did the student added auto complete when you are writting the commands?
###### +Did the student added piping?
###### +Did the student managed the `Ctrl + C`?
###### +Did the student added colors to the errors or directories?
###### +Did the student added redirection?
###### +Did the student added the current path behind the `$`?
###### +Did the student added any other features or commands to the project?

50
subjects/0-shell/job-control/README.md

@ -0,0 +1,50 @@
## job control
### Objectives
You must follow the same [principles](https://public.01-edu.org/subjects/0-shell/) as the first subject.
Job control refers to the ability to selectively stop (suspend) the execution of processes and continue (resume) their execution at a later point.
In `job control`, you will have to implement the following [builtins](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Job-Control-Builtins):
- jobs
- bg
- fg
- kill
- wait
- suspend
### Instructions
- The project has to be written in a compiled language like (C, Rust or other), no semi compiled language like (Pearl and others) are allowed.
- The code must respect the [good practices](https://public.01-edu.org/subjects/good-practices/)
This project will help you learn about:
- Job control
- Process creation and synchronization
- Commands syntax
- Scripting language
### Usage
```
student$ ./0-shell
$ tar -czf home.tar.gz . &
[1] 8287
$ sleep 50 &
[2] 8870
$ jobs
[1]- Running tar -czf home.tar.gz . &
[2]+ Running sleep 50 &
$ jobs -l
[1]- 8287 Running tar -czf home.tar.gz . &
[2]+ 8870 Running sleep 50 &
$ kill 8287
[1]+ Terminated tar -czf home.tar.gz .
& jobs
[2]+ Running sleep 50 &
$ exit
student$
```
Loading…
Cancel
Save