JNTU
JNTU B.Tech III LINUX PROGRAMMING Previous Question Paper (February - 2022 - R15)
Answer any five questions
All questions carry equal marks
Main
What are the responsibilities of Shell?
Answer
The shell acts as a command-line interpreter that serves as the interface between the user and the Linux kernel. Its primary responsibilities include:
- Command Execution: It parses user input, locates the corresponding executable file in the system path, and initiates its execution.
- Input/Output Redirection: It manages the redirection of standard input, output, and error streams using operators like <, >, and >>.
- Piping: It connects the output of one command to the input of another using the pipe (|) operator, facilitating command chaining.
- Environment Management: It maintains and manages environment variables, aliases, and shell functions that define the user's working session.
- Programmability: It supports scripting capabilities, including variables, loops, conditional statements, and functions, allowing for the automation of complex tasks.
- Job Control: It allows users to manage multiple processes, enabling them to suspend, resume, or move processes between the foreground and background.
- Filename Expansion: It performs globbing (wildcard expansion) to match filenames before passing arguments to commands.
Write an awk script to calculate the net salary of an employee based on the working hours.
Answer
To calculate the net salary, we assume a base hourly rate and apply logic for overtime if hours exceed a standard threshold (e.g., 40 hours). The following awk script processes an input file containing employee names and hours worked.
#!/bin/awk -f
BEGIN {
rate = 100;
print "Name\tHours\tNet Salary";
print "---------------------------";
}
{
hours = $2;
if (hours > 40) {
salary = (40 * rate) + ((hours - 40) * rate * 1.5);
} else {
salary = hours * rate;
}
printf "%s\t%d\t%.2f\n", $1, hours, salary;
}This script defines a base hourly rate of 100. For employees working more than 40 hours, it calculates overtime at 1.5 times the base rate. The script expects an input file with the format: Name Hours.
List and explain various text processing utilities in Linux with a clear syntax and examples.
Answer
Sign in to view the complete answer paper.
Write a shell script to demonstrate the usage of ‘if-else’ structure.
Answer
Sign in to view the complete answer paper.
What are the system calls used for file operations? Explain each system call with an example illustration.
Answer
Sign in to view the complete answer paper.
Give the syntax of stat() system call and explain its usage and implementation.
Answer
Sign in to view the complete answer paper.
How to read the contents of a directory? Discuss appropriate system calls used for it.
Answer
Sign in to view the complete answer paper.
Define a signal. Demonstrate the concept of signal generation and handling using signal(), kill() and raise() system calls.
Answer
Sign in to view the complete answer paper.
What are the macros to examine the termination status returned by wait() and waitpid() system calls? Demonstrate various exit status returned with an example code snippet.
Answer
Sign in to view the complete answer paper.
Demonstrate how synchronization between the processes is implemented using semaphores with sample program.
Answer
Sign in to view the complete answer paper.
Describe the following socket APIs with clear syntax:
socket()
Answer
Sign in to view the complete answer paper.
bind()
Answer
Sign in to view the complete answer paper.
listen()
Answer
Sign in to view the complete answer paper.
accept()
Answer
Sign in to view the complete answer paper.