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. |
What is the best way to run a script in the background? |
|
Answer» For a SCRIPT to run in the BACKGROUND, SIMPLY ADD "&" at the end of the command. Example: script.sh & command & |
|
| 2. |
What is the use of the "$?" command? |
|
Answer» By USING the COMMAND "$?", you can FIND out the status of the LAST command executed. |
|
| 3. |
What does the . (dot) indicate at the beginning of the file name? How can it be listed? |
|
Answer» If the file name begins with ".", it is a hidden file. When a dot appears at the beginning of a filename, the file is hidden in most file managers and shell PROGRAMS. A Shell usually lists all the files except hidden files when you try to list the files in a shell. Despite this, hidden files can be found in the DIRECTORY. The Is COMMAND must be run with the "–a" FLAG if you wish to SEE hidden files. |
|
| 4. |
How long does a variable in a shell script last? |
|
Answer» VARIABLES inside shell scripts have a LIFESPAN of only as long as the EXECUTION LASTS. |
|
| 5. |
Name the command that can be used to find out the number of arguments passed to the script? |
|
Answer» The following COMMAND will display the number of ARGUMENTS PASSED to the script: ECHO $ # |
|
| 6. |
Write the command that is used to execute a shell file. |
|
Answer» Firstly, USE the chmod command to SET execute PERMISSION on your SCRIPT as shown below: chmod +x script-name-here.SH Secondly, run or execute your script as follows: ./script-name-here.sh Alternatively, you can execute shell script by: sh script-name-here.sh |
|
| 7. |
What is the importance of $#? |
|
Answer» $# usually holds the number of arguments, although it may be DIFFERENT for FUNCTIONS. To put it SIMPLY, it was USED to STORE the number of command-line arguments passed to a shell script. |
|
| 8. |
Explain the way you can connect to a database server. |
|
Answer» Open client DRIVER COMES with the isql utility that can be used to connect to a database SERVER from Linux. Here's how to do it: isql –S SERVERNAME –U username –P password |
|
| 9. |
Name the alternative command for echo. |
|
Answer» The tput COMMAND is an alternative command for echo. We can USE this command to control how the output is DISPLAYED. Additionally, shell SCRIPTS can do things such as underline text and center text, regardless of the size of the SCREEN. |
|
| 10. |
What is a file system? Write down the four core components of a Linux file system. |
|
Answer» Generally, file systems are referred to as the collections of files, which include information related to those files. It would be impossible to tell where one piece of data stops and the next begins without a file system. There are four blocks in a file system:
|
|
| 11. |
What is the shebang line in shell scripting? |
|
Answer» Shell scripts or programs often contain shebang at the top. In general, the Shebang (the SERIES of characters "#!") is used to indicate the operating system to use a particular interpreter to process the rest of the file. Here, the SYMBOL '#' is referred to as HASH, and "!" is referred to as bang. This usually aids developers in avoiding repetitive work. Scripts are generally executed by the engine; therefore, shebang DETERMINES the location of the engine that will be used to run the script. Example: #!/bin/bash In addition, this line also SPECIFIES which shell to use. |
|
| 12. |
What do you mean by GUI Scripting? |
|
Answer» The GUI (GRAPHICAL User Interface) is a client/server interface that uses graphical ICONS and VISUAL indicators to allow USERS to interact with devices. Specifically, it is used to control a COMPUTER and its applications. A wide variety of applications are supported, and it is largely dependent on the operating system. |
|
| 13. |
Write difference between Hard link and Soft Link. |
||||||||||||||
Answer»
|
|||||||||||||||
| 14. |
How to check whether a link is a hard one or a soft link? |
|
Answer» We can use -H and -L OPERATORS of the test command to check WHETHER a link is HARD or SOFT (symbolic link).
One can also use: readlink FILE; echo $? // This returns 1 if it's a hard link and 0 if it's a symbolic link. |
|
| 15. |
Explain ways to create shortcuts in Linux. |
|
Answer» Links PRESENT in LINUX OS can be used to create shortcuts as given below:
|
|
| 16. |
How many types of control instructions are available in a shell? |
|
Answer» Shells provide four types of control instructions as given below:
|
|
| 17. |
What are control instructions? |
|
Answer» Control instructions specify how the different instructions will be EXECUTED in the script. They are primarily used to DETERMINE the control flow in Shell programs. The execution of a shell script proceeds in succession WITHOUT these instructions. In shell programs, control instructions govern how execution flows. |
|
| 18. |
Explain the term positional parameters. |
|
Answer» In a shell program, positional parameters specify arguments that are used to launch the current process. A special set of variables is usually maintained by the shell for storing positional parameter values. BASH is an EXAMPLE of a shell that uses positional parameters. The bash shell can be used on Linux, BSD, macOS X, and Windows 10. For example: In this case, the command name is mycommand, and there are four parameters in the command line: one, five, and "six four”. Note: A space delimits each positional parameter and each thing after spaces are interpreted by the shell as individual parameters. Therefore, the parameter itself should be enclosed in quotation marks if it CONTAINS a space, as in "six four". |
|
| 19. |
What are different types of variables mostly used in shell scripting? |
|
Answer» Shell scripts usually have two types of variables:
|
|
| 20. |
What do you mean by Shell variable? |
|
Answer» Shell variables are integral parts of all Shell PROGRAMS and SCRIPTS. In general, we know that variables usually store data either in the form of characters or NUMBERS. Shell also STORES and manipulates information using variables in its programs. Generally, shell variables are stored as strings. Variables in the shell provide the information needed for scripts/commands to execute. In the following EXAMPLE, a shell variable is created and then printed: |
|
| 21. |
Write difference between Bourne Shell and C Shell. |
Answer»
Difference between Bourne shell and C shell
|
|
| 22. |
Name different types of shells available. |
Answer»
The Bourne-type is subdivided into the FOLLOWING categories:
The C-type is subdivided into the following categories:
|
|
| 23. |
Name the file in which shell programs are stored. |
|
Answer» A file CALLED sh stores shell PROGRAMS. Sh FILES contain commands written in a SCRIPTING language that is run by Unix SHELLS. |
|
| 24. |
Write some limitations of shell scripting. |
|
Answer» Shell scripting has the following disadvantages:
|
|
| 25. |
Write some advantages of shell scripting. |
|
Answer» Shell scripting offers the following benefits:
|
|
| 26. |
Why is a shell script needed? |
|
Answer» Shell SCRIPTS can be WRITTEN for a variety of reasons:
|
|
| 27. |
What is Shell? |
|
Answer» A Shell is basically a command-line interpreter between user and kernel or a complete ENVIRONMENT specially designed to run COMMANDS, shell scripts, and programs. In this, whenever a user enters human-readable commands (input commands) through the keyboard, the shell communicates with the kernel to execute these commands, and DISPLAY output in a shell script. Just as there are different flavors of operating systems, there are also different types of shells. Every shell has its own set of commands and functions. Shells ISSUE the prompt, $, called a command prompt. You can type into the prompt while it is displayed. After you press enter, your input is read by the shell. Based on the first word of your input, it determines the command you want to run. The characters in a word are separated using spaces and tabs. Example: Here is an example of a date command that displays the current date and time: $date Tue Aug 10 06:03:35 MST 2021 |
|