0% found this document useful (0 votes)
95 views

Scr2043 Operating Systems: Ativity 1

The document provides instructions for completing three activities in Linux: 1) Basic Linux commands to create and navigate directories and files. Directories for friends, subjects like "Water" and "Banana" were made. 2) Writing a C program called "fork1.c" using nano editor in the "Banana" directory. Copies were made to other locations. 3) Compiling the C program using gcc compiler, specifying outputs. The program was executed from different directories. Directory structures were redrawn using "tree" command.

Uploaded by

Coolest Person
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

Scr2043 Operating Systems: Ativity 1

The document provides instructions for completing three activities in Linux: 1) Basic Linux commands to create and navigate directories and files. Directories for friends, subjects like "Water" and "Banana" were made. 2) Writing a C program called "fork1.c" using nano editor in the "Banana" directory. Copies were made to other locations. 3) Compiling the C program using gcc compiler, specifying outputs. The program was executed from different directories. Directory structures were redrawn using "tree" command.

Uploaded by

Coolest Person
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lab 1 (LINUX) |1

SCR2043 OPERATING SYSTEMS

Name : Marks
Student ID :
Section :

Instruction: Please do the following activities in sequence. Once completed, ask your lecturer
/ instructor to verify your results by putting his / her initial.
Please make sure the answer is always start with low capital letter.

ATIVITY 1 : BASIC LINUX COMMANDS [10 Marks]

Write down instructions under command column.

You need a terminal window to enter all your commands in sequence.

Task Command
1 Check your current working directory pwd
2 List the content of the directory ls
3 Create a directory with your name.
Change working directory to the
4
directory created in previous task 3.
5 To display your current directory now
Create 3 directories using your best
6
friend’s name.
7 List all created directories available.
Create a directories (Water) under one
8 of those directories created in task 5
without change working directory.
Create a directories (Banana) under
the other one of those directories
9
created in task 5 without change
working directory.
10 Change working directory to Banana
Create new directory Papaya under
11
same directory with Banana.
List all directories created under the
12
parent of current working directory
From current working directory, create
13 new directory Durian under same
directory with Water.
14 Rename Water into another new
2014/2015-2 @ M
Lab 1 (LINUX) |2

name as Watermelon.

Remove the directories with no sub-


15
directory created in task 5.
16 Return back to /home directory
17 Complete the file structure of the entire tasks done. (Hint: use tree command)

ATIVITY 2 : WRITING A PROGRAM / SOURCE CODE [5 Marks]

This activity continuous from the previous activity 1. Write the command in the provided
boxes.

1. Continuing from task (17) in activity 1, go directly to your Banana directory as your
working directory.

Command:

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.

Command:

3. Type the following simple source code correctly. Use the menu given by the editor to do
your task.
2014/2015-2 @ M
Lab 1 (LINUX) |3

#include <stdio.h>
#include <unistd.h>

int main ()
{
int pid;
printf("\nHello World\n");
pid = fork();

if(pid != 0)
printf("I'm the Father and my son's PID is %d\n", pid);
else
printf("I'm the Son\n");

printf("Goodbye Cruel World\n\n");


}

Source: http://www.osix.net/modules/article/?id=641

4. Once you finished typing the source code, save the file using menu WriteOut with
control button.

5. Make a copy of the file in the same directory with name fork2.c.

Command:

6. Make another copy of the fork2.c file into Durian directory with name fork3.c.

Command:

7. Move the fork2.c file in current directory into Papaya directory.

Command:

8. View the content of the file fork1.c without using the editor.

Command:

2014/2015-2 @ M
Lab 1 (LINUX) |4

ATIVITY 3 : COMPILING THE PROGRAM / SOURCE CODE [5 Marks]

This activity continuous from the previous activity 2. Write the command in the provided
boxes. This activity will show the process of compiling the source code written in C
programming language.

1. By using a terminal, change your working directory to Durian directory. You need to
compile the fork3.c file in that directory.

Command:

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.

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
Command:

4. Re-compile the fork3.c, and do specify the output filename in the command as
fork3result (use -o option).

Command:

5. Execute the specified output file generated in previous step.

Command:

6. From current working directory, compile the fork1.c file in Banana directory. Do
specify the output filename as fork1result.

Command:

7. Execute the output file generated (fork1result.)

Command:

8. Remove the a.out file in related directory.

Command:

2014/2015-2 @ M
Lab 1 (LINUX) |5

9. Redraw the final directories and files generated. (Hint: use tree command)
End of Lab1

2014/2015-2 @ M

You might also like