Top BASH interview Question & Answers

Hello Techies, Sharing some important interview questions related to Bash shell. Feel free to add your feedback regarding quality and do let us know if in case you feel any solution incorrect. Bookmark this page as we will be continue adding different questions here 🙂 If you have any question in mind, whose solution you … Continue reading Top BASH interview Question & Answers

Bash: Writing your first script

Script code for reference: KERNEL COUNT # Checking how many kernels installed in my system ## kernelcount=`rpm -q kernel | wc -l` echo "We have total $kernelcount kernels installed in this system" USER CREATION # Creating a custom user # echo "Provide the username which you want to create: " ; read customusername grep $customusername … Continue reading Bash: Writing your first script

Bash – Building your own “top” command

Top "top" is versatile monitoring tool, providing run time summary view of many stats (CPU/Memory/Swap/Process/Load average etc), so admins prefer it a lot while troubleshooting several issues. It is provided by procps-ng-3.3.10-23.el7.x86_64 package, so you can install it as that well, if you feel missing, usually it is shipped by default in Fedora variant *nix … Continue reading Bash – Building your own “top” command

Linux : Fixing mailx command stucking in bash script

Today one colleague of mine, showed me a script of his own which was intended to email some monthly reports to his email address. Issue: The script was stucking, and thus we have to terminate the script. Resolution: Let's see a basic version of script to reproduce that issue. #!/bin/bash echo "Script completed successfully, please … Continue reading Linux : Fixing mailx command stucking in bash script

BASH – Construct to convert seconds to human readable time

Basic contruct to be used here : It's helpful, when you are trying to convert your system time into human readable seconds1. Calculate how many seconds are there in unit of your choice , and divide remaining value or original value by those seconds. 2. Now to handle decimal part , multiply your above output … Continue reading BASH – Construct to convert seconds to human readable time

BASH – Understanding case / esac Statement

INTRODUCTION The case construct is the shell scripting analog to switch in C/C++. The case command compares the variable specified against the different patterns. If the variable matches the pattern, the shell executes the commands specified for the pattern. The asterisk symbol is the catch-all for values that don’t match any of the listed patterns. … Continue reading BASH – Understanding case / esac Statement

BASH – Comparison of decimal value with integer value

Let's discuss how shell script behaves when we try to compare a numeric decimal value against integer. Decimal value : Server load statistics, which need not to be integer value [root@test tmp]# uptime 03:40:21 up 1 day, 20:17,  3 users,  load average: 2.82, 1.06, 0.39 [root@test tmp]# Integer value : Processor count [root@test ]# grep … Continue reading BASH – Comparison of decimal value with integer value