A variable can be removed using _____
1.unset
2.readonly
3.del
4. Bash shell
C shell uses which command for assigning values to variables?
1.=
2. set
3. unset
4.$
readonly command is used to protect a variable from reassignment.
1.True
2.False
3.all of the above
4.None of the mentioned
The command is valid. $ ls -lRa $HOME > home.ls
1. True
2.False
3.all of the above
4.None of the mentioned
The user bhojas logged in and performed the following sequence of command. What will be the output of the last command? $ cd project/module1 $ pwd
1. /home/bhojas/project/module1
2. /home/project/module1
3./usr/bhojas/project/module1
4. project/module1
To display the last five used commands, which one of the following commands is used (in bash shell)?
1.history 5
2. history -5
3.history
4. history 5-
Which of the following is a correct initialization of variables to null strings?
1.x=
2. x=’ ‘
3.x=†“
4.x=, x=’ ‘, x=†“
Which one of the following command will change our primary prompt from $ to C>?
1.PS1=â€C> “
2.PS2=â€C>â€
3.PS1=â€>Câ€
4. PS2=â€<Câ€
Which symbol is used as a shorthand for using the last argument to the previous command?
1.%
2. _
3.|
4. $
After running this program, as your press 4, what will be the output of the program? #!/bin/bash echo "How many times you want to print 'Sanfoundry'" read value for ((i=0;i<$value;i++)) do echo "Sanfoundry"; done exit 0
1.‘Sanfoudry’ will print 4 times
2.‘Sanfoudry’ will print 3 times
3.‘Sanfoudry’ will print 5 times
4.Program will generate an error message
After running this program, if you enter 1000, then what will be the output of the program? #!/bin/bash echo "Please enter a number" read a if [ $a -lt 100 ]; then echo "It is less than 100"; elif [ $a -lt 1000 ]; then echo "It is less than 1000" else echo "It is greater than 1000" fi exit 0
1.It is greater than 1000
2.It is less then 1000
3. It is equal to 1000
4.None of then mentioned
Command substitution is enabled in single quotes also.
1.True
2.False
3.all of the above
4.None of the mentioned
Command substitution requires the command to use _____
1. standard input
2. standard input
3. standard error
4. All of the mentioned
Environment variable names can be defined only in uppercase.
1.True
2. False
3.all of the above
4.None of the mentioned
Environment variables control the behavior of the system.
1.True
2.False
3.all of the above
4.None of the mentioned
Every feature used in an interactive shell can also be used by a shell script.
1.True
2.False
3.all of the above
4.None of the mentioned
Functions improves the shell’s programmability significantly, because
1. when we invoke a function, it is already in the shell’s memory, therefore a function runs faster than seperate scripts
2.function will not provides a piece of code for repetative tasks
3. all of the mentioned
4.None of the mentioned
How can you come out of the loop in this program? #!/bin/bash read x while [ $x != "hello" ] do echo "Try to come out of the loop" read x done echo "Welcome" exit 0
1.by entering “helloâ€
2.by entering anything except “helloâ€
3. it is not possible
4.None of the mentioned
POSIX recommends the use of ____ instead of archaic `command ` for command substitution.
1.|
2. #
3.%
4.$
Shell enables one or more arguments to be obtained from the standard output of another command. This feature is called _____
1.command substitution
2.argument substitution
3.shell substitution
4. korn
Shell variables are of ____ types.
1.1
2.3
3.2
4.4
Suppose ABD_DIR is a local variable. Then it will be accessible to the child process.
1. True
2.False
3.all of the above
4.None of the mentioned
The shell has ____ prompts.
1.1
2.4
3.many
4.2
The UNIX shell is both _______ and _______ language.
1. interactive, responsive
2. interpreter, executing
3.scripting, interpreter
4. high level, low level
The variable assignment as x = 10 (whitespace on both sides of =) will work if we are not using C shell?
1.True
2. FALSE
3.all of the above
4.None of the mentioned
We can also execute previous commands by context.
1. True
2.False
3.all of the above
4.None of the mentioned
We can display an alias definition by using an alias with the name.
1.True
2. False
3.all of the above
4.None of the mentioned
We can use relative addressing while executing previous commands.
1.True b) False
2. False
3.all of the above
4.None of the mentioned
What is the output of this program? #!/bin/bash echo "Which file do you want to check" read x until [ -e $x ] do echo "The file does not exist. Do you want to create? y/n" read a if [ $a = y ]; then touch $x echo "Your file has been created successfully." fi done echo "The file is present in this directory" exit 0
1.it checks the existance of your entered file in the present working directory
2.it creates the file if file does not exists
3. program runs untill you create the file
4.All of the Mentioned
What is the output of this program? #!/bin/bash for i in 2 3 7 do echo "Sanfoundry" done exit 0
1. ‘Sanfoundry’ will print 3 times
2. Nothing will print
3. Program will generate an error message
4. none of the mentioned
What is the output of this program? #!/bin/sh echo "Just call the function" san_function san_function() { echo "This is a function" } exit 0
1.only first string will print without any error
2. only second string will print without any error
3.both strings will print
4.None of the mentioned
What is the output of this program? #!/bin/sh san_function() { echo "Welcome to the Sanfoundry" printf "World of Linux " } unset -f san_function san_function exit 0
1.Welcome to the Sanfoundry
2.World of Linux
3.both Welcome to the Sanfoundry and World of Linux
4.nothing will print
What is the output of this program? #!/bin/sh san_function1() { a=5 echo "This is the first function" san_function2 } san_function2() { echo "This is the second function" san_function3 } san_function3() { echo "This is the third function" } san_function1 exit 0
1.This is the first function This is the second function This is the third function
2.This is the first function This is the third function This is the second function
3.This is the second function This is the first function This is the third function
4.This is the third function This is the first function This is the second function
What will the result when we evaluate this statement? $ directory=’pwd’=`pwd`
1.output of pwd command along with string pwd=
2.undefined output
3.erroneous
4.directory variable will hold string pwd
Which command generates possible completions for string according to the and write it to standard output?
1.compgen
2. complete
3.continue
4. none of the mentioned
Which command is used in bash and Korn shells to display the previously used commands?
1. his
2.history
3.sh
4.ps
Which command runs the shell built-in command ‘command’ with the given argument?
1. builtin
2.caller
3.there is no command present for this purpose
4. none of the mentioned
Which environment variable is used to display our username?
1.PATH
2.MAIL
3. LOGNAME
4.HOME
Which escape sequence is used with PS1 to show the hostname of our computer?
1.
2.c
3.h
4. e
Which of the following function(s) are performed by an interactive shell?
1. job control
2.history
3.aliases
4. job control, history, aliases
Which of the following is an invalid variable?
1._user
2.us01
3.-txtfile
4.txt123
Which of the following is not a system defined variable?
1.$PATH
2.$HOME
3. $SHELL
4.$cd
Which of the following meta-character is used in command substitution?
1. `
2. `
3.“
4.>
Which of the following shell doesn’t support the command substitution using $ recommended by POSIX?
1.Korn
2.bash
3. C
4.Bourne
Which of the following shells support the use of aliases?
1.bourne
2.Korn
3.bash
4.Korn and bash
Which of the following symbols are used for accessing previous commands by event numbers?
1.!
2. r
3.$
4.! and r
Which one of the following command is used to create a child shell?
1.fork
2. wait
3.sh
4.env
Which one of the following is arguably the best shell to use?
1.Bash
2.Korn
3. C
4.Bourne
Which one of the following is not an environment variable?
1. HOME
2.PATH
3.USER
4.env
Which option of the command ‘cd’ use the actual filesystem path for cd.. and the value of pwd?
1.-l
2. -L
3.-p
4. -P
Which symbol is used for assigning a value to variables?
1. $
2.&
3. =
4.@
Which symbol is used for evaluation of variables?
1.$
2. &
3.=
4.@
Which symbol is used for setting the PS1 prompt to show the current event number?
1. ^
2.!
3. &
4. |
____ command displays all the variables available in the current shell.
1.env
2.set
3.var
4.shift
____ command is used to display the environment variables only.
1.set
2. env
3.sh
4.var divs = #("div");