1.
Which of the following is not a proper shell name?
Correct Answer
D. Ssh : sea shell
Explanation
The given answer "ssh : sea shell" is not a proper shell name because "sea shell" is not a recognized shell in the Unix/Linux operating system. The other options, csh, ksh, and bash, are all legitimate shell names commonly used in Unix/Linux systems.
2.
In Shell scripting, What does $? Return?
Correct Answer
A. $? will return exit status of command .0 if command gets successfully executed ,non-zero if command failed.
Explanation
The correct answer is that "$?" will return the exit status of a command. It will return 0 if the command gets successfully executed and a non-zero value if the command fails.
3.
In Shell scripting, What does $# stand for?
Correct Answer
B. Will return the number of parameters that are passed as the command-line arguments
Explanation
The correct answer is "Will return the number of parameters that are passed as the command-line arguments." In Shell scripting, the special variable "$#" represents the number of parameters that are passed as command-line arguments. It is often used to determine the number of arguments provided to a script or function.
4.
In Shell scripting, what is $*?
Correct Answer
C. Its mainly used for showing up all params. This show all parameter values passed in shell script
Explanation
$* is a special variable in Shell scripting that is used to display all the parameter values passed in a shell script. It is mainly used to show all the parameter values passed in the script.
5.
How do you find out what’s your shell?
Correct Answer
C. Echo $SHELL
Explanation
The correct answer is "echo $SHELL" because the command "echo" is used to display the value of the environment variable "$SHELL", which stores the path to the current user's shell. By executing this command, the shell will return the path to the current shell being used.
6.
Why should the Bourne shell be used for writing shell scripts?
Correct Answer
B. Standard and portable
Explanation
The Bourne shell should be used for writing shell scripts because it is standard and portable. This means that scripts written in the Bourne shell can be easily run on different systems without any compatibility issues. It provides a consistent and reliable scripting environment, making it a preferred choice for writing shell scripts. Additionally, being widely available and easy to use further adds to its advantages.
7.
How do shell scripts receive input?
Correct Answer
D. All of the above
Explanation
Shell scripts can receive input in multiple ways. They can read keyboard data entered by a user, use the output of another program as input, or use a file's contents as input. Therefore, the correct answer is "All of the above."
8.
Which one of the following files contains the name of your login shell?
Correct Answer
A. /etc/passwd
Explanation
The correct answer is /etc/passwd. The /etc/passwd file is a system file that contains information about user accounts on a Unix-like operating system. It stores the username, user ID, group ID, home directory, and login shell of each user. Therefore, the name of the login shell can be found in this file.
9.
When a shell script begins, it has an initial value for the PATH variable. Where does this value come from?
Correct Answer
A. It’s passed down from the script’s parent shell
Explanation
The initial value for the PATH variable in a shell script is passed down from the script's parent shell. This means that when the script is executed, it inherits the value of the PATH variable from the shell that launched it.
10.
Which shell is the parent process of the Korn shell seen in the listing above?
Correct Answer
C. The C shell
Explanation
The C shell is the parent process of the Korn shell seen in the listing above.
11.
Which quoting mechanism is used to protect $, > and * from shell?
Correct Answer
A. Single
Explanation
The single quoting mechanism is used to protect special characters like $, >, and * from being interpreted by the shell. When a string is enclosed in single quotes, the shell treats it as a literal string and does not expand variables or interpret special characters within it. This ensures that the characters are treated as regular characters and not as part of any shell command or operation.
12.
Study the following steps:
name=cat
namelast=meow
echo $name `echo last`
How can the above echo command be modified to display the string meow?
Correct Answer
D. Both eval echo \$name `echo last` & eval ‘$name’ `echo last`
Explanation
Both options "eval echo \$name `echo last`" and "eval ‘$name’ `echo last`" will display the string "meow" because they use the "eval" command to evaluate the value of the variable "name" and then concatenate it with the result of the command "echo last". This will result in the string "meow" being displayed. The other options do not include the necessary evaluation of the variable and will not display the desired string.
13.
How to check if a file is present in a particular directory in Unix?
Correct Answer
A. Ls –l myFile.txt; echo $?
Explanation
The correct answer is "ls –l myFile.txt; echo $?" because the "$?" variable in Unix stores the exit status of the previous command. In this case, the "ls -l myFile.txt" command is used to list the file details, and the "echo $?" command is used to display the exit status. If the file is present in the directory, the exit status will be 0, indicating success. If the file is not present, the exit status will be 1, indicating failure.
14.
How to remove the last line/ trailer from a file in UNIX?
Correct Answer
B. Sed –i '$ d' file.txt
Explanation
The correct answer is "sed –i '$ d' file.txt". In sed command, the option -i is used to edit the file in-place. The '$' represents the last line of the file and 'd' is the command used to delete the line. Therefore, the command "sed –i '$ d' file.txt" will remove the last line or trailer from the file in UNIX.
15.
Which command is used to sort the lines of data in a file in reverse order?
Correct Answer
D. Sort -r
Explanation
The command "sort -r" is used to sort the lines of data in a file in reverse order. The "-r" flag stands for reverse, indicating that the sorting should be done in descending order instead of ascending order. This command is useful when you want to arrange the lines of data in a file in reverse alphabetical or numerical order.
16.
Which command is used to display the top of the file?
Correct Answer
B. Head
Explanation
The "head" command is used to display the top of a file. It allows users to view the first few lines of a file, typically the first 10 lines by default. This command is commonly used to quickly check the contents of a file without having to open the entire file.
17.
Which symbol will be used with grep command to match the pattern pat at the beginning of a line?
Correct Answer
A. ^pat
Explanation
The symbol "^" is used with the grep command to match the pattern "pat" at the beginning of a line. This symbol signifies the start of a line, so using it before the pattern ensures that the pattern is only matched if it appears at the beginning of a line.
18.
Which command is used to change protection mode of files starting with the string emp and ending with 1,2, or 3?
Correct Answer
A. Chmod u+x emp[l-3]
Explanation
The correct answer is "chmod u+x emp[l-3]". This command uses the "chmod" command to change the protection mode of files starting with the string "emp" and ending with the numbers 1, 2, or 3. The "[l-3]" part specifies a range of numbers from l to 3, so it will match any of the specified endings. The "u+x" part of the command adds execution permission for the owner of the files.
19.
How can you display a list of all files, including the hidden files?
Correct Answer
B. Ls -a
Explanation
The correct answer is "ls -a". The "ls" command is used to list files and directories, and the "-a" option is used to display all files, including hidden files. Therefore, "ls -a" will display a list of all files, including the hidden files.
20.
How to create a new file without opening it?
Correct Answer
B. Touch filename
Explanation
The correct answer is "touch filename". The touch command is used to create a new file without opening it. It updates the access and modification timestamps of the file, and if the file does not exist, it creates a new empty file with the specified name. This command is commonly used in Unix-like operating systems to create new files quickly and efficiently.
21.
What do you use to forward errors to a file?
Correct Answer
A. 2> filename
Explanation
The correct answer is "2> filename". In Unix-like operating systems, the "2>" syntax is used to redirect the standard error stream to a file. By using this syntax followed by the desired filename, any error messages or output generated by a command will be written to the specified file instead of being displayed on the screen. This is useful for capturing and analyzing error information for troubleshooting purposes.
22.
With what can you stop a process?
Correct Answer
B. Kill
Explanation
You can stop a process by using the "Kill" command. This command terminates a running process forcefully, effectively stopping it. It is commonly used in operating systems to end a program or process that is not responding or causing issues. By using the "Kill" command, you can forcefully stop a process and free up system resources.
23.
With what command you can see what folder you are in?
Correct Answer
D. Pwd
Explanation
The "pwd" command stands for "print working directory." When this command is executed in a command line interface, it displays the full path of the current working directory. This allows the user to easily determine which folder they are currently in. Therefore, the correct answer to the question is "pwd."
24.
Which command is most useful when you want not only to send some data down a pipe, but also to save a copy?
Correct Answer
D. Tee
Explanation
The command "tee" is the most useful when you want to send data down a pipe and also save a copy. Tee reads from standard input and writes to standard output and files simultaneously. It allows you to redirect the output of a command to both a file and another command or multiple files. This is helpful when you want to save a copy of the data for future reference or analysis while still passing it along for further processing.
25.
Shell programs are?
Correct Answer
B. Interpreted
Explanation
Shell programs are interpreted. This means that they are executed line by line by an interpreter, rather than being compiled into machine code beforehand. The interpreter reads each line of the program and immediately executes the corresponding command or instruction. This allows for quick and easy development and testing of shell scripts, as changes can be made and executed immediately without the need for a compilation step.
26.
The name of the Unix scheduling utility is?
Correct Answer
B. Cron
Explanation
The correct answer is "Cron". Cron is a Unix scheduling utility that allows users to schedule commands or scripts to run automatically at specified times or intervals. It is commonly used for tasks such as system maintenance, backups, and batch processing. Cron is a powerful tool that helps automate repetitive tasks and improve system efficiency.
27.
Applications of Shell programming include?
Correct Answer
C. Both of the Above
Explanation
Shell programming is a powerful tool that can simplify complex jobs and automate repetitive tasks. By writing scripts in a shell language, users can create a series of commands that can be executed together, saving time and effort. This can be particularly useful for tasks that need to be performed regularly or involve multiple steps. Therefore, the correct answer is "Both of the Above" as shell programming can be used to simplify complex jobs and automate repetitive tasks.
28.
Flow control in a shell program allows parts of a shell program to be executed _______
Correct Answer
C. Both of the Above
Explanation
Flow control in a shell program allows parts of a shell program to be executed repeatedly or conditionally. This means that certain sections of the program can be executed multiple times in a loop, or they can be executed based on a specific condition being met. Both options provide flexibility and control over the execution of the program, allowing for efficient and dynamic programming.
29.
Which of the following is not true of program variables?
Correct Answer
A. Can be exported to the entire system
Explanation
Program variables cannot be exported to the entire system. They are limited to the scope of the program or script in which they are defined. They can be used within the shell program or script and can hold data, but they are not accessible or visible outside of the program or script unless specifically exported or shared.
30.
Look at the following ps –f command :
UID PID PPID C STIME TTY TIME CMD
Correct Answer
D. All of the above
Explanation
The given output of the ps -f command shows the process information in a tabular format. Each row represents a process, and the columns display the UID (user ID), PID (process ID), PPID (parent process ID), C (CPU usage), STIME (start time), TTY (terminal), TIME (CPU time), and CMD (command). The output shows three processes with different PIDs, PPIDs, and commands (/bin/sh, /bin/ksh, and /bin/csh). Therefore, the correct answer is "All of the above" because it includes all the processes listed in the output.