Docsity

Operating Systems worksheet 1, Assignments of Operating Systems

Toggle sidebar
bg1
Lab 1 (LINUX) | 1
SWER252 OPERATING SYSTEMS
Name : Mohammad Abu Salh Marks
Student ID : 202007723
Instruction: Please do the following activities in sequence.
You need a Linux terminal windows to enter all your commands in sequence.
You will submit a screenshot with some commands of your selection as evidence of doing
this by yourself.
ACTIVITY 1 : BASIC LINUX COMMANDS [10 Marks]
Write down instructions under command column. Each task only uses one line command.
Task Command
1Check your current working directory. $pwd
2List the content of the directory. $ls
3Create a directory with your name. $Mkdir Mohammad
4Change working directory to the directory created
in previous task 3.
cd
amirafatini
cd
amirafatini
cd
amirafatini
$cd Mohammad
5Create 3 directories using your favourite fruits
name.
$mkdir Mango; Strawberry;
watermelon
6
Without changing directory, create a Yusliza
directory under one of those directories created in
task 5.
$mkdir Mango/yusliza
7
Without changing directory, create a Rashidah
directory under one of those directories created in
task 5.
$mkdir Strawberry
/Rashidah
8Change working directory to Rashidah $cd Strawberry/Rashidah
Sami Giacaman – SWER252
pf3
pf4
pf5

Partial preview of the text

Download Operating Systems worksheet 1 and more Assignments Operating Systems in PDF only on Docsity!

SWER252 OPERATING SYSTEMS

Name : Mohammad Abu Salh Marks Student ID : 202007723 Instruction: Please do the following activities in sequence. You need a Linux terminal windows to enter all your commands in sequence. You will submit a screenshot with some commands of your selection as evidence of doing this by yourself. ACTIVITY 1 : BASIC LINUX COMMANDS [10 Marks] Write down instructions under command column. Each task only uses one line command. Task Command 1 Check your current working directory.^ $pwd 2 List the content of the directory.^ $ls 3 Create a directory with your name.^ $Mkdir^ Mohammad 4 Change working directory to the directory created in previous task 3.

cd

amirafatini

cd

amirafatini

cd

amirafatini

$cd Mohammad 5 Create 3 directories using your favourite fruits name. $mkdir Mango; Strawberry; watermelon 6 Without changing directory, create a Yusliza directory under one of those directories created in task 5. $mkdir Mango/yusliza 7 Without changing directory, create a Rashidah directory under one of those directories created in task 5. $mkdir Strawberry /Rashidah 8 Change working directory to^ Rashidah^ $cd^ Strawberry/Rashidah

Create new directory Muhalim under same directory as Rashidah. $Mkdir Muhalim 10 List all directories created under the parent of current working directory $ls 11 From current working directory, create new directory Marina under same directory with Yusliza. $Mkdir Mohammad/Mango/yusliza/ Marina 12 Rename one of the fruits directory in Task 5 into one of your favourite vegetable. $cd Mohammad $mv Mango Cucumber 13 Remove the directories with no sub-directory created in task 5. $rm watermelon 14 Return back to^ /home^ directory^ Cd^ ../ 15 Use tree to draw the complete the file structure of the entire tasks done. ACTIVITY 2 : WRITING A PROGRAM / SOURCE CODE [5 Marks]

  1. Continuing from task (15) in activity 1, make Rashidah your working directory.
  2. By using a terminal, open a simple text editor provided in Ubuntu OS by typing the command either pico or nano. Create a file by using a name of fork1.c.
  3. Type the following simple source code correctly. Use the menu given by the editor. Command: $cd Mohammad/ Strawberry /Rashidah Command: $pico fork1.c

language.

  1. By using a terminal, change your working directory to Marina directory. You need to compile the fork3.c file in that directory.
  2. To compile the source code, you need a compiling command for C programming, which is gcc. Compile the fork3.c file using that command.
  3. Execute the output file generated in the directory. If you didn’t specify the output , a default filename of a.out will be produced
  4. Re-compile the fork3.c, and do specify the output filename in the command as fork3result (use -o option).
  5. Execute the specified output file generated in previous step.
  6. From current working directory, compile the fork1.c file in Rashidah directory. Do specify the output filename as fork1result.
  7. Execute the output file generated (fork1result.)
  8. Remove the a.out file in related directory.
  9. By your words, explain the function fork() and why do you need to use it? Command: $cd Mohammad/Mango/yusliza/Marina Command: $gcc fork3.c Command: ./a.out Command: $gcc fork3.c -o fork3result Command: ./fork3result.out Command: $gcc Mohammad/ Strawberry /Rashidah /fork1.c -o fork1result Command: ./Mohammad/ Strawberry /Rashidah /fork1result Command: rm a.out

is used to create processes.

 fork() returns a zero to the newly created child process.

 fork() returns a positive value if the process is Father value is ID of the

process.

.End of Worksheet 1