An umount command is used to unmount a device/partition by specifying the path to the directory where it has been mounted. Sometimes, when you run the umount command you may receive the “target is busy” or “device is busy” errors indicating that there is some process that is using the mounted filesystem or the remote […]
bash
Git Bash: Clear History
The history -cw command is used to clear a Bash history on Linux, but for some reason it doesn’t work for a Git Bash on Windows. If you try to clear the commands history in the Git Bash using this command, it won’t work – you will still see the history of the executed commands […]
Linux: Repeat Command N Times – Bash FOR Loop
Sometimes you might need to run some command from the Linux command line and repeat it several times. There is a simple way to write a command once and have it executed N times using Bash loop FOR. In this short note you’ll find how to execute some command a number of times in a […]
Mass Emails Sending From Bash Script in Linux
To prevent abuse and don’t allow to send bulk emails through SMTP server, it is recommended to restrict the number of messages that each user can send. Let’s say we have limited the number of messages to send, but how can we check that the limitation works? The best way to make such check is […]
Bash: String Length – How To Find Out
If you often create Bash scripts, you may sometimes need to get the length of a string or find out the length of a variable that stores some string. This short note shows how to find out the length of a string from the Linux command line and how to count the length of the […]
“Yes/No” in Bash Script – Prompt for Confirmation
Very often in bash scrips you need to ask for user input that requires a Yes or No answer. For example, you may want to put a quick “Are you sure?” prompt for confirmation before execution of some potentially dangerous part of a bash script. In this article you’ll find three easiest and fastest ways […]
CASE Statement in Bash [Example]
The following article describes the basic syntax and includes a simple example of the BASH CASE statement usage. The CASE statement is the simplest form of the IF-THEN-ELSE statement in BASH. You may use the CASE statement if you need the IF-THEN-ELSE statement with many ELIF elements. With the BASH CASE statement you take some […]
Print Usage and Exit if Arguments are Not Provided
Use the following test in your shell scripts to: 1. verify the number of input values 2. display an error message if the number of input argument is not correct 3. exit a shell script with the error status [ $# -eq 0 ] && { echo “Usage: $0 argument”; exit 1; } Parameter Description […]
7 Tips – Tuning Command Line History in Bash
7 Tips that can help you to improve you Bash history file. You will learn how to add date and time to bash history file, increase history size, ignore specific commands and much more … Every command that you enter, is stored in the file ~/.bash_history. Run history to see your last commands. You can […]
HowTo: Clear BASH History
Sometimes you don’t want to leave Bash history, because it may contain some sensitive data (e.g. passwords, tokens, etc.). This article will help you to take a full control on your .bash_history file. I will show how to clear the commands history for the current Bash session, how to prevent particular commands from being recorded […]