InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Command substitution requires the command to use ________(a) standard input(b) standard output(c) standard error(d) all of the mentionedI got this question in an interview for internship.This is a very interesting question from Command Substitution and Shell Variables in division The Shell of Unix |
|
Answer» The correct answer is (b) STANDARD output |
|
| 2. |
Which of the following is not a system defined variable?(a) $PATH(b) $HOME(c) $SHELL(d) $cdThis question was posed to me in a job interview.The doubt is from Command Substitution and Shell Variables topic in section The Shell of Unix |
|
Answer» The correct answer is (d) $cd |
|
| 3. |
Which of the following is an invalid variable?(a) _user(b) us01(c) -txtfile(d) txt123The question was asked by my college professor while I was bunking the class.My enquiry is from Command Substitution and Shell Variables topic in division The Shell of Unix |
|
Answer» Correct option is (c) -txtfile |
|
| 4. |
C shell uses which command for assigning values to variables?(a) =(b) set(c) unset(d) $The question was posed to me by my college professor while I was bunking the class.This interesting question is from Command Substitution and Shell Variables topic in division The Shell of Unix |
|
Answer» Right choice is (b) set |
|
| 5. |
The variable assignment as x = 10 (whitespace on both sides of =) will work if we are not using C shell?(a) True(b) FalseI have been asked this question in a national level competition.This interesting question is from Command Substitution and Shell Variables in division The Shell of Unix |
|
Answer» CORRECT choice is (b) False Explanation: If we are using any other shell other than C shell, the assignment in the FORM x = 10 will PRODUCE an error because the shell will interpret x as a COMMAND and =,10 as its arguments. |
|
| 6. |
readonly command is used to protect a variable from reassignment.(a) True(b) FalseI have been asked this question in homework.The above asked question is from Command Substitution and Shell Variables topic in portion The Shell of Unix |
|
Answer» The CORRECT OPTION is (a) True |
|
| 7. |
Which of the following is a correct initialization of variables to null strings?(a) x=(b) x=’ ‘(c) x=” “(d) x=, x=’ ‘, x=” “The question was posed to me by my college director while I was bunking the class.I want to ask this question from Command Substitution and Shell Variables topic in chapter The Shell of Unix |
|
Answer» CORRECT option is (d) X=, x=’ ‘, x=” “ The BEST explanation: All shell variables are initialized to NULL strings by a string. While explicit ASSIGNMENT of null strings can be performed with x=’ ‘ or x=” “ or x= |
|
| 8. |
A variable can be removed using _____(a) unset(b) readonly(c) del(d) bashI have been asked this question during a job interview.This question is from Command Substitution and Shell Variables in chapter The Shell of Unix |
|
Answer» The correct CHOICE is (a) UNSET |
|
| 9. |
Which symbol is used for assigning a value to variables?(a) $(b) &(c) =(d) @I have been asked this question in an internship interview.My question is taken from Command Substitution and Shell Variables topic in section The Shell of Unix |
|
Answer» Correct answer is (c) = |
|
| 10. |
Which symbol is used for evaluation of variables?(a) $(b) &(c) =(d) @The question was asked in an interview for job.My question is taken from Command Substitution and Shell Variables topic in portion The Shell of Unix |
|
Answer» RIGHT CHOICE is (a) $ The explanation: The shell supports variables that are useful both in the command line and shell scripts. These variables are called shell variables like TERM and SHELL.A variable assignment is of the form variable=value(no spaces around =), but its evaluation REQUIRES the $ as a prefix to the variable name. For EXAMPLE, |
|
| 11. |
Which of the following shell doesn’t support the command substitution using $ recommended by POSIX?(a) Korn(b) bash(c) C(d) bourneThis question was addressed to me by my school teacher while I was bunking the class.This question is from Command Substitution and Shell Variables in chapter The Shell of Unix |
|
Answer» Right option is (d) bourne |
|
| 12. |
POSIX recommends the use of ____ instead of archaic `command ` for command substitution.(a) |(b) #(c) %(d) $The question was asked in examination.My question is based upon Command Substitution and Shell Variables topic in division The Shell of Unix |
|
Answer» Right answer is (d) $ |
|
| 13. |
Shell enables one or more arguments to be obtained from the standard output of another command. This feature is called _________(a) command substitution(b) argument substitution(c) shell substitution(d) kornThis question was posed to me in examination.My question is based upon Command Substitution and Shell Variables topic in division The Shell of Unix |
|
Answer» Correct option is (a) command substitution |
|
| 14. |
Which of the following meta-character is used in command substitution?(a) `(b) ‘(c) “(d) >The question was posed to me in class test.This intriguing question originated from Command Substitution and Shell Variables in portion The Shell of Unix |
|
Answer» Correct CHOICE is (a) ` |
|
| 15. |
Command substitution is enabled in single quotes also.(a) True(b) FalseThis question was addressed to me during a job interview.The query is from Command Substitution and Shell Variables topic in portion The Shell of Unix |
|
Answer» CORRECT option is (B) False The BEST I can explain: Command substitution is enabled only when we use double quotes. If we use single quotes, it will not WORK. For example, |
|
| 16. |
Apart from its use in redirection, /dev/tty can also be used as an argument to some commands.(a) True(b) FalseI have been asked this question by my college professor while I was bunking the class.My query is from Redirection and Pipes topic in chapter The Shell of Unix |
|
Answer» The correct option is (a) True |
|
| 17. |
Which of the following is not true about tee command?(a) it is a feature of the shell(b) it is an external command(c) tee command duplicates its input(d) tee is an internal commandI got this question during an interview.The doubt is from Redirection and Pipes in section The Shell of Unix |
|
Answer» The correct choice is (a) it is a feature of the SHELL |
|
| 18. |
tee is an internal command.(a) True(b) FalseThe question was posed to me in an internship interview.The above asked question is from Redirection and Pipes topic in section The Shell of Unix |
|
Answer» The correct answer is (b) False |
|
| 19. |
Which command saves one copy of character stream in a file and store the other to standard output?(a) who(b) ls(c) tee(d) wcThis question was posed to me during an online interview.My question comes from Redirection and Pipes topic in section The Shell of Unix |
|
Answer» Correct option is (c) tee |
|
| 20. |
In a pipeline, the command on the left of | must use standard output and one on the right must use standard input.(a) True(b) FalseThis question was addressed to me by my college director while I was bunking the class.Asked question is from Redirection and Pipes in division The Shell of Unix |
|
Answer» Right ANSWER is (a) True |
|
| 21. |
We can use the > symbol along with pipe in a command.(a) True(b) FalseThe question was asked in a national level competition.My question is taken from Redirection and Pipes topic in section The Shell of Unix |
|
Answer» The correct option is (a) True |
|
| 22. |
Which symbol is used to connect different streams?(a) |(b) >(c) |
|
Answer» CORRECT option is (a) | The best I can explain: The shell can connect DIFFERENT streams using a special operator called PIPE (|) and avoid CREATION of disk FILE. We can connect two commands using this operator so that one command can take the output of other as its input. For example, |
|
| 23. |
Which file is used for indicating terminals?(a) /dev/tty(b) /dev/null(c) terminal file(d) device fileI got this question in homework.My doubt stems from Redirection and Pipes topic in division The Shell of Unix |
|
Answer» Right answer is (a) /dev/tty |
|
| 24. |
Which symbol is used to redirect error messages to /dev/null?(a) %(b) $(c) >(d) |
|
Answer» The CORRECT answer is (c) > |
|
| 25. |
Which of the following files are known as special files in UNIX?(a) sample.txt(b) /dev/null(c) /dev/tty(d) /dev/null and /dev/ttyThis question was addressed to me in final exam.Query is from Redirection and Pipes in division The Shell of Unix |
|
Answer» Correct answer is (d) /dev/null and /dev/tty |
|
| 26. |
The size of /dev/null is always zero.(a) True(b) FalseI have been asked this question during an interview.My question comes from Redirection and Pipes in section The Shell of Unix |
|
Answer» Right option is (a) True |
|
| 27. |
We can redirect the error message to file named newfile using __________ command.(a) catfooerrorfile(b) catfoo >errorfile(c) cat errorfile>foo(d) cat foo 2>errorfileThe question was posed to me by my school principal while I was bunking the class.This interesting question is from Redirection and Pipes in division The Shell of Unix |
|
Answer» Right answer is (d) cat foo 2>errorfile |
|
| 28. |
Which file descriptor is used to represent standard error stream?(a) 0(b) 1(c) 2(d) 3I got this question during an online exam.This question is from Redirection and Pipes topic in chapter The Shell of Unix |
|
Answer» RIGHT answer is (c) 2 The best EXPLANATION: Each of the three standard files is represented by a number called as a file descriptor. A file is opened using its pathname, but subsequent read and write operations identify the file by this file descriptor. Whenever we ENTER an incorrect command or try to OPEN a non-existent file, certain diagnostic messages are displayed onto the terminal. This is the standard error stream whose DEFAULT destination is the terminal. |
|
| 29. |
The >> symbol is used to overwrite the existing file if it exists.(a) True(b) FalseThe question was asked during an interview for a job.Question is taken from Redirection and Pipes topic in chapter The Shell of Unix |
|
Answer» CORRECT choice is (b) False Easy explanation: The SHELL provides the >> symbol (right chevron used twice) to append to an EXISTING file. For example, //Do a word count PROGRAM on sample.txt and append the output to NEWFILE as shown below. $ wcsample.txt >> newfile |
|
| 30. |
Which of the following symbol(s) can be used to redirect the output to a file or another program?(a) |(b) >(c) >>(d) |, > and >>This question was posed to me by my college director while I was bunking the class.This is a very interesting question from Redirection and Pipes in section The Shell of Unix |
|
Answer» CORRECT option is (d) |, > and >> Explanation: All commands DISPLAYING output on the TERMINAL actually write to the standard output file as a stream of CHARACTERS and not directly to the terminal as such. The symbol > will replace the default destination (terminal) with any file by using the > operator, followed by the filename while the symbol >> is used to append to a file. | is used to give input to another program. |
|
| 31. |
Which symbol is used for taking input from standard input?(a) &(b) %(c) –(d) $The question was posed to me during an interview.Query is from Redirection and Pipes topic in section The Shell of Unix |
|
Answer» CORRECT option is (c) – For explanation: When a command TAKES input from multiple SOURCES –say a file and STANDARD input, the – symbol is used to indicate the sequence of TAKING input. For example, |
|
| 32. |
The command wc < sample.txt will count data from the file sample.txt.(a) True(b) FalseI have been asked this question in examination.My enquiry is from Redirection and Pipes in portion The Shell of Unix |
|
Answer» The correct option is (a) True |
|
| 33. |
Which stream is used for representing error messages?(a) standard input(b) standard output(c) standard error(d) errorThis question was addressed to me by my school principal while I was bunking the class.I want to ask this question from Redirection and Pipes topic in portion The Shell of Unix |
|
Answer» Right OPTION is (C) standard error |
|
| 34. |
Which stream is connected to the display?(a) standard input(b) standard output(c) standard error(d) errorThe question was asked in an interview.This question is from Redirection and Pipes topic in chapter The Shell of Unix |
|
Answer» Right option is (b) STANDARD output |
|
| 35. |
How many files are used for representing different standard streams?(a) 1(b) 2(c) 4(d) 3This question was addressed to me in an internship interview.I would like to ask this question from Redirection and Pipes in division The Shell of Unix |
|
Answer» CORRECT ANSWER is (d) 3 To explain I would say: The shell associates three files with the terminal –two for display and one for the keyboard. These SPECIAL files are actually streams of CHARACTERS which MANY commands see as input and output. Each stream is associated with a default device –which is terminal. These three files are: •Standard Input •Standard output •Standard error |
|
| 36. |
Redirection is a process of switching of the standard stream of data.(a) True(b) FalseI got this question in final exam.Query is from Redirection and Pipes topic in section The Shell of Unix |
|
Answer» Correct answer is (a) True |
|
| 37. |
Which of the following command will remove the file named * ?(a) rm *(b) rm ‘*’(c) rm \*(d) rm ‘*’ and rm \*I got this question at a job interview.This interesting question is from Pattern Matching, Escaping and Quoting in division The Shell of Unix |
|
Answer» Right CHOICE is (d) rm ‘*’ and rm \* |
|
| 38. |
Double quotes are more permissive than single quotes and allow the evaluation of the $ and ` itself.(a) True(b) FalseI have been asked this question in homework.Query is from Pattern Matching, Escaping and Quoting in division The Shell of Unix |
|
Answer» The correct answer is (a) True |
|
| 39. |
For escaping the newline character we can use ____(a) /(b) \(c) ?(d) \nI got this question at a job interview.Origin of the question is Pattern Matching, Escaping and Quoting in portion The Shell of Unix |
|
Answer» Correct answer is (b) \ |
|
| 40. |
We can escape the \ itself using escaping.(a) True(b) FalseThis question was addressed to me in my homework.Question is from Pattern Matching, Escaping and Quoting in portion The Shell of Unix |
|
Answer» Right ANSWER is (a) True |
|
| 41. |
To remove the file named my document.txt, which one of the following commands will be used?(a) rm my\ document.txt(b) rm my document.txt(c) rm *(d) rm my_document.txtI got this question in an interview for job.I would like to ask this question from Pattern Matching, Escaping and Quoting topic in division The Shell of Unix |
|
Answer» The correct answer is (a) RM my\ document.txt |
|
| 42. |
Providing a backslash (\) before the wild card to remove its special meaning is called _____(a) escaping(b) quoting(c) listing(d) pattern matchingI had been asked this question in an online quiz.My doubt stems from Pattern Matching, Escaping and Quoting in portion The Shell of Unix |
|
Answer» Correct option is (a) escaping |
|
| 43. |
Enclosing the wild card or the entire pattern within quotes is called ___(a) escaping(b) quoting(c) listing(d) pattern matchingI got this question in semester exam.This interesting question is from Pattern Matching, Escaping and Quoting topic in division The Shell of Unix |
|
Answer» CORRECT option is (b) QUOTING The explanation is: There is another way to turn off the meaning of the metacharacter. When a command argument is ENCLOSED in quotes, the meaning of all special characters is turned off. This METHOD is called quoting. For EXAMPLE, |
|
| 44. |
The command cd * will work.(a) True(b) FalseThe question was posed to me during a job interview.I need to ask this question from Pattern Matching, Escaping and Quoting topic in chapter The Shell of Unix |
|
Answer» Right option is (a) True |
|
| 45. |
Which of the following shell doesn’t support ! symbol for negating the character class?(a) bash(b) bash(c) POSIX(d) CI have been asked this question in a job interview.My query is from Pattern Matching, Escaping and Quoting topic in division The Shell of Unix |
|
Answer» CORRECT OPTION is (d) C The explanation is: The ! SYMBOL cannot be USED to negate a character class in a C shell. In fact, C shell doesn’t provide any MECHANISM for doing so. |
|
| 46. |
* and ? cannot match ____(a) /(b) $(c) .(d) / and .The question was asked during an interview.This intriguing question originated from Pattern Matching, Escaping and Quoting topic in section The Shell of Unix |
|
Answer» Correct answer is (d) / and . |
|
| 47. |
Which of the following symbol is used for negating the character class?(a) .(b) *(c) !(d) %I had been asked this question in a job interview.This key question is from Pattern Matching, Escaping and Quoting in chapter The Shell of Unix |
|
Answer» Right ANSWER is (c) ! |
|
| 48. |
Which of the following files will not be deleted using “rm chap??” ?(a) chap01(b) chap02(c) chaptd(d) chactdThis question was addressed to me in an online quiz.My query is from Pattern Matching, Escaping and Quoting topic in section The Shell of Unix |
|
Answer» RIGHT option is (d) chactd The explanation: Since ? is USED to match a SINGLE character, ?? can match two characters. So the above command will remove all FILES with a filename starting with a prefix ‘CHAP’, followed by any two characters. |
|
| 49. |
Which of the following command will list all the hidden filenames in our directory having at least three characters after the dot (.)?(a) ls(b) ls -a(c) ls.???*(d) ls *This question was posed to me during an interview.I'd like to ask this question from Pattern Matching, Escaping and Quoting topic in portion The Shell of Unix |
|
Answer» Correct CHOICE is (C) ls.???* |
|
| 50. |
Which of the following is not a wild-card?(a) *(b) ?(c) $(d) %The question was posed to me during an online interview.This interesting question is from Pattern Matching, Escaping and Quoting topic in division The Shell of Unix |
|
Answer» Right answer is (c) $ |
|