0% found this document useful (0 votes)
3 views2 pages

OS Lab VIVA-2

The document provides an overview of essential Linux commands and concepts across various units, including file permissions, shell scripting, system calls for file management, process creation, inter-process communication, and synchronization. Key topics include the use of commands like chmod, cp, mv, and rm, as well as system calls such as fork() and execlp(). It also discusses mechanisms for managing concurrency and data flow between processes.

Uploaded by

emorarey16
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)
3 views2 pages

OS Lab VIVA-2

The document provides an overview of essential Linux commands and concepts across various units, including file permissions, shell scripting, system calls for file management, process creation, inter-process communication, and synchronization. Key topics include the use of commands like chmod, cp, mv, and rm, as well as system calls such as fork() and execlp(). It also discusses mechanisms for managing concurrency and data flow between processes.

Uploaded by

emorarey16
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/ 2

Unit 1: Introduc on to Linux

1. What is the purpose of the chmod command in Linux?

o It changes file permissions (read, write, execute) for the owner, group, or others.

2. Explain the difference between cp, mv, and rm commands.

o cp: Copies files/directories; mv: Moves or renames files; rm: Deletes files.

3. What does the man command do?

o Displays the manual or help pages for a command.

4. What is the role of the lseek system call?

o It reposi ons the read/write file offset, allowing access to a specific posi on in a file.

Unit 2: Shell Programming

5. How do you declare and use variables in a shell script?

o Syntax: VAR=value, use with $VAR. No spaces around =.

6. Explain input/output redirec on in shell.

o >: Redirects output to a file; <: Takes input from a file; >>: Appends output.

7. What is the difference between if, elif, and else statements in shell scrip ng?

o if: First condi on check; elif: Addi onal condi on; else: Executes if all condi ons fail.

8. How is arithme c performed in shell scrip ng?

o Using expr or $(( )), e.g., sum=$((a + b)).

Unit 3: File and Directory Management using System Calls

9. What are the different file-related system calls in Linux?

o open(), read(), write(), lseek(), close().

10. How is opendir() different from open()?

 opendir() opens a directory stream; open() opens a file descriptor.

11. What is the use of readdir()?

 Reads directory entries one by one from a directory stream.

12. Describe the flow of opening, reading, and closing a file using system calls.

 open() → read() (or write()) → close().

Unit 4: Process Crea on and Threading


13. How does the fork() system call work?

 It creates a new child process that is a duplicate of the parent.

14. What is the purpose of execlp()? How is it different from fork()?

 execlp() replaces the current process image; fork() creates a new process.

15. What are threads, and how are they created using pthread in Linux?

 Threads are lightweight processes; use pthread_create() to spawn a new thread.

16. What are environment variables and how can they be accessed?

 Variables that affect process behavior, accessed with getenv() or $VAR in shell.

Unit 5: Inter-Process Communica on (IPC)

17. Explain the working of pipes in Linux.

 Pipes allow data flow between processes; created using pipe() system call.

18. What is shared memory and how is it used for IPC?

 A memory segment shared between processes using shmget() and shmat().

19. How do popen() and pclose() func ons help in IPC?

 popen() runs a command and connects a process’s output/input to a pipe.

Unit 6: Synchroniza on

20. What is a race condi on and how can it be avoided using semaphores or mutexes?

 A race condi on occurs when processes/threads access shared data unsafely.

 Semaphores and mutexes ensure only one process/thread accesses the cri cal sec on at a
me.

You might also like