You are on page 1of 4

ASSIGNMENT NO.

Deadline

Your assignment must be uploaded/submitted at or before 30th April 2008.

Uploading instructions

Please view the assignment submission process document provided to you by


the Virtual University to upload the assignment.

Rules for Marking

It should be clear that your assignment will not get any credit if:

o The assignment is submitted after due date.


o The submitted assignment does not compile or run.
o The assignment is copied.

Objective

The objective of this assignment is to provide an on hand experience of:


o Basic Unix/Linux commands
o fork(), execlp() system calls
Assignment No. 1

Important Instructions

It is recommended that before answering the following questions you test the commands
on some popular Linux Operating System. Also, if you want to test the code, you need to
have gcc compile installed on your Linux system.

1- Describe each of the following commands: (16 marks)

1. ls -al
2. mkdir -p /home/munir/courses/cs604
3. rm –rf directory1 directory2
4. pwd
5. cp –ir /home/user1/directory1 /home/user2/directory2
6. mv *.c ./cfiles
7. ls –l > list
8. ps fax | less

2- Answer the following short questions: (14 marks)

1. What is the difference between cat and more commands?

2. If our current working directory is /home/user1/dir1/subdir1 and we


want to move to the directory /home/user2/dir5, then what are the two
possible choices to change to the desired directory?

3. What is the command to display the user name with which you have logged in?

4. What does the /etc/shadow file contain?

5. What is the difference between statically linked and dynamically linked


executable files?

6. What is the command to create a compressed archive (archive1.tar.gz) of


files test1 test2 and test3.

7. In Linux Operating System, what file extension is used for executable files?
3- What would be the output of the following code segment, if the current working
directory contains the following files and directories: .bashrc, .profile,
.private, test.c, main.c, courses, personal. (5 marks)

main()
{
pid_t childpid;

childpid = fork();
if (childpid == -1) {
printf(“fork failed.\n”);
exit(1);
}
if (childpid == 0) {
if (execlp (“/bin/ls”, “ls ./”, NULL) < 0) {
printf(“exec failed.\n”);
exit(1);
}
}
}

4- Consider the following code segment, how many times “hello, world” would
be printed, if every fork() call is successful. (5 marks)

main()
{
fork();
printf(“hello, world\n”);
fork();
fork();
printf(“hello, world\n”);
fork();
fork();
printf(“hello, world\n”);

exit(0);
}

Assignment submission instructions:


Your Assignment should be a well formatted word document. For
more help you can view the handouts of ‘Operating Systems” CS604 at LMS
from lessons 1-7.

You might also like