Member-only story

Bash bang commands: A must-know trick for the Linux command line

Rakan Khaled
3 min readAug 29, 2024
Photo by Moritz Mentges on Unsplash

Have you ever forget to issue sudo before a command?

Have you ever had to repeat a whole command because you had a typo?

Have you ever thought it would be nice to have shortcuts to repeat your previous commands?

If this sounds like you, I have something to share that will knock your socks off!!!

In this article, I will show you how to use bash bang (!) commands, which make it easy to repeat commands and fix errors. grab a cup of coffee and lets get into it!

Command repeat basics

Bash provides access to the list of commands you previously issued, which is known as your command history. The value of the HISTSIZE variable sets the number of commands that are saved in your history list. By default, this value is 500. These previously issued commands (known as your history list) are stored in your history file. Its default location is ~/.bash_history, and this location is stored in the shell variable HISTFILE.

Under the hood, bang (!) commands introduce commands from your bash history list into the input…

--

--

Rakan Khaled
Rakan Khaled

No responses yet