GSEB-11 2014-15: CH. NO 7: Vim Editor & Basic Scripting and Ch.No.8: Advanced Scripting (Self Made, VV IMP) with answers highlighted.

                 1)            Which of the following is/are the best suited for creating text file in Linux?
a) Nano
b) Vim
c) Pico
d) All of these
                 2)            …………………… is a graphical editor available with GNOME desktop environment.
a) Gedit
b) Kwrite
c) Vim editor
d) All of these
                 3)            …………………… is a graphical editor available with KDE desktop environment.
 a) Gedit
b) Kwrite
c) Vim editor
d) All of these
                 4)            …………………… is a visual display editor to write the shell script in Linux.
a) Gedit
b) Kwrite
c) Vim editor
d) All of these
                 5)            The Vim editor is written by ……………………
a) Charles Babbage
b) Dennis Ritchie
c) Linus Torvald
d) Bram Moolenaar
                 6)            The Vim editor was released publicly in the year ……………………
a) 1990
b) 1991
c) 1992
d) 1993
                 7)            The …………………… symbol on the left side of the screen in Vim editor indicates that the lines are yet to be used by the editor.
a) $ (Dollar)
b) > (Greater than sign)
c) ~ (Tilde)
d) None of these
                 8)            The Vim editor functions in …………………… modes.
a) Two
b) Three
c) Four
d) Many
                 9)            When we first start editing a file using the Vim editor, it will start in a …………………… mode.
a) Append
b) Visual
c) Command
d) Insert
            10)            …………………… mode of Vim editor is a flexible and easy way to select a piece of text from the file.
a) Append
b) Visual
c) Command
d) Insert
            11)            When a user issue an insert, append or open command, then user will be in the …………………… mode of Vim editor.
a) Append
b) Visual
c) Command
d) Insert
            12)            Match the following commands with their usage that assist the user in the insert mode of the Vim editor.
Command
Usage
A)     A
1)     To insert text from the beginning of a line.
B)     i
2)     To insert text after the current cursory position
C)     I
3)     To insert in a new line below the current cursor position.
D)    o
4)     To insert text before the current cursor position.
a) A-3, B-4, C-1, D-2
b) A-4, B-2, C-1, D-3
c) A-2, B-4, C-1, D-3
d) None of these
            13)            To close the Vim editor …………………… command is to be issued.
a) exit
b) wq
c) Esc
d) quit
            14)            Match the following commands that can be used in the last line mode along with their usage in Vim editor.
Command
Usage
A)     :w
1)     To quit editing mode without saving changes made in the file.
B)     :x
2)     To quit editing mode when no changes are made.
C)     :q
3)     To save and quit editing mode
D)    :q!
4)     To save file and remain in editing mode.
a) A-4, B-3, C-2, D-1
b) A-3, B-4, C-2, D-1
c) A-2, B-4, C-1, D-3
d) None of these
            15)            Match the following key strokes that are used to navigate within the Vim editor.
Command
Usage
A)     h
1)     Moves cursor right
B)     l
2)     Moves cursor left
C)     j
3)     Moves cursor up
D)    k
4)     Moves cursor down
a) A-3, B-4, C-2, D-1
b) A-2, B-1, C-4, D-3
c) A-2, B-4, C-1, D-3
d) None of these
            16)            Match the following key strokes that are used to navigate within the Vim editor.
Command
Usage
A)     CTRL + d
1)     Scroll back one page.
B)     CTRL + u
2)     Scroll down one half of a page.
C)     CTRL + f
3)     Scroll up one half of a page.
D)    CTRL + b
4)     Scroll forward one page.
a) A-3, B-4, C-2, D-1
b) A-2, B-1, C-4, D-3
c) A-2, B-3, C-4, D-1
d) None of these
            17)            Match the following commands that are used to edit the Vim editor document.
Command
Usage
A)     U
1)     Delete the character before the cursor (Backspace).
B)     D
2)     Overwrite characters from cursor onward.
C)     R
3)     Delete contents of line after cursor.
D)    X
4)     Undo all changes to entire line
a) A-4, B-3, C-2, D-1
b) A-2, B-1, C-4, D-3
c) A-2, B-3, C-4, D-1
d) None of these
            18)            Match the following commands that are used to edit the Vim editor document.
Command
Usage
A)     dd
1)     Delete N number of lines.
B)     Ndd
2)     Delete single line
C)     Ndw
3)     Change Word
D)    cw
4)     Delete N number of words
a) A-4, B-3, C-2, D-1
b) A-2, B-1, C-4, D-3
c) A-2, B-3, C-4, D-1
d) None of these
            19)            Match the following commands that are used for search or replace operation within a file.
Command
Usage
A)     /
1)     Search again in the opposite direction.
B)     ?
2)     Search for text in a forward direction.
C)     n
3)     Search for text in a backward direction.
D)    Shift + n
4)     Search again in the same direction.
a) A-4, B-3, C-2, D-1
b) A-2, B-1, C-4, D-3
c) A-2, B-3, C-4, D-1
d) None of these
            20)            The …………………… extension is used to specify that the file is a shell script.
a) sh
b) scr
c) ss
d) None of these
            21)            Which of the following statement is incorrect in context to a shell scrip file?
a) A shell script file must have the .sh as the extension of file.
b) A shell script is a script combination of multiple commands in it.
c) It is not mandatory to create a file with an extension .sh for shell script.
d) None of these
            22)            To execute the shell script file, user needs to execute the …………………… command.
a) sh
b) bash
c) Either (a) or (b)
d) None of these
            23)            The …………………… is used to insert a comment is shell script.
a) //
b) $
c) #
d) None of these
Read the following script and answer the following question(s).
1.       #Script1: Script to welcome the user who has logged into the system.
2.       clear
3.       echo Hello
4.       who am i
5.       echo Welcom to Ubunto Linux
            24)            The Line 2 ‘clear’ is used to ……………………
a) delete all the files of the directory.
b) clear all the junk characters of the file.
c) delete all the directories of the current director.
d)  None of these
            25)            The Line 3 and 5 has ‘echo’; what is echo?
a) a variable
b) a command
c) an operator
d) None of these
            26)            Which of the above line will display the name and some additional details of the user currently longed into the system.
a) Line 2
b) Line 3
c) Line 4
d) None of these
            27)            Shell script has one of the most common features of higher level programming is provision of ……………………
a) data types
b) variables
c) commands
d) operators
            28)            …………………… are entities wherein user can store or edit a value.
a) data types
b) variables
c) commands
d) operators
            29)            The …………………… symbol is preceding the variable name instructs the shell script to extract the value stored or assigned in the variable.
a) @
b) #
c) $
d) ~
            30)            Which of the following statement is correct, in context to assigning the value to a variable?
a) subject=”Computer Science”
b) subject =”Computer Science”
c) subject = ”Computer Science”
d)  All of these
            31)            Which of the following rule(s) is/are to be followed before defining a variable in a shell script?
a) A variable name can consists of alphabets, digits or an underscore(_).
b) No special character other than underscore allowed as part of variable name.
c) The first character of a variable name must either be an alphabet or an underscore.
d) All of these
            32)            The …………………… command expects the user to key in the data on the standard input device.
a) input
b) read
c) enter
d) None of these
            33)            The …………………… option is used with echo command, which will instruct the script not to print a new line after he message is displayed.
a) -a
b) -n
c) -x
d) None of these
            34)            The …………………… command by default inserts a new line after displaying the message.
a) display
b) print
c) echo
d) cout
            35)            Which of the following code segment is correct as per the shell script rules?
a) sum =`expr $num1 + $num2`
b) sum = `expr $num1+$num2`
c) sum=`expr $num1 + $num2`
d) None of these
            36)            Match the symbols with the operations .
Command
Usage
A)     +
1)     Multiplication
B)     *
2)     Division
C)     %
3)     Addition
D)    /
4)     Modulus
a) A-3, B-1, C-2, D-4
a) A-3, B-1, C-4, D-2
c) A-4, B-1, C-2, D-3
d) None of these
            37)            The …………………… command is used to see the processes viw the process of all the users.
a) PID
b) ps
c) Either (a) or (b)
d) None of these
            38)            Match the following meaning of the some of the columns listed for Process ID.
Command
Usage
A)     UID
1)     The start time for the current process.
B)     PID
2)     Name or number of the user who owns the process.
C)     PPID
3)     A unique numeric process identifier assigned to each process.
D)    STIME
4)     Identifies the parant process id, the process that created the current process.
a) A-2, B-1, C-4, D-2
a) A-3, B-1, C-4, D-1
c) A-2, B-3, C-4, D-1
d) None of these
            39)            To remove the process from the memory …………………… command is used.
a) terminate
b) clear
c) kill
d) destroy
            40)            The exit status of if command is set to 0, when ……………………
a) it has been executed successfully.
b) it has not been executed successfully.
c) the statement does not state any value.
d) None of these
            41)            Which of the following decision making instructions can be used when creating a shell script in Linux?
a) if-then-fi
b) if-then-else-fi
c) if-then-elif-then-else-fi
d) All of these
            42)            Which of the following decision making instructions cannot be used when creating a shell script in Linux?
a) case-esac
b) if-then-fi
c) if-elif-fi
d) None of these
            43)            Which of the following test(s) is/are being performed with if statement?
a) numerical test
b) string test
c) file test
d) All of these  
            44)            Match the following operators with their usage.
Command
Usage
A)     –gt
1)     Less than or equal to
B)     –lt
2)     Greater than or equal to
C)     –ge
3)     Less than
D)    –le
4)     Greater than
a) A-2, B-1, C-4, D-2
a) A-2, B-1, C-4, D-3
c) A-2, B-3, C-1, D-4
d) None of these
            45)            To combine one or more conditions, the user should user the …………………… operators in Shell script.
a) Relational
b) Arithmetic
c) Logical
d) None of these
            46)            The relational “NOT EQUAL TO” operators is used as …………………… in shell script.
a) -ne
b) !n
c) -NE
d) !N
            47)            The logical OR operators is used as …………………… in shell script.
a) -o
b) -or
c) -O
d) -OR
            48)            The logical AND operators is used as …………………… in shell script.
a) -n
b) -a
c) -an
d) -and
            49)            Match the file operators for condition tested with their output/usage/ meaning.
Condition tested
Output
A)     –s name
1)     True if a file with the specified name exists and is not a directory.
B)     –f name
2)     True if the directory with the specified name exists.
C)     –r name
3)     True if a file with the specified name exists and has size greater than 0
D)    –d name
4)     True if a file with the specified name exists and the user has read permission on it.
a) A-2, B-3, C-4, D-1
b) A-2, B-1, C-4, D-3
c) A-3, B-1, C-4, D-2
d) None of these
            50)            The alternate option for using if statement for checking the condition is a ……… statement.
a) loop
b) case
c) repetition
d) function
            51)            The process of repeating the some commands number of lines is known as ……………………
a) decision making
b) looping
c) functioning
d) None of these
            52)            Linux provides …………………… keywords that can be used to perform repetitive actions.
a) two
b) three
c) four
d)five
            53)            The …………………… command repeates the set of commands specified between keywords do and done statements.
a) while
b) for
c) Both (a) & (b)
d) None of these
            54)            The …………………… loop executes till the conditions is false.
a) for
b) while
c) until
d) do
            55)            …………………… are the small subscripts within a shell script, which are used to make the scripting more modular.
a) Loops
b) Decision Structures
c) Functions
d) None of these
            56)            The function written in shell script returns a ……………………
a) value
b) status code
c) variable
d) function
            57)            The …………………… indicates after a variable name that it is a fnction.
a) ( )
b) [ ]
c) { }
d) None of these
            58)            Which of the following keyword specifies the end of the case statement?
a) end-case
b) esac
c) case end
d) stop case
            59)            In case structure, which of the following character denotes the default case?
a) *
b) +
c) d
d) None of these
            60)            Which of the following is used to break the flow of control in the case statement?
a) **
b) ;;
c) ++
d) >>
            61)            Which of the following command is used to set the file permission as executable?
a) x
b) r
c) w

d) e

No comments

Post your comments

Powered by Blogger.