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
Category: BASH
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
Understanding bash keyboard shortcutsÂ
Bourne-again shell (BASH) is one of highly used shell in Linux severs, typing long Linux commands and traversing it in can be a pain in back, if you are not comfortable with keyboard shortcuts. Lets discuss some of highly used shortcuts here that can help to ease working with bash shell: Ctrl + a : … Continue reading Understanding bash keyboard shortcutsÂ
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
Setting root password remotely of Linux Machines using Expect & Bash
This blog can help you with using expect script for basic usage and for fixing same issue as faced by me.
BASH – Comparison of decimal value with integer value
This code snippet and logic will be helpful when you have to compare a decimal and integer values.
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