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

Unix and Shell Programming Exam Questions

This document is an examination paper for the B.Sc. (CS) Degree at Sacred Heart College, focusing on UNIX and Shell Programming. It includes various sections with questions on shell types, file permissions, commands, scripting, and system calls, requiring detailed answers and practical examples. The exam is structured into three sections, with varying marks allocated to each question.

Uploaded by

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

Unix and Shell Programming Exam Questions

This document is an examination paper for the B.Sc. (CS) Degree at Sacred Heart College, focusing on UNIX and Shell Programming. It includes various sections with questions on shell types, file permissions, commands, scripting, and system calls, requiring detailed answers and practical examples. The exam is structured into three sections, with varying marks allocated to each question.

Uploaded by

tonybaskar83
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SACRED HEART COLLEGE(AUTONOMMOUS), TIRUPATTUR, VELLORE DT .

[Link] .(CS)Degree VI Semester November 2017


Time : 3Hrs [Link] : 75

CS622A-ELECTIVE-II:UNIX AND SHELL PROGRAMMING

Section –A (10 X 2 =20 Marks)


Answer ALL the questions.
1. What are the different types of shell in Unix?
2. How will you change the file permission?
3. Define Touch command.
4. What is the difference between the commands compress and pack?
5. Define read and echo statement.
6. List out the logical operators used in shell programming.
7. Develop a shell script for printing the command line arguments.
8. State the uses of break and continue keywords in Unix shell programming.
9. Define Unix system call.
10. What is the purpose of using the lseek() System call?
Section –B (5 x 5 =25 Marks)
Answer all the questions.
11.a) Explain the following three types of terminals connected to the host machine.
• Dumb Terminal
• Terminal Emulation
• Dial-in Terminal
(Or)

b) Describe all the directory related commands with example.


12.a)Write a detailed note on I/O Redirection and piping.
13.a) Describe the Unix communication commands write and wall with an example.
(Or)
b)Develop a shell script to obtain the division obtained by the student. The marks obtained by the
students in 5 different subjects are input through the keyboard. The student gets division as per the
following rules.
Percentage above or equal to 60 : First Division
Percentage between 50 to 59 : Second Division
Percentage between 50 to 59 : Second Division
Percentage Less than 40 : Fail
14.a) Explain while and until looping statements with its flowcharts.
(Or)
b) Write a shell program to find out the factorial of given numbers.
15. a)Describe the fork() system call with suitable example.
(Or)
b) Write a c program to generate the Fibonacci sequence in the child processing using fork() system
call.
Section –C (3 x 10 =30 Marks)
Answer any THREE questions.
16. Describe the salient features of Unix operating system.
17. Explain the following process scheduling commands with example.
a ) wc b ) sort c ) cut d) grep
18. Write a shell program to generate the pay bill. The user gets basic salary as input and calculates the
Allowance, Deduction, Gross and Net Salary. (Allowance : DA=65% HRA=15%, MA=5%. Deduction:
PF=12% and IT=5%)
19. Write a Shell script to check whether the inputted string is palindrome or not.
20. Explain the following fie structure related system calls with its prototype.
a) creat()
b) open()
c) close()
d)read()
e)write()
=*=

Common questions

Powered by AI

These system calls form the foundation of file handling in Unix. 'creat()' initializes a new file with specific permissions, 'open()' accesses files, 'close()' ends file interaction, 'read()' retrieves data, and 'write()' saves data to files. Their correct use ensures data integrity and system stability, highlighting Unix’s robust file management capabilities .

The fork() system call creates a new process by duplicating the calling process, enabling parallel execution of tasks. It is fundamental for tasks like managing concurrent operations, handling client-server architectures, and running background jobs. The new process, or child process, can execute different tasks while sharing code with the parent, enhancing process efficiency and control .

The command wc (word count) counts words, lines, and characters, aiding in file statistics. Sort orders lines of text files, providing organized outputs necessary for data management. Cut extracts sections from each line of files, allowing specific data manipulation. Grep searches files for matching patterns, essential for data retrieval and filtering. Together, these commands enhance data processing capabilities in Unix systems .

Unix is known for its portability, multitasking, and multi-user capabilities. Its powerful command-line interface provides direct interaction with the system kernel, offering flexibility and control. The modular design of Unix, with small single-purpose tools, allows users to build custom solutions. These features make Unix a robust, efficient, and versatile operating system, suitable for various computing environments .

Dumb terminals are basic text presentation devices that do not process data on their own; they rely entirely on the host machine for processing. Terminal emulation allows a device to mimic the functionality of a terminal within a software program, providing flexibility in accessing different host systems. Dial-in terminals use telecommunication lines to connect to a host machine, enabling remote access but potentially reducing speed and interactivity due to the limitations of telecommunication bandwidth .

I/O Redirection allows the redirection of input and output streams to and from files or other commands, which enhances automation and efficiency. Piping connects the output of one command directly as input to another, creating complex command sequences that perform advanced data processing tasks. Both techniques facilitate efficient command execution, reduce redundant data handling, and improve task automation .

Unix shell scripts process command line arguments using positional parameters like $1, $2, etc., representing each argument. Scripts can utilize these to perform operations based on input parameters, such as configuring scripts for different runtime conditions. Typical use cases include automated backups, system monitoring, and deployment tasks, where user input tailors the script's execution .

File permissions in Unix can be changed using the chmod command, which alters the read, write, and execute permissions for the owner, group, and others. These permissions are critical for system security as they control access rights, ensuring only authorized users can modify or execute the files. Incorrect permissions can lead to unauthorized access or data loss .

The break statement is used to exit a loop prematurely, which is useful when a certain condition is met. The continue statement skips the current iteration of a loop and proceeds to the next one. These commands allow for greater control and flexibility in iterative processes, such as terminating infinite loops or skipping certain iterations based on dynamic conditions within the code .

The 'while' loop continues execution as long as its test condition remains true, making it suitable for indefinite iteration where conditions vary dynamically. The 'until' loop continue until its test condition becomes true, ideal for scenarios where the terminating condition is clearer from the start. Both enhance script control, allowing precise execution flow and decision-making .

You might also like