Shell Scripting Interview Questions for DevOps
Linux is the open-source operating system that is known for its great security and command-line interface. Shell interview questions & answers are important to know as Shell is a scripting language used to work on the Linux operating system. In this article, we will discuss some of the great shell for Linux interview questions and answers that will help beginners, intermediates, and advanced shell users to land a perfect job. Shell is used in DevOps very often and is required to learn DevOps online. StarAgile provides DevOps online training that covers these topics in detail.
Top 5 Entry-level Shell Scripting Interview Questions for DevOps
1. What is the shell?
It is a command line interpreter and it translates every command entered by the user into the language understood by the Kernel. It is used to call a program or a function by the user in Linux by entering the command at the command-line interface.
2. What is GUI scripting?
GUI scripting is the Graphical User Interface scripting required to control the computer and applications. It is used for controlling different applications and is used on different operating systems.
3. What are the various types of variables used in shell scripting?
There are 2 types of variables used in shell scripting they are as follows,
a. System generated variables – As the name suggests these are the variables generated by the operating system. These variables are viewed by invoking the Set command.
b. User-defined variables – These are the variables that are created by the users, this can be viewed by invoking the echo command.
4. What are shell scripts? And mention any 2 advantages of the same?
The shell scripts are the command line text file which consists of commands in the order of execution. The typical executions are printing the file, invoking the program and file saving, modifying and writing, etc.
The 2 advantages of shell scripts are as follows,
a. It enables us to develop our custom operating systems with custom features in it to suit our needs.
b. It helps in developing software applications as per our needs and concerning specific platforms.
5. What is the difference between the break and continue commands?
- The break command lets us exit out of the current loop completely whether is while or until loops
- The continue command lets you skip 1 iteration of the loop but you will still stay inside the current loop.
Learn DevOps concepts, devops tools, and cultural aspects and also practice for an interview at the end of the course by taking up the DevOps online course at StarAgile.
Top 5 Intermediate shell scripting for DevOps interview questions
1. What are the commonly used shells in the Linux operating systems?
There 2 types are shells in Linux operating system those are C shell and Bourne shell.
The variants of these shells are as follows,
- C Shell – Z shell, C Shell and TENEX C shell
- Bourne shell – Korn shell, POSIX shell, Bourne shell, and Bourne-Again shell
2. How would you compare strings in shell scripts?
The test command is used to compare the text strings in shell scripts. The test command compares the text strings by comparing each character of the strings.
3. Why is C shell a more preferred option than Bourne shell?
The C shell is more preferred in the following cases than the Bourne shell,
- Long commands can be used again and again in C shell and cannot be done in Bourne shell.
- The commands can be aliased using the C shell and cannot be done in Bourne shell
- The history of the commands can be accessed in C shell which is not possible in the Bourne shell.
4. What are the default permissions of the file when it is created?
Any file created in Linux or UNIX has default permissions and to view the file permissions the unmask or user mask command is used for the newly created file. It is the 4 digit octal number used to set and expressed in symbolic values. The default permission of the newly created files is rw-rw-r that is 664.
The permissions are tabulated below,
|3||1+2||execute + write|
|5||1+4||execute + read|
|6||2+4||write + read|
|7||1+2+4||execute + write + read|
5. What is CRONTAB?
It is used to represent the CRON Table. As it uses the CRON schedule to execute the tasks. It is the list of the command used for executing the regular scheduler tasks. The scheduler is called CRONTAB.
Register for the DevOps training at StarAgile to undergo the DevOps course online and practice for the interview with a lot of Devops Interview questions and answers.
Top 5 DevOps shell scripting interview questions for experts
1. What are the 2 types of files using the Crontab command?
The 2 types of using the Crontab are as follows,
a. Cron.allow – This is used when you want to set permission to allow for the user to use the Crontab command
b. Cron.deny – This is used when you want to set permissions to deny the user to use the Crontab command
2. How to debug the problems encountered in the shell script and shell program?
- The first method is to put a debug command in the shell script program to output or display the error or bugs in the program
- The second method is to use a set –x to debug the script.
3. How would you know the disk usage using the shell script commands?
There are 3 different methods to check the disk usage using the shell script commands they are as follows,
a. dfspace command: - This is used in checking the free disk usage in terms of megabytes.
b. df command: - This is used to check the free disk space
c. du command: - This is used to check the directory wise disk usage
4. What are the different communication commands used in the shell?
The different communication commands used in the shell are as follows,
5. How many fields are present in a Crontab file and what are they?
The Crontab files have 6 fields, they are as follows,
The first 5 fields consist of fields on when to execute the commands and the 6th field is the command itself.
e. day of the week(0-6, Sunday = 0)
f. "specify the required command here"
We have discussed the top 15 shell interview questions and answers than may be asked in the DevOps interview on the shell. For the requirement of brevity, we have listed only some questions and answers which are important. However, more questions and answers will be discussed when you take up the DevOps certification course at StarAgile institute. StarAgile is an industry-recognized institute for the DevOps training online which can be taken at the comforts of home and office. We recommend you to enquire about the DevOps training at StarAgile institute and register for the various certification benefits.