UNIX Shell Scripting Interview Questions, Answers, and Explanations: UNIX Shell Certification Review
By Equity Press
4.5/5
()
About this ebook
The Ultimate Reference & Learning Guide for the advanced UNIX Operator
Fluency with a UNIX Shell is mandatory for working within the UNIX operating system. Keeping current, however, can be a challenge. With the UNIX Shell Scripting Interview Guide, you will be sure to be current. Using this book to prepare for a job interview or brush up on a scripting programming language will aid any programmer in acquiring new and applicable skills and knowledge. This book contains a complete reference of common scripting errors, performance tuning examples, and common applications. More than just UNIX documentation and open source rhetoric, this guide explains UNIX Shell Scripting from the perspective of the advanced programmer and administrator so you can be sure to come to any interview prepared.
Key topics include:
Graphical user interfaces for UNIX
Advanced features of Bash, Bourne, and Korn
Common errors and troubleshooting
System monitoring and maintenance
Modern command line shells
Read more from Equity Press
65 Interview Questions: Conquer Your Fear and Answer the Toughest Job Interview Questions Rating: 4 out of 5 stars4/5Oracle® Financials Interview Questions: Unofficial Oracle Financials Certification Review Rating: 3 out of 5 stars3/5TCP/IP Networking Interview Questions, Answers, and Explanations: TCP/IP Network Certification Review Rating: 5 out of 5 stars5/5SAP Basis Configuration Frequently Asked Questions Rating: 4 out of 5 stars4/5SAP ECC FI Transaction Codes: Unofficial Certification and Review Guide Rating: 5 out of 5 stars5/5Cisco Network Administration Interview Questions: CISCO CCNA Certification Review Rating: 5 out of 5 stars5/5SAP R/3 Transaction Codes Unofficial Certification and Review Guide Rating: 4 out of 5 stars4/5SAP ABAP Objects Interview Questions Rating: 4 out of 5 stars4/5SAP FICO Company Creation Rating: 4 out of 5 stars4/5SAPCOOKBOOK Training Tutorials: SAP MM Inventory Management Rating: 4 out of 5 stars4/5Oracle Ultimate DBA Interview Questions Rating: 5 out of 5 stars5/5SAP Solution Manager Rating: 4 out of 5 stars4/5C# Interview Questions, Answers, and Explanations: C Sharp Certification Review Rating: 5 out of 5 stars5/5SAP APO Interview Questions, Answers, and Explanations: SAP APO Certification Review Rating: 2 out of 5 stars2/5Python Interview Questions Rating: 5 out of 5 stars5/5SAP Security Interview Questions, Answers, and Explanations Rating: 4 out of 5 stars4/5SAP IS-Retail Interview Questions, Answers, and Explanations Rating: 3 out of 5 stars3/5SAP MDM Frequently Asked Questions Rating: 5 out of 5 stars5/5The Programmer’s Guide to Microsoft Access Rating: 5 out of 5 stars5/5COBOL Programming Interview Questions: COBOL Job Interview Preparation Rating: 5 out of 5 stars5/5Breaking In to SAP HR: Interview Questions, Answers and Explanations Rating: 4 out of 5 stars4/5Linux Interview Questions: Open Source Operating Systems Interview Questions, Answers, and Explanations Rating: 5 out of 5 stars5/5SAPCOOKBOOK Training Tutorials SAP Financials: Accounts Receivable Rating: 4 out of 5 stars4/5Unofficial SAP WebDynpro for ABAP Rating: 5 out of 5 stars5/5Oracle Database Security Interview Questions, Answers, and Explanations: Oracle Database Security Certification Review Rating: 0 out of 5 stars0 ratings
Related to UNIX Shell Scripting Interview Questions, Answers, and Explanations
Related ebooks
Oracle Database A Complete Guide - 2021 Edition Rating: 0 out of 5 stars0 ratingsDatabase Design and SQL for DB2 Rating: 5 out of 5 stars5/5Interview Questions for IBM Mainframe Developers Rating: 1 out of 5 stars1/5Java for RPG Programmers: 3rd edition Rating: 4 out of 5 stars4/5Mastering Linux System Administration Rating: 0 out of 5 stars0 ratingsLinux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Linux Bible Rating: 0 out of 5 stars0 ratingsLearning CoreOS Rating: 0 out of 5 stars0 ratingsOracle SQL and PL/SQL Rating: 5 out of 5 stars5/5Linux System Administrator Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsDistributed Algorithms Rating: 3 out of 5 stars3/5CUPS Administrative Guide Rating: 0 out of 5 stars0 ratingsIBM MQ A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsWindows PowerShell for .NET Developers - Second Edition Rating: 4 out of 5 stars4/5DB2 9 for Developers Rating: 0 out of 5 stars0 ratingsUnderstanding TCP/IP Rating: 4 out of 5 stars4/5COBOL Basic Training Using VSAM, IMS and DB2 Rating: 5 out of 5 stars5/5Bash for Fun: Bash Programming: Principles and Examples Rating: 0 out of 5 stars0 ratingsScala in Depth Rating: 4 out of 5 stars4/5Ubuntu Linux Bible Rating: 0 out of 5 stars0 ratingsLPIC-1 Primer Rating: 4 out of 5 stars4/5Mvs Jcl in Plain English Rating: 5 out of 5 stars5/5Learning PostgreSQL Rating: 1 out of 5 stars1/5Linux Commands By Example Rating: 5 out of 5 stars5/5The Linux Command Line Beginner's Guide Rating: 4 out of 5 stars4/5PostgreSQL 11 Administration Cookbook: Over 175 recipes for database administrators to manage enterprise databases Rating: 0 out of 5 stars0 ratingsLinux for Beginners: Linux Command Line, Linux Programming and Linux Operating System Rating: 4 out of 5 stars4/5Mastering Windows PowerShell Scripting Rating: 4 out of 5 stars4/5A Beginners Guide to Linux Rating: 0 out of 5 stars0 ratings
Reviews for UNIX Shell Scripting Interview Questions, Answers, and Explanations
4 ratings1 review
- Rating: 5 out of 5 stars5/5very well explained
Book preview
UNIX Shell Scripting Interview Questions, Answers, and Explanations - Equity Press
BASIC QUESTIONS AND ANSWERS:
Questions most likely to be asked by beginners
Question 01: Shell Script
What is shell script anyway?
A: A shell script, in its most basic form, is simply a collection of operating system commands put into a text file in the order they are needed for execution. Using any of the shells mentioned so far, a text file containing the commands listed in example basic shell script would work every time the script was executed.
Example basic shell script:
#!/bin/sh
rm -f /tmp/listing.tmp> /dev/null 2>&1
touch /tmp/listing.tmp
ls -l [a-z]*.doc | sort> /tmp/listing.tmp
lpr -Ppostscript_1 /tmp/listing.tmp
rm -f /tmp/listing.tmp
Of course, not all scripts are this simple but it does show that ordinary UNIX commands can be used without any extra, fancy scripting constructs. If this script was executed any number of times the result would be the same, a long listing of all the files starting with lower case letters and ending with a doc extension from the current directory printed out on your local PostScript printer. Let’s start to look at this in detail starting at the beginning.
In the Beginning:
The first line of any script should always look a bit like the top line in the example basic shell script; the only difference would be the path leading to the shell executable file, in this case the /bin/sh part. By default, the UNIX system will attempt to execute an ASCII text file
if the files name is supplied as the first argument on the command line. UNIX will attempt to execute the file in the current shell and try to process the included command strings within the file using the syntax rules of the current shell. So, if you are using the Bourne Shell as your default environment and the ASCII file contains a list of UNIX command structures formatted how the Bourne Shell likes them to be formatted, all will work fine. However, if you try and execute a C Shell file with a different syntax structure, the Operating System will complain about unrecognized commands and syntax errors. The reason is no one told the Operating System that it was a C Shell file, so it processed it as a Bourne Shell. The correct way to indicate this to the Operating System is to pass the script name to the shell executable as an argument thus:
user@system$ /bin/csh my_script arg_1 arg_2
However, it didn't take long for someone to notice that this was extra typing that could well be done away with and hence the short hand first line comment was born.
Basically, all comments in shell scripts start with a hash sign (#). However, for the first line only, UNIX reads past the hash to see what's next. If it finds an exclamation point (!), or Bang! as it's known, then what follows is taken as the path to the shell executable binary program. Not only can that, but all the command line arguments that the shell executable allows also be stacked up on this line. With this feature it doesn't matter what flavor of shell your environment is, you can execute a script in any other flavor of shell, as if it was a real UNIX command. Let’s look at the Bourne Shell syntax rules more closely. It would be helpful at this point to print out the sh man pages from your system so that you can compare them with what I have here.
Question 02: Invoking Shell Scripts
How do you invoke shell scripts?
A: There are two ways to invoke a shell script file.
1. Direct Interpretation:
In direct interpretation, the command csh filename [arg ...] invokes the program csh to interpret the script contained in the file filename.
2. Indirect Interpretation:
In indirect interpretation, we must insert as the first line of the file:
#! /bin/csh
or
#! /bin/csh -f
There are situations in which this is not necessary, but it won't hurt to have it and the file must be made executable using chmod. Then it can be invoked in the same way as any other command, i.e., by typing the script file name on the command line.
The -f option says that we want fast startup, which it will achieve by not reading or executing the commands in .cshrc. Thus for example, we won't have the set
values for shell variables or the aliases from that file, but if we don't need them, this will be much faster (if we need a few of them, we can simply add them to the script file