0% found this document useful (0 votes)
165 views17 pages

Unix QB

The document provides an overview of the Unix Programming course offered by the Department of Computer Science and Engineering at DSATM. The summary is: The course covers 5 modules on various aspects of Unix programming over 40 lecture hours. Module 1 introduces Unix components, architecture, basic commands, files and permissions. Module 2 covers shells, shell programming and regular expressions. Module 3 discusses Unix file APIs and process control. Module 4 focuses on IPC methods, signals and daemon processes. Module 5 examines signals and daemon processes. Students will be assessed through assignments, exams and a question paper testing knowledge across all modules.

Uploaded by

study material
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)
165 views17 pages

Unix QB

The document provides an overview of the Unix Programming course offered by the Department of Computer Science and Engineering at DSATM. The summary is: The course covers 5 modules on various aspects of Unix programming over 40 lecture hours. Module 1 introduces Unix components, architecture, basic commands, files and permissions. Module 2 covers shells, shell programming and regular expressions. Module 3 discusses Unix file APIs and process control. Module 4 focuses on IPC methods, signals and daemon processes. Module 5 examines signals and daemon processes. Students will be assessed through assignments, exams and a question paper testing knowledge across all modules.

Uploaded by

study material
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/ 17

Unix Programming 2020-2021

UNIX PROGRAMMING
Subject Code 18CS56 IA Marks 40
Number of Lecture hours/week 03 Exam Marks 60
Total Number of Lecture Hours 40 Exam Hours 03
CREDITS – 03

Course objectives: This course will enable students to


 Interpret the features of UNIX and basic commands.
 Demonstrate different UNIX files and permissions
 Implement shell programs.
 Explain UNIX process, IPC and signals.
Syllabus Teaching
Hours
MODULE – 1
Introduction: Unix Components/Architecture. Features of Unix. The UNIX Environment and UNIX
Structure, Posix and Single Unix specification. General features of Unix commands/ command
structure. Command arguments and options. Basic Unix commands such as echo, printf, ls, who, date,
passwd, cal, Combining commands. Meaning of Internal and external commands. The type command:
knowing the type of a command and locating it. The root login. Becoming the super user: su command.
08 Hours
Unix files: Naming files. Basic file types/categories. Organization of files. Hidden files. Standard
directories. Parent child relationship. The home directory and the HOME variable. Reaching required
files- the PATH variable, manipulating the PATH, Relative and absolute pathnames. Directory
commands – pwd, cd, mkdir, rmdir commands. The dot (.) and double dots (..) notations to represent
present and parent directories and their usage in relative path names. File related commands – cat, mv,
rm, cp, wc and od commands.
RBT: L1, L2
MODULE - 2
File attributes and permissions: The ls command with options. Changing file permissions: the
relative and absolute permissions changing methods. Recursively changing file permissions. Directory
permissions.
The shells interpretive cycle: Wild cards. Removing the special meanings of wild cards. Three
standard files and redirection. Connecting commands: Pipe. Basic and Extended regular expressions.
The grep, egrep. Typical examples involving different regular expressions. 08 Hours
Shell programming: Ordinary and environment variables. The .profile. Read and readonly commands.
Command line arguments. exit and exit status of a command. Logical operators for conditional
execution. The test command and its shortcut. The if, while, for and case control statements. The set
and shift commands and handling positional parameters. The here ( << ) document and trap command.
Simple shell program examples.
RBT: L1, L2

MODULE - 3
UNIX File APIs: General File APIs, File and Record Locking, Directory File APIs, Device File APIs,
FIFO File APIs, Symbolic Link File APIs.
UNIX Processes and Process Control:
The Environment of a UNIX Process: Introduction, main function, Process Termination, Command-
08 Hours
Line Arguments, Environment List, Memory Layout of a C Program, Shared Libraries, Memory
Allocation, Environment Variables, setjmp and longjmp Functions, getrlimit, setrlimit Functions,
UNIX Kernel Support for Processes.
Process Control: Introduction, Process Identifiers, fork, vfork, exit, wait, waitpid, wait3, wait4
Functions, Race Conditions, exec Functions
RBT: L1, L2, L3
Dept. of CSE, DSATMPage 1
Unix Programming 2020-2021

MODULE - 4
Changing User IDs and Group IDs, Interpreter Files, system Function, Process Accounting,
User Identification, Process Times, I/O Redirection.
Overview of IPC Methods, Pipes, popen, pclose Functions, Coprocesses, FIFOs, System V
IPC, Message Queues, Semaphores. 08 Hours
Shared Memory, Client-Server Properties, Stream Pipes, Passing File Descriptors, An Open
Server-Version 1, Client-Server Connection Functions.
RBT: L1, L2, L3
MODULE - 5
Signals and Daemon Processes: Signals: The UNIX Kernel Support for Signals, signal, Signal Mask,
sigaction, The SIGCHLD Signal and the waitpid Function, The sigsetjmp and siglongjmp Functions,
08 Hours
Kill, Alarm, Interval Timers, POSIX.lb Timers. Daemon Processes: Introduction, Daemon
Characteristics, Coding Rules, Error Logging, Client-Server Model.
RBT: L1, L2, L3

Course Outcome :
 Explain Unix Architecture, File system and use of Basic Commands
 Illustrate Shell Programming and to write Shell Scripts
 Categorize, compare and make use of Unix System Calls
 Build an application/service over a Unix system.
Question paper pattern:
 The question paper will have ten questions.
 Each full Question consisting of 20 marks
 There will be 2 full questions (with a maximum of four sub questions) from each module.
 Each full question will have sub questions covering all the topics under a module.
 The students will have to answer 5 full questions, selecting one full question from each module.
Text Books:
1. Sumitabha Das., Unix Concepts and Applications., 4thEdition., Tata McGraw Hill ( Chapter 1,2 ,3,4,5,6,8,13,14)
2. W. Richard Stevens: Advanced Programming in the UNIX Environment, 2nd Edition, Pearson Education, 2005 (
Chapter 3,7,8,10,13,15)
3. Unix System Programming Using C++ - Terrence Chan, PHI, 1999. ( Chapter 7,8,9,10)
Reference Book:
1. M.G. Venkatesh Murthy: UNIX & Shell Programming, Pearson Education.
2. Richard Blum , Christine Bresnahan : Linux Command Line and Shell Scripting Bible, 2nd Edition, Wiley,2014.

Faculty can utilize open source tools

Dept. of CSE, DSATMPage 2


Unix Programming 2020-2021

Module 1

1. With a neat diagram, explain the relationship between the kernel and shell in UNIX.
(08 Marks June 2008)
2. Define an operating system. Discuss the salient features of UNIX operating system.
(06 Marks Dec 2009)
3. Explain the architecture of UNIX operating system.
(06 Marks Dec2009, 08 Marks Dec2010,08 Marks June2013,July2014,July 2015, Jan 2016, 06 Marks
July 2016, 06 Marks June 2018)
4. Explain salient features of UNIX operating system.
(06 Marks June2010, 07 Marks Dec2012,July2014, Jan2018)
5. Describe briefly the UNIX architecture explaining the role played by the kernel and shell in sharing.the
work load. (8 Marks Jan2015)
6. Explain the following commands, with example:
i. mailx,
ii. passwd
iii. sty
iv. who (08 Marks, Dec 2010)
7. Describe the salient features of UNIX operating system.
(08 Marks, Dec 2010, Dec 2013, 08 Marks Dec/Jan 2016)
8. Write a note on the man command. (04 Marks Dec 2010, 04 Marks Dec/Jan 2016)
9. Explain the following with examples:
i. Absolute and relative path names
ii. Internal and external commands
(06 Marks, June 2012,July 2014,08 Marks, July 2016, 06 Marks June 2018)

10. With neat diagram, explain the architecture of UNIX operating system
(06 Marks, June 2012)
11. Compare internal command and external command in UNIX with suitable example. Explain why cd
command is not an external command.
(06 Marks June2013,08 MarksJuly2015, Jan2018)
12. Illustrate with a diagram typical Unix file system and explain different types of files supported in UNIX
(07 Marks June2013, 08MarksJuly2015)
13. With the help of examples, explain the following commands: i) apropos ii) whatis
(6 Marks, July 2016)
14. Discuss the salient features of Unix Operating System. (06 Marks, Jan 2017)
15. Explain the following commands with example: (06 Marks, Jan 2017)
i) Echo
ii) ls
iii) who
iv) date
16. Write a note on man documentation and explain the keyword option and what is option.

(06 Marks, Jan 2017)

Dept. of CSE, DSATMPage 3


Unix Programming 2020-2021

17. Explain how to display and set the terminal characteristics of a unix OS.
(06 Marks, Jan 2017)
18. Explain the contents of /etc/passwd and /etc/shadow file with respect to Unix OS.
(06 Marks, Jan 2017)
19. Explain the commands to add and delete a user. (04 Marks, Jan 2017)
20. With a neat diagram, explain the architecture of Unix operating system.
(08 Marks, June 2017)
21. With the help of a diagram, explain the parent-child relationship in Unix File System.
(04 Marks, June 2017)
22. Explain the following commands with the syntax and example:(04 Marks, June 2017)
i) Sty
ii) Echo
iii) Cal
iv) Passwd
23. Write the output of the following commands: (03 Marks, Jan 2018)
a) cal 8 1947
b) echo ‘Todays date is ‘date’’
c) date +”Date is: %a/%h/%Y”
24. Explain “man” documentation, and its internal command. (08 Marks, Jan 2018, June 2018)
25. Describe command arguments and options with suitable examples (04 Marks, Jan 2018)
26. How an ordinary user can become a super user and vice versa? Explain with suitable commands
(04 Marks, Jan 2018)
27. Explain the fields of /etc/passwd and /etc/shadow. (04 Marks, Jun 2018)
28. Explain the following commands with examples: (04 Marks, Jan 2018)
i. Printf ii.passwd iii.date iv. Who
29. Describe with appropriate commands, how to display and set terminal characteristics. (06 Marks, Jan
2018)
30. Explain with an example use of single quote, double quote and back quote in a command
Line.(06 Marks, Dec. 2012)
31. Explain the following commands:
i. cp ????? progs
ii. kill-S KILL 121 122
iii. we -£ < user.txt
iv. ps - e £ (06 Marks, Dec. 2012)
32. Explain the following environment variables:
i. PATH
ii. IFS
iii. HISTSIZE
iv. PS2
v. SHELL
33. With the help of a diagram, explain the parent-child relationship. Explain the UNIX file system
(06 Marks June 2012,July 2014, Jan 2018)

Dept. of CSE, DSATMPage 4


Unix Programming 2020-2021

34. With the help of neat diagram explain parent child relationship. Explain UNIX file system.
(06 Marks, June 2013, June 2018)
35. Explain briefly absolute pathname and relative pathname.

(06 Marks, June 2013, Jan 2015, Jan 2018, June 2018)

36. Define a file. With examples, explain the three categories of files supported by UNIX.
(06 Marks, Dec 2013)
37. Briefly describe: i) System calls ii)PATH iii)HOME. (06 Marks, Dec 2013)
38. Draw the tree structure of the file system created by the following commands (assume you are in the
directory/usr/office). Why is it not possible to issue the command rmdir/usr/office/right
(08 Marks Jan 2015)
$ mkdir left
$ mkdir middle
$ mkdir right

$ cd left

$ mkdir left middle right


$ cd —/middle
$ mkdir dirt dir2/usr/office/right/dir3
39. Explain the following commands with examples:
i. cat
ii. rmdir
iii. pwd. (06 Marks Dec 2009)
40. Explain briefly the different types of files in a UNIX operating system.
(06 Marks June 2008, 06 Marks, Jan 2017)
41. Explain the following commands with examples:
i. mkdir
ii. ls –l
iii. echo
iv. cd
42. With the help of a neat diagram, explain the parent-child relationship with respect to UNIX file system.
(05 Marks, Jan 2017)
43. Explain the following commands with example:
i) HOME ii) cd iii) pwd iv) mkdir v) rmdir
44. Explain the following commands with example:
i) cat
ii) mv
iii) rm
iv) cp
v) wc

Dept. of CSE, DSATMPage 5


Unix Programming 2020-2021

45. Illustrate with a diagram typical Unix file system and explain different types of files supported in Unix.
(08 Marks, June 2017)
46. Name the command used for creating, deleting and changing the directory. Explain with the syntax and
example. (08 Marks, June 2017)
47. Write a command line to perform the followings: (02 Marks, Jan 2018)
i) Change current directory to home directory
ii) Change to parent of parent directory
48. Explain CP and OD commands with options (06 Marks, Jan 2018)
49. Write the output for the following command lines (03 Marks, Jan 2018)
i) mv filename dir_name
ii) ls | wc –w
iii) who | wc –l
50. Briefly describe: i. HOME ii.PATH iii. WC iv. Pwd (06 Marks, June 2018)

Module 2
1. What are file attributes? Explain how to change the basic file permissions, with an example.
(06 Marks, Dec 2010)
2. What is file permission? What are the different ways of setting file permission?
(08 Marks, June 2008,July 2014)
3. Briefly describe the different ways of setting file permissions. (06 Marks, June 2010)
4. Explain the different types of files supported in UNIX. (06 Marks, Dec 2010, 06 Marks Dec/Jan
2016)
5. Interpret the significance of the seven fields of the ls-l output.
(07 Marks, Dec 2010,July 2014)
6. Give the significance of seven attributes of the ls-l command. (07 Marks, June 2011, June 2018)
7. What is file permissions? Explain how to change basic file permission with an example
(06 Marks,June 2011, Jan 2018)
8. Assuming that a file's current= permissions are r w x r — — r x, specify the chmod expression required
to change them to : i) rwxrwxr—x., ii) r xr — x — iii) — — — r r x
iv) — — —r w — r — using both relative and absolute methods of assigning permission.
(08 Marks Jan 2015, July 2016)
9. A file’s current permissions are rw_r_xr__. Specify the chmod expression required to change them for
the following:
i) Rwxrwxrwx
ii) ii) r_ _ r_ _ _ _ _
iii) _ _ _ _ _ _ _ _ _
iv) iv) _ _ _ r_ _ r_ _
Using both the relative and absolute methods of assigning permissions.

(08 Marks,June 2012, 06 Marks Dec 2013, 06MarksJuly 2015, June 2018)

Dept. of CSE, DSATMPage 6


Unix Programming 2020-2021

10. Which command is used for listing file attributes? Explain briefly the significance of each field of the
output. (06 Marks, Jan 2015,06 Marks Dec/Jan 2016)
11. Explain briefly the file attributes listed using ls-l command.
(06 Marks, June 2012, 08 Marks, Dec 2013)
12. Explain the basic file attributes displayed by £s - £ command. (06 Marks, Dec 2012)
13. Discuss relative and absolute methods for changing file permissions.
(06 Marks, Dec 2012)
14. Give the significance of the seven fields of the "Is -/" command. (07 Marks, July 2013)
15. What is file permission? Explain how to use "Chmod" command to set the permissions in arelative
manner with an example. (07 Marks, July 2013)
16. Which command is used for listing file attributes? Briefly describe the significance of each field od the
output. (06MarksJuly 2015)
17. Write UNIX commands for the following ( 06 Marks, July 2016)
a) Find and replace all the occurences of unix with UNIX in the text file after confirming the user (vi editor
command)
b) List all the files in PWD which are having exactly five characters in their filename and any number of
characters in their extension.
c) To delete all files containing * in their file name
d) To delete all files with three character extension except out from current directory
e) To display contents of current directory and its subdirectories
18. Explain the seven field output of ls –l. (05 Marks, Jan 2017)
19. What are different ways of setting file permission? (06 Marks, Jan 2017)
20. Which command is used for listing file attributes? Explain the significance of each field in the output.
(08 Marks, June 2017)
21. Files current permission are rw--w-r-- write chmod expression required to change them for the
following.
i) r—r----x
ii) rwxrw—x
iii) r-xr-xr-x
iv) rwxrwxr—using both relative and absolute methods of assigning permissions.
(08 Marks, June 2017)
22. Write a note on directory permissions with examples (04 Marks, June 2018)
23. What is a standard input, standard output, and standard error? Explain with respect to UNIX.(08
Marks, June 2008)
24. Explain the three sources of standard input and standard output. (06 Marks, Jan 2015)
25. Frame wild-card patterns:
i. Where the last character is not numeric
ii. That have atleast four characters. (04 Marks, June 2008)
26. What are standard input, standard output, and standard error? Explain with respect to
UNIX. (06 Marks, June 2009, 06MarksJuly 2015)

27. What are three standard files used by UNIX commands? Explain.
(06 Marks, June 2010, 08 Marks, July 2016)
28. What are the standard input, standard output and standard error? Explain with respect to UNIX.
(10 Marks, Dec 2010)

Dept. of CSE, DSATMPage 7


Unix Programming 2020-2021

29. Explain what these wild — card patterns match : (08 Marks, Jan 2015)
i) [A — Z]????*
ii) *[0 — 9]*
iii) *[!0 — 9
iv) *.[!s] [!h].
30. Explain the grep, with examples. (04 Marks, Dec 2010)
31. Explain the three standard files with respect to unix operating systems.
(6 Marks, June 2012)
32. Explain the standard input, standard output and standard error with operating system.
(7 Marks,July 2013, 06 Marks Dec/Jan 2016)
33. What are wild cards? Explain the shell wild cards, with examples.(08 Marks, July 2014, Jan 2018,
June 2018)
34. Devise wild-card patterns to match filenames:
(i) Comprising of atleast three characters where the first char is the last char is not
alphabetic. (06 Marks Dec 2013)
(ii) With three character extensions except the ones with .log extension.
(iii)Containing 2004 as an embedded string except at the beginning or end.
35. Explain shell interpretive life cycle. (04 Marks, Jan 2017)
36. Discuss the three standard files supported by UNIX. Also give details about the special files used for
output redirection in UNIX. (06 Marks, Jan 2017, June 2018)
37. With the help of example, explain grep command and list is options with their significance.
(06 Marks,Jan 2017, June 2017, Jan 2018)
38. Explain what these wild card pattern match:
i) [A-z]????*
ii) *[!0-9]*
iii) *.[!S][! (06 Marks, June 2017)
39. Briefly explain the extended regular expression with an example.(06 Marks, June 2017)
40. Explain the three sources of standard input and standard output. (04 Marks, June 2017)
41. Write the Unix commands for the following:
i) Find and replace all the occurrence of “Unix” with “Unix” in the text file after
confirming the user. [vi editor command].
ii) To delete all the files with three character extension except “.out” from current directory.
iii) List all the files in PWD which are having exactly five characters in their filename and
any number characters in their extension.
iv) Writing the first 50 lines to another file. [Vi editor command].
v) Inserting a text at the beginning of the line. [Vi editor command].
vi) Searching for a pattern in backward direction. (06 Marks, June 2017)
42. Explain tee command with an example (02 Marks, Jan 2018)
43. Explain the following commands with examples: (06 Marks, Jun 2018)
i. Set ii. Map iii. Abbr
44. Write a command for the following using grep (04 Marks, Jun 2018)
i) To delete all blank lines from a file named Emp
ii) To list only subdirectories in the current directory
iii) To display lines containing pattern in file sample SIGSTOP or SIGTSTP
iv) To display number of lines that does not contain pattern ‘USA’ in file times.txt
Dept. of CSE, DSATMPage 8
Unix Programming 2020-2021

45. Differentiate between hard link and soft link. (06 Marks, June 2009)
46. What are environmental variables? State their significance. (06 Marks, June 2010)

47. What are environment variables? Explain any four.(6 Marks,July 2013)
48. What is shell programming? Explain with examples how expressions are evaluated in shell
programming. (08 Marks, June 2008)
49. What is shell programming?Write a shell script to create a menu which displays:
i. List of files
ii. Contents of files
iii. Process Status
iv. Current date
v. Clear the screen.
vi.Current user of the System(10 Marks June 2014, 08 Marks Dec/Jan 2016, June 2018)
50. What is shell script? Explain the following statements with syntax and example
i. if
ii. case
iii)while(10 Marks Jan 2015)
51. What are shell parameters $*, $#, $? And $$? Discuss very briefly.
(06 Marks, June 2008)

52. What is ‘for’ loop in shell programming? Explain the different ways of making the lists.
(06 Marks, June 2008, Dec 2013, 06 MarksJuly 2015)
53. Explain special parameters used by the shell. (06 Marks, Jan 2009,Jan 2015)
54. Explain the expr command applicable to numeric and string functions.
(06 Marks, Jan 2009, June 2018)
55. Explain here document with an example. Also mention its use. (04 Marks, Jan 2009)
56. Explain trap in shell scripts with a suitable example. (04 Marks, Jan 2009)
57. What are the special parameters used by the shell? (06 Marks, June 2010)
58. Explain how numeric and string comparison is done by using test.
(06 Marks, June 2010)
59. Write a menu driven shell script to display list of files, process of user, today’s date and users of the
system. (08 Marks June 2010)
60. Explain the use of test and [ ] to evaluate expressions in shell
(08 Marks, Dec 2010 06 Marks Dec/Jan 2016)
61. Explain the shell features of ‘while’ and ‘for’ with syntax
(06 Marks, June 2012,06 Dec/Jan 2016, 06 Marks ,July 2016)
62. Define a shell script. What are the two ways of running a shellscript? Write a shell script to Accept
pattern and a file and search for the pattern in the file.
(08 Marks, Dec. 2013)
63. What is the ‘exit’ status of a command and where is it stored?And how it can be accessed? Give
examples
(06 Mark, June 2012,Jan 2015, 06 Marks ,July 2016)
64. What is shell programming? Write a shell program to create a menu and execute a given
option based on users choice. Options include
i. list of users
Dept. of CSE, DSATMPage 9
Unix Programming 2020-2021

ii. list of processes,


iii. list of files. (06 Marks, Dec. 2012)
65. Explain with example set and shift commands in UNIX to manipulate positional parameters.
(04 Marks, Dec. 2012, 06 Marks July 2015)
66. Discuss use of trap statement for interrupting a program in UNIX.
(04 Marks, Dec. 2012)
67. Explain with an example while and for loop in shell programming.
(06 Marks, Dec. 2012)
68. Explain the use of "test" and [ ] to evaluate an expression in shell.
(06 Marks, June 2013, Jan 2018)
69. Explain the shell features of "while" and "for" with syntax. (06 Marks, June 2013)
70. Write a menu-driven shell script to perform the following:
(06 Marks, Dec. 2013, 06 Marks July 2015)
i)List of users who are logged in.
ii)List of files in the current directory.
iii) List of processes of user.
iv)Today'sdate.
v)QuittoUNIX.
71. Explain the "expr" command applicable to computation and string functions.
(8 Marks, June 2013)
72. Write a shell code to accept a string from the terminal and display suitable message if it doesn’t have at
least 10 characters using i)case ii) expr (06 Marks ,July 2016)
73. Explain the shell features of “while” and “for” with syntax (08 Marks, Jan 2017)
74. Explain with example set and shift commands in UNIX to manipulate position parameters.
(08 Marks, Jan 2017, June 2018)
75. Differentiate between hard link and soft link with suitable example.
(06 Marks, Jan 2017, Jun 2017, June 2018)

76. Explain the following with example:


i) Head
ii) Tail
iii) Cut
iv) Paste (08 Marks, Jan 2017 June 2017, Jan 2018, June 2018)
77. Discuss briefly sort command with its options. (04 Marks, Jan 2017)
78. What is shell programming? Write a shell program to create a menu and execute a given options based
on user choice. Options include
i) List of users
ii) List of processes
iii) List of files
iv) Current date
v) Content of files
79. Display current login users. (10 Marks, June 2017)
80. What is shell script? Explain the following statements with syntax and example:
i) If

Dept. of CSE, DSATMPage 10


Unix Programming 2020-2021

ii) Case
iii) While (10 Marks, June 2017)
81. Write a shell script using case to perform all arithmetic operations. (06 Marks, Jan 2018)
82. Explain for loop, also possible sources of argument list. (06 Marks, Jan 2018)
83. What are links? How to create different types of links? And list their differences (06 Marks, Jan 2018)
84. Discuss umask and default file permissions. (05 Marks, Jan 2018)
85. Explain the following with examples: (04 Marks, Jun 2018)
i. Umask ii. /dev/null iii. /dev/tty

Module 3
1. List all the file attributes along with their meaning? Which of these attributes can’t be changed and why?
List the commands needed to change the change the following attributes? File size, Used ID, Last access
and modification time and Hard link count (05
Marks, June 2009)
2. What is an inode? Why are the inodes unique only within a file system? How OS does maps the inode to its
filename? Bring out the difference between soft and hard link? (07 Marks, June 2009, Dec 2010)
3. List the structure to query the file attributes in UNIX? Write a program in C++ to list the following file
attributes of a given regular file passed as command line argument? File type, Hard link count, File size
and File name (08 Marks, June 2009)
4. Explain the different file types available in UNIX and POSIX system? And also write the commands to
create all the files? (08 Marks, Dec 2010, June 2010, Dec 2010, June 2011, Dec 2011)
5. Describe the UNIX kernel support for files? (06 Marks, Dec 2010, June 2011,June 2012,08 Marks Dec
2015, 08 Marks June 2016, 10 Marks Dec 2016 )
6. Discuss with a neat diagram the different data structures supported by UNIX kernel for file manipulation?
(08 Marks, June 2010)
7. Bring out the differences between hard link and symbolic link? (06 Marks, June 2010, Dec 2010)
8. Differentiate between C stream pointers and file descriptors? (05 Marks, Dec 2012)
9. Write any three differences between: i. C stream pointers and file descriptors ii. hard link and symbolic
link. (06 Marks June/July 2016)
10. Bring out the differences between hard link and symbolic link. (04 Marks, June 2011, 06 Marks)
11. What is file? Explain types of files with command examples. (08 Marks June 2016, 10 Marks Dec 2016)
12. Explain the commands to create different file types supported by UNIX. (06 Marks, Dec 2015)
13. Describe the open API, clearly indicating its prototype declaration, the values the arguments take along
with their meaning. Give two instances, when open API can fail. List all the access modifier flags and
explain their meanings. (06 Marks, June 2009)
14. List the important uses of fcntl API. Give its prototype description. Write a C++ program to check whether
the close-on-exec flag is set for a given file. If it is not set, use fcntl to set this flag. Also show the
implementation of dupz macro using this API.
(06 marks, June 2009)

Dept. of CSE, DSATMPage 11


Unix Programming 2020-2021

15. Bring out the importance of locking files. What are mandatory and advisory locks? Why is advisory lock
considered safe? What is the drawback of advisory lock? Explain in brief.
(05 marks, June 2009, Dec 2010)
16. Explain File and Record Locking with C/C++ program (08 Marks June 2016)
17. Write C/C++ program to rename a file[use mv command / link and unlink API’s] (04 Marks June 2016)
18. In a certain application, it is required to lock the hashed portion of the file as shown in Fig.4 (b).Before
locking the program must query the OS to see if some other process has locked the file. If yes, give the
details of the locked portion and the PID of the process. Once the lock is obtained perform a write and
unlock the file. Write a C++ program to implement this application. Assume suitable lock type.
figure (06 marks, June 2009)
BEG.
300
450

File name=
“t t t t”

19. List and explain the access mode flags and access modifier flags. Also explain how the permission value
specified in an ‘open’ call is modified by its calling process ‘Umask’ value.
(04 marks, Dec 2009)
20. Explain how fcntl API is used for file and record locking. (08 marks, Dec 2009)
21. Write the code segment in C that records at most 100 bytes into a variable but from standard input.
(08 marks, Dec 2009)
22. Explain the following API along with their prototype definitions: (08 marks, June 2010)
Open, Write, Fcntl and lseek (12 Marks, Dec 2015)
23. What is symbolic link file APIs? Write a C/C++ program to emulate the UNIX ln command.
(08 marks, June 2010)
24. Give the hierarchy structure of the file classes. (04 Marks, June 2010)
25. With the help of prototype, explain the following API’s: (05 Marks, Dec 2010)
Create, lseek, Access and Link.
26. List the structure used to query the file attributes in UNIX. Write C++ program to list the following file
attributes of given regular file passed as command line argument.
File type, User ID, File name and File size (08 Marks, Dec 2010)
27. Explain the following API’s with prototypes: (08 Marks, June 2011)
Open, lseek, Stat, and Read.
28. Write a C++ program to implement following unix commands i) ln ; ii) mv; (08 Marks, June 2011, 10
Marks Dec 2016)
29. Write a C/C++ program to illustrate the use of fcntl API for file locking.
(08 Marks, Dec 2011)
30. Write a C/ C++ program to implement following UNIX command ls-l.
(06 Marks, Dec 2011)

Dept. of CSE, DSATMPage 12


Unix Programming 2020-2021

31. Explain the file APIs: READ, WRITE, CLOSE and OPEN, with prototype and arguments.
(06 Marks, Dec 2011, 08 Marks June 2016)
32. Explain the working of the open function with the prototype. (10 Marks, June 2012)
33. How do you access and modify the time stamps of a file. Explain the prototypes and Write a program to
illustrate the usage of the prototype. (10 Marks, June 2012)
34. Discuss the file and record locking in UNIX system. Explain the fcntl API for file Locking.
(10 Marks, Dec 2012)
35. Explain the Symbolic Link with an API. (08 Marks, Dec 2015)
36. Write short notes on Device file API’s (03 Marks, Dec 2010)
37. Explain the working of open function with prototype. (10 Marks, Dec 2016)
38. Explain the following APIs, with prototype: (05 Marks, Dec 2011)
Umask, stat, fstat, chown and link
39. What are the different ways in which a process can terminate? With a neat block schematic, explain how a
process is launched and terminated clearly indicating the role of C-startup routine and the exit handlers. (05
Marks, June 2009, Dec 2010, 2011, June 2009, 06 Marks, Dec 2015)
40. With a neat diagram, explain about the termination ways for a process. Also write a C/C++ programs to
display: Command Line arguments and Environment Variables. (10 Marks June 2016)
41. With a neat diagram, explain the memory layout of a C program. In which segments are the automatic
variables and dynamically created objects are stored? (04 Marks, June 2009, 06 marks Dec 2015, June
2016)
42. Write an explanatory note on environment variables. Also write a C/C++ program that outputs the contents
of its environment list. (06 Marks, Dec 2009)
43. With an example program, explain the use of set jmp and long jmp functions.
(08 Marks, Dec 2009, Dec 2011)
44. Describe the UNIX Kernel support for a process. Show the related data structures.
(06 Marks, Dec 2009, Dec 2011)
45. Write a C/C++ program to demonstrate the use of atexit function. (10 Marks, June 2010)
46. Explain briefly the memory layout of C program. (10 Marks, June 2010, June 2011, Dec 2010, Dec 2012,
10 Marks , Dec 2016)
47. What do you mean by command line argument? Explain with an example.
(03 Marks, Dec 2010, Dec 2012)
48. Explain the following, with an example: (04 Marks, Dec 2010)
i. setjmp and longjmp
ii. setrlimit and getrlimit.
49. Explain exit,-exit,atexit functions with its prototypes.
(04 Marks, June 2011, 08 marks Dec 2015)
50. Explain getrlimit and setrlimit functions with prototype. Mention the three rules to change the resource
limits. Give four resource values. (06 Marks, June 2011, Dec 2012)
51. What are the APIs to query and change the resource limits. List the rules that govern the changing of the
resource limits. (08 Marks, June 2012)
52. Explain with a neat block diagram UNIX process data structure. (06 Marks, June 2012, Dec 2012)

Dept. of CSE, DSATMPage 13


Unix Programming 2020-2021

53. Write a C/C++ Proram to demonstrate the use of outexit function. (10 Marks Dec 2016)
54. Explain setjmp and longjmp functions with their prototypes. (06 Marks, June 2016)

Module 4
1. With a prototype description of fork, explain the special features of this API. Write a program to create a
child process and print the PPID and PID in the child process. The parent process must ensure that the child
doesn’t become zombie process. The p[aren’t process must wait for the child and print exit status of the
child using appropriate macros. (06 Marks, June 2009, June
2010)
2. Explain in brief, what happens when exec is called in a child process. List the 6 different exec APIs. Write
a program that execs a program echo all to display all the command line and environment variables when
this program is exceed in the child process space. (06 Marks, June 2009, June 2010, June 2011, Dec
2011, 06 Marks Dec 2016)
3. With neat diagram, explain the terminal login process in BSD Unix. What is a session? Explain how you
create a session using appropriate shell command. (04 Marks, June 2009, June 2010)
4. What is job control? What are the three forms of support from the OS required for job control?
(04 Marks, June 2009, Dec 2009, June 2010, Dec 2011, June 2011)
5. Write short notes on the following: (09 Marks, Dec 2010)
i. Sigsetjmp and Siglongjmp
ii. Race conditions
iii. Error logging facility in BSD Unix.
6. What is race condition? Write a program in C/C++ to illustrate a race condition. (06
Marks, Dec 2009, Dec 2011, 08 marks Dec 2015, June 2016)
7. How UNIX operating system keeps process accounting? (06 Marks, Dec 2009)
8. What is fork and vfork? Explain with a program for each. (10 Marks, June 2010, June 2011, June 2012,
Dec 2012, Dec 2016)
9. What is controlling terminal? Explain its characteristics and relation to session and process groups.
(10 Marks, June 2010, Dec 2012)
10. What is zombie process? Write a C program to avoid zombie process by forking twice.
(06 Marks, June 2011, 06 Marks Dec 2016)
11. What is an orphaned process? Explain with an example (04 Marks, June 2012)
12. Explain the following:
i. Orphaned process ii. Zombie process iii. Terminal login iv. Network login (10 marks June 2016)
13. Describe the sequence of processes involved in executing TELNET server.
(08 Marks, June 2012)
14. Explain in detail exec family in detail (08 marks Dec 2015)
15. Explain : i. Process ii. Session. (04 Marks June 2016)
16. What is an orphaned process? Explain with an example. (04 Marks, June 2012)
17. Write short notes on the following: (09 Marks, June 2009, June 2011, Dec 2011)
i. Sigsetjmp and Siglongjmp, Race conditions, Error logging facility is BSD Unix.
Dept. of CSE, DSATMPage 14
Unix Programming 2020-2021

ii. Network login and Controlling terminal


18. What are pipes? What are their limitations? Write a C program that sends “Hello world” message to the
child process through the pipe. The child on receiving this message should display the standard output?
(06 Marks, June 2009, Dec 2010)
19. Write a neat block diagram explain how FIFO can be used to implement client –server communication
model? (06 Marks, June 2009)
20. What are the 3 different ways in which the client and server processes can get access same IPC structure?
Explain the different prototypes? List the API along with their argument details that are used to create,
control, send and receive messages from a message queue? (07 Marks, June 2009,
06 Marks June/July 2016)
21. What are semaphores? What are their purposes? List and explain the API used to create and control the
semaphores? (03 Marks, June 2009)
22. What is FIFO? Explain how it is used in IPC. Discuss with an example, the client-server communication
using FIFO? (10 Marks, Dec 2010, June 2010, June 2012, Dec 2012, 04 marks Dec 2015, June/July
2016)
23. What are the different system calls available to create and manipulate semaphores? Explain?
(10 Marks, Dec 2010, June 2011)
24. Explain popen and pclose function with prototypes and write a program to demonstrate popen and pclose
function? (10 Marks, June 2010, 06 marks Dec 2015)
25. What is the purpose of message queuing? List and explain message queuing with the prototype?
(10 Marks, Dec 2010)
26. Write a short notes on: (10 Marks Dec 2010, 6 Marks June/July 2016)
i. Semaphores
ii. Message queues
27. What are pipes? What are their limitations? Write a program to send data from parent to child over a pipe?
(06 Marks, June 2011,June 2012, Dec 2012, 10 Marks Dec 2016)
28. Write a program to create pipe from the parent to the child and send the data down the pipe?
(07 Marks, Dec 2011)
29. What are message queues? Write the structure of the message queues and explain each member in detail?
(06 Marks, Dec 2011, 10 marks Dec 2015)
30. What are the advantages and disadvantages of XSI IPC? (06 Marks, June 2012)
31. Explain the following functions related to message queues: (05 Marks, Dec 2012)
i. Msgget
ii. Msgsnd

32. What is a socket? Describe the socket API. Write a C program to illustrate the process of creating socket,
initializing the socket address structure and establishing a connection from a client to the server. Assume
the server IP address as 10.10.2.5 and port number=8000. The client after establishing a connection should
send “Hello World” message and wait for a reply. (08 Marks, June
2009)

Dept. of CSE, DSATMPage 15


Unix Programming 2020-2021

33. What is out-of-band data? Illustrate with an example, how would you specify out-of-band data.
(03 Marks, June 2009)
34. What is a socket? Discuss how it create and destroy a socket?
(10 Marks, Dec 2009, June 2011)
35. Discuss the different functions available for transmitting and receiving data over a socket.
(10 Marks, Dec 2009, Dec 2010, Dec 2012)
36. Explain socket addressing, socket creation, connection establishment and data transfer with appropriate
APIs. (10 Marks, June 2010)
37. What are send and recv socket calls? Explain various flags used with send and recv calls.
(10 Marks, June 2010)
38. What are sockets? Explain the sequence of calling socket APIs for both server and client process. Briefly
explain the prototype of each socket API. (10 Marks, Dec 2011)
39. Explain in shmget, shmctl, shmat and shmdt functions. (12 marks Dec 2015, June/July 2016)
40. Write short notes on client-server properties (08 marks Dec 2015)
41. Explain the following APIs with prototypes listen () and accept ().
(10 Marks, June 2012)
42. What is byte ordering? Explain the two types of ordering. Explain the APIs to convert between the
processor byte order and the network byte for TCP/IP applications.
(12 Marks, June 2012)
43. Write shorts notes: (2.5 Marks, Dec 2011)
i. Out-of-band data.
44. Explain the following socket programming functions with their prototypes: Socket, connect, listen and
accept. (10 Marks, Dec 2012, Dec 2016)
45. Briefly explain client-server Functions. (June/July 2016)
46. Explain shared memory as an IPC mechanism. (June/July 2016)

Module 5
1. What are signals? Mention the different sources of signals. What are the three dispositions the process has
when signals occur? List any four signals along with one or two line explanation. Write a program to setup
signals handlers for SIGINT and SIGALARM signals. (08 Marks, June 2009, June 2011, 06 marks Dec
2015, 10 Marks 2016)
2. Describe the API used to mask the signals. What are signal sets? List the functions that are used to
manipulate the signal sets. Write a program to demonstrate the use os sigprocmask and sigpending
functions. (06 Marks, June 2009, Dec 2011)
3. What are daemon processes? Enlist their characteristics. Also write a program to transform a normal user
process into a daemon process. Explain every step in the program.
(06 Marks, June 2009)
4. What is Daemon process? Explain Daemon characteristics and relation to session and process groups.
(10 Marks, Dec 2016)

Dept. of CSE, DSATMPage 16


Unix Programming 2020-2021

5. What are signals? Discuss any five posix defined signals. Explain how to setup a signal handler.
(10 Marks, Dec 2009, June 2010)
6. What is Daemon? Discuss the basic coding rules. (10 Marks, Dec 2009, June 2010,08 Marks Dec
2015,10 Marks June/July 2016)
7. What is signal mask? Explain with prototype and example. (05 Marks, Dec 2010)
8. With neat diagram, explain the method of error logging. (07 Marks, Dec 2010)
9. What is signal mask of a process? Explain sigprocmask() along with its prototype.
(06 marks Dec 2015)
10. What are signals? Explain the prototype of sigaction function. Also write a C/C++ program to setup signal
handler using sigaction function. (06 Marks, Dec 2011)
11. What is the use of the alarm API? Give the prototype of alarm API. How can the alarm API be used to
implement the sleep API? (08 Marks, June 2012, 6M June/July 2016)
12. List the timer manipulation APIs in POSIC.1b. (06 Marks, June 2012)
13. Explain the three way of generate log messages. (06 Marks, June 2012)
14. Define and Explain: i: SIGCHLD ii: waitpid function. (04 Marks June/July 2016)
15. Explain the following APIs related to signals with their prototypes:
Sigprocmask, Sigaction, Sigsetjmp and Kill. (10 Marks, Dec 2012)

Dept. of CSE, DSATMPage 17

You might also like