Professional Documents
Culture Documents
Deadline
Uploading instructions
It should be clear that your assignment will not get any credit if:
Objective
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. 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
3. What is the command to display the user name with which you have logged in?
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);
}