LINUX Smiley Question Bank
LINUX Smiley Question Bank
LINUX Smiley Question Bank
Basics:
1. List the commands you can use to perform these operations
a) Make your home directory the working directory
b) To create new user
c) To change password
d) Find present working directory
e) Display who is logged in your terminal
f) Display first 18 lines from the file
g) To access online help
h) Display the content about the file ie to display whether the file is binary file or ascii file
i) Display the contents from the zip files
j) To list invisible files
(1X10 =10 Marks)
5. What are the different possibilities to change the permission of the file explain in detail with
example. (explain in numerical method)
(2X5 =10 Marks)
7. a) what is > , >> and 2> symbols used in the following commands
ls > all files
ls >> all files
ls 2> file
b) Develop an interactive script that asks for a word and file name and then tells how many times
that word occurred in the file.
(3+7 =10 marks)
15. Briefly explain the various file permissions in Linux. How can the permissions be modified using the
‘chmod’ command? 10
18. What is redirection and piping? Explain the importance of these two methods with examples 10
19. With a short note explain the use of test commands for various purposes with the help of examples
10
20. (5+5)
1. Write short notes on the importance of Tee utility
2. What is a Filter? Explain different utilities that can be used as filters
22. Explain with an example the syntax and the working of the case control structure used in shell
programming 10
Scripting:
24. a) Write a program to accept a number and calculate the sum of its digits.
b) Write a script to display home directory location, os type, username and bash version.
(5+5 =10 marks)
25. a) explain different types quotes available in linux explain it with an example
b) Write a scripting to get user input , password - if you are typing password with 10 seconds it
must abort.
(5+5 =10 marks)
28. a) Write a shell script that computes the gross salary of a employee according to the following
if basic salary is <1500 then HRA 10% of the basic and DA =90% of the basic
if basic salary is >1500 then HRA 500 and DA =98% of the basic . The basic salary is entered
interactively through the key board
b) Write a shell scripts which gets the moment the user opens a terminal. It should display the
message Good Morning"/"Good Afternoon"/"Good Evening" depending upon the time.
(5+5 =10 marks)
FROM NEW QB:
29. (5+5)
1. Explain different types of quotes available in Linux with an example
2. Write a shell scripting to calculate factorial of n using functions
30. Explain with examples the different looping statements used in shell programming 10
31. (5+5)
1. Write a simple shell script that takes two numbers as parameters and uses a while loop to
print all the numbers from the first to the second inclusive, each number separated only by
a space from the previous number.
2. Write a shell script which displays “Good morning”, “Good afternoon” or “Good evening”,
on the monitor, depending on the time of running the script.
32. (5+5)
1. Write a shell script calculate, which accepts 4 arguments a, b, c, d and prints the value of
a × 20 − b × 2 + c ÷ d to standard output.
2. Write shell script to print given number in reverse order, for eg. If number is 123 it must
print as 321.
33. (5+5)
1. Write shell script to determine whether given file exist or not, file name is supplied as
command line argument, also check for sufficient number of command line argument
2. Write shell script to print the sum of the given number, for eg. If number is 123 it must
print as 6.
34. (5+5)
1. Write a shell script that accepts two integers as its arguments and computes the value
of first number raised to the power of the second number
2. Write a shell script to count the number of users currently logged in, also the script
should display the details about the user whose login name is specified on the command
line
35. (5+5)
1. Write a menu driven shell script to show various system configuration
1)Currently logged user and his login name
2) Your current shell
3) Your home directory
4) Your operating system type
5) Your current working directory
6) Show Currently logged number of users
2. Develop an interactive shell script that asks for a word and a file name and then tells
how many times that word occurred in the specified file.
Dialog box:
36. Explain input box and password box in dialog box utility explain it with an example.
(1X10 =10 marks)
37. Write a script to create interactive script in that user must answer either yes or no. by using to
delete a file by using dialog box utility.
(1X10 =10 marks)
38. Write a interactive script to display “the process is going on … please wait” for 20 minutes using
dialog box utility.
(1X10 =10 marks)
39. Write a interactive script to create menu box in the list to display list of files, date, calendar by
using dialog box utility.
(1X10 =10 marks)
40. Explain gauge box in dialog utility. Explain it with simple example.
(1X10 =10 marks)
POWER UTILITY:
41. a) Write short notes on TRAP .
44. a) Explain Conditional execution statements && and || in linux with an example
b) Write a shell script that accepts two integers as its arguments and computes the value of first
number raised to the power of the second number
(5+5 =10 marks)
SED:
45. Using SED perform the following functions
a) Print only lines 3 through 6
b) Delete from line3 until the end of the file
c)Change all occurrences of west to north
d) Substitute all occurrences of the word ‘home’ from line number 100 to 200 of
‘password’ file using vi editor.
e) Delete all lines from a file containing the word ‘unix’.
48. Explain how to append, change and insert word in SED explain with an example
(1X10=10 marks)
49. a) Explain substution with different options in SED
b) How to execute multiple commands in sed explain with an example
(5X2 =10 marks)
50. Explain any 3 regular expressions and any 2 character classes in SED with an example
(1X10=10 marks)
FROM NEW QB:
51. Explain how sed works (Basic sed procedure) with regards to the main loop of the sed script with an
appropriate example 10
52. What is a Regular Expression? Write a note on the use of the following characters in regular
expression, give appropriate examples. 10
a) ^ and $
b) \{ and \}
c) \( and \)
d) […]
e) *
53. Explain the syntax of the Substitute command in sed with an example. Also list the different flags
which can be specified with the command. 10
54. Explain how to append, change and insert lines using SED with appropriate example 10
55. Explain the following commands related to sed with examples. (2x5)
1) n 2) p 3) d 4) b 5) t
56. Write and explain the working of the sed script that deletes everything between the pattern “hello”
and “goodbye” if they are on one or two consecutive lines 10
58. Assume that we have a text file named test.txt having some data in it. Write sed script to do the
following operations on the file. 10
1) show only lines which match the pattern “mom”
2) delete all the lines that contain the word “debug”
3) insert the line “I have been inserted” when pattern “dad” is matched
4) substitute all the instance of pattern “sister” with pattern “brother”
5) show all the lines between the lines containing the pattern “grandmother” and
“grandfather”
59. Assume that we have a text file named data.txt having some data in it. Write sed script to do the
following operations on the file. 10
1) Print only lines from 3 through 6
2) Delete lines from line 3 until the end of the file
3) Change all occurrences of ‘west’ to ‘north’
4) Substitute all occurrences of the word ‘home’ to ‘root’ from line number 100 to 200
5) Delete all lines from the file containing the word ‘unix’.
60. Write sed scripts to do the following operations on the input file 10
1) Take a string as an input from the user and surround the string by brackets at all the
locations the string appears in the input file
2) Replace all the numbers in the input file by the letter NUM.
3) Replace all the capital “D” with small “d”.
4) Replace the first letter in ever line by a blank.
5) Delete all the blank lines in the file.
AWK:
61. Write AWK scripts to do the following
a) Print the even-numbered lines in the data file
b) Delete all blank lines from a file
c) Print lines 8 to 12
d) Print the last field of each line
e) Print the total number of lines containing word “MCIS"
(5X2=10 marks)
63. Perform the following functions using AWK by using below table:
SNO SNAME ATTENDANCE MARK1 MARK2
1 Joe 89 45 56
2 Mary 90 78 80
3 Lara 67 56 78
a) Calculate average marks
b) List how many students are there
c) Calculate total number of students whose attendance is > 90%
d) Print JOE’s record
e) Print all the records without marks
(5X2=10 marks)
64. a) Explain format specifiers and modifiers related to printf statement in AWK
b) Explain any 5 Arithmetic built in functions.
(5X2=10 marks)
67. a) Write a script to find the sum of numbers 1 to 10 by using AWK. Explain working of the script
b) Explain any 5 string built in functions related to AWK
(5X2=10 marks)
69. Explain the difference between the following pair of system variable related to AWK with an
example.
a) NF,NR b) OFS, ORS c) FS,RS d) FILENAME,FNR
(4X2.5=10 marks)
70. Describe the following system variables used in AWK ,also give examples for the same
a) NF b) NR c) FILENAME d) RS e) FS
(5X2=10 marks)
FROM NEW QB:
71. (5+5)
1. Explain any 5 Arithmetic built-in functions in AWK.
2. Explain the END and BEGIN routines in AWK with an example
72. What are Associative Arrays in awk? explain with the help of an example 10
73. Describe the various system variables found in AWK, also give relevant examples 10
74. Explain the working of an AWK script with respect to the BEGIN routine, the END routine and the
main input loop with an appropriate example 10
75. (5+5)
1. Explain the format specifiers and modifiers related to printf statement in AWK
PERL:
81. What are the different variables available in PERL explain
(1X10=10 marks)
82. What are the different operations performed on ARRAYS in PERL explain with an example.
(1X10=10 marks)
83. Explain the following terms a) Push b) Pop c) shift d) unshift with an example
(1X10=10 marks)
84. Define hash .list is the difference between Hash and Array. How to add and remove an element
from hash.
(1X10=10 marks)
86. Explain matching, substitution, and translation operation in PERL with an example.
(1X10=10 marks)
87. How to get value from the user in PERL. Explain it with an example.
(1X10=10 marks)
88. a) Define the terms pattern matching and regular expressions.
b) What sort of tasks is pattern matching useful for? Name four .
c) What do each of the following patterns do?
/ice\s*cream/
/\d\d\d/
/^\d+$/
/ab?c[,.:]d/
(4+2+4=10 marks)
89. a) Write a perl program to check whether a number is a palindrome or not.
b) Write a perl program to implement the bubble sort on a set of numbers.
(5X2=10 marks)
90. a) Write a perl program to store phone numbers in a hash. Write a program to look up numbers by
the person's name.
b) Write a perl program to capture all the prime numbers between 2 and a number the user gives
you.
(5X2=10 marks)
FROM NEW QB:
91. With appropriate examples explain what do the symbols $ @ and % mean when prefixing a variable
in PERL 10
92. Explain the push, pop, shift, unshift, reverse and chomp functions in PERL with respect to array.
Also give appropriate examples 10
93. Explain the keys, values, each and delete functions in PERL with respect to hash. Also give
appropriate examples 10
94. Explain with examples the syntax and working of the if-elsif-else and foreach control structures
found in PERL 10
95. Explain the matching, substitution, and translation operations possible in PERL with appropriate
examples 10
96. Write and explain a PERL program that reads a series of words with one word per line until end-of-
file, then prints a summary of how many times each word was seen 10
97. (5+5)
1. Write a PERL program to check whether a number is a palindrome or not.
2. Write a PERL program to implement bubble sort on a set of numbers.
98. Write and explain a PERL program that reads and store phone numbers in a hash then when
needed the stored numbers are retrieved by the person's name.
10
99. Write and explain a PERL program that reads in a list of strings on separate lines and then prints
out the list of strings in reverse order --- without using the inbuilt reverse function on the list 10
100. Write and explain a PERL program that reads a list of numbers (on separate lines) until the
number 999 is read, and then prints the total of all the numbers added together 10