LINUX Smiley Question Bank

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

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)

2. List the commands you can use to perform these operations


a) To delete user
b) To switching between users
c) View last 20 lines from the file
d) Display previous, current, next month in calendar
e) Display your terminal number
f) Find out the current shell
g) How to remove alias
h) Display only directory and subdirectories
i) How to decompress the files
j) How can you find out which commands are available on your system for compressing the
files?
(1X10 =10 Marks)

3. List the commands you can use to perform these operations:


a) How to display today date and time
b) How to remove duplicate lines from the file
c) What are the attributes of files how to list the attributes
d) What is the difference between More and less utility
e) What is the difference between comp and diff utility
(2X5 =10 Marks)

4. List the commands you can use to perform these operations:


a) To count total number of lines ,words and characters explain command
b) To create hard link
c) To copy the directory /usr/local to /opt/pgms? Explain the working of the command.
d) To move the directory /usr/local to /opt/pgms? Explain the working of the command.
e) What is the difference between absolute path name and relative path name?
(2X5 =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)

6. a) perform the following operations


i. How to find the jobs in the queue
ii. What if you want a command to run every day at midnight?
iii. Give a command to find out how many users are working in the system
iv. To kill a particular process with a PID
b) Explain Cron command (4+6 =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)

8. Perform the following functions using GREP utility


a) Print all lines that begin with “south” including line numbers
b) Print all lines with “pat” regardless of case
c)Print all lines that do not contain ‘Suan Chin’
d) Print just the filenames of files containing lines with “SE”
e) Print the number of lines containing “west”
(2X5 =10 marks)

9. write commands to following functions and explain


a) Count the number of occurrences of “{“ and “}” in a given .c file
b) To sort the users based on their names
c)Print the last 5 files in a list of files sorted in ascending order based on their size.
d) Print the list of recently used five filenames
e) List the files and directory to both standard output and to file
(2X5 =10 marks)

10. a) Write short notes on importance of Tee utility


b) What is Filter? Explain different utilities used for filters

FROM NEW QB:


11. Give a brief structural overview of the Linux operating system with an appropriate diagram 10
12. Write short notes on the following: a) Shell   b) Kernel      10

13. Explain the various features of LINUX system.       10

14. Write a note on the Linux file system structure 10

15. Briefly explain the various file permissions in Linux. How can the permissions be modified using the
‘chmod’ command?         10

16. Write a short note on the following command (2x5)


i) who ii) tar iii) sort iv) wc v) chmod

17. Write a short note on the following command (2x5)


i) w ii) gzip iii) head iv) fg v) mv

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

21. Write a note on the trap built-in with suitable example 10

22. Explain with an example the syntax and the working of the case control structure used in shell
programming 10

23. Write a note on the different keyword variables found in Linux 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)

26. a) Explain case statements


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.
(5+5 =10 marks)

27. a) Explain looping statements in scripting language


b) Write A shell script that takes a command –line argument and reports on whether it is directory, a
file, or something else.
(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 .

b) write a scripting to calculate factorial of n using functions.


(5+5 =10 marks)
42. a) Write short notes on Functions.
b) Write a program to create a menu with the following in the list
1. Date
2. Who
3. Exit
The above should also display the following message “you pressed Control C” on Pressing Ctrl +c.
(5+5 =10 marks)
43. Explain Cut, Paste , Joint, Tr utility with an example
(1X10 =10 marks)

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’.

(5X2 =10 marks)

46. Using SED perform the following functions


a) Print number of lines in input file (i.e. wc –l)
b) Print last line of a file (i.e. tail -1)
c)Out put the entire line except 1 to 20.
d) Output the file after changing mcis to MCIS on lines 10-20
e) Output only the lines that contain either MCIS or Manipal
(5X2 =10 marks)

47. Sed Regular expressions using SED


a) Output the file Depts after changing the first character of the department number from D to
E.
b) Retrieve all the folders in current Directory.
c) For each line, if the sixth character is a W, print”
d) print section of file between two regular expressions
e) Delete all lines NOT beginning with an 'a,e,E or I'"
(5X2 =10 marks)

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

57. Explain the working of the following sed commands 10


1) sed -e 's/dog/cat/g' -e 's/cat/elephant/g' filename
2) sed '/debug/d' < log
3) sed -e '/^line.*one/ s/line/LINE/' -e '/line/d' filename
4) sed /start/,/stop/ y/abc/xyz/ filename
5) sed /Northeast$/{
s/Northeast$//
w region.NE
}

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)

62. Write AWK scripts to do the following


a) Display all input lines for which field 3 is greater than 5
b) Write the line number and number of fields in each line. The three strings representing the
line number, the colon, and the number of fields are concatenated and that string is written
to standard output
c) Write lines longer than 72 characters
d) Write all lines between occurrences of the strings start and stop
e) Print any line where field #5 is not equal to "abc123"
(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)

65. a) Explain the basic structure of AWK with an example


b) Print all words that appear more than 10 times in input
(5X2=10 marks)

66. a) Explain END and BEGIN pattern in AWK with an example


b) Print all lines where the 3rd field multiplied by the 4th field is bigger than 500
c) Print all line where the 3rd field is 100 or the 4th field is bigger than 50

(6+2+2 =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)

68. Write AWK script


a) To display total number of lines, words and characters in a file.
b) To Print the length of the longest input line
(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

2. Explain any 5 built-in string functions in AWK


76. The input file consist of the following fields serial number, student name, attendance followed by a
series of marks obtained in each subject, write a awk script to do the following operations. 10

1. Calculate average marks obtain by the students


2. List how many students are there
3. Calculate total number of students whose attendance is > 90%
4. Print complete record if student name is ‘Joe’
5. Print  all the  records without marks
77. Write an awk script that will take a number N as input on the command line. Then count the
number of lines in the input file that have fields greater than N and display the complete lines. In
place of the lines that do not have the required number of fields print the difference between the
number of fields that are present and N 10
78. The input file bookdetails.txt contains records with fields — item number, Book name, number of
copies sold and Rate per book. Write an Awk script to reads and processes the above
bookdetails.txt file, and generates the final bill that displays — name of each book, total amount on
the number of copies sold, and finally total amount for all the books sold, the output should be well
formatted 10
79. The input file grades.txt contains records with fields ---- Student name followed by a series of marks
obtained in each subject, Write an awk script to average each student’s marks and to give a letter
grade, also calculate the class averages and determine the number of student’s above and below
class average 10
80. The input file employee.txt contains records with fields ---- Employee ID, Employee Name,
Designation, Department and Salary, each records are separated by double new line, and each
fields are separated by a new line character. Write an Awk script to reads and processes the above
employee.txt file, and generates a report that displays — Employee Name, Department and Salary,
finally print the total number of records processed and the total expenditure of the employer on
man power 10

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)

85. Explain looping and branching conditions in PERL with an example.


(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

ARAVINDA (Diode): Qno. 78 to 88


DIVYA(rat): Qno. 34 to 44
CHETHAN(focus light): Qno. 89 to 100
ROCHELLE(jumbo mummy): Qno. 45 to 55
JOSHI(sleeping baby): Qno. 12 to 22
BENHUR(disco light): Qno. 23 to 33
PRADEEP(carpenter): Qno. 1 to 11
SRIKANTH(horlicks baby): Qno. 67 to 77
PRATAP(vajra muni): Qno. 56 to 66

You might also like