Quick Links

I’ve lost count of how many times I’ve needed to reuse a command, only to find that it’s no longer in my Bash history. If you’re anything like me, you know how frustrating that can be. But the default history settings only store a limited number of commands, meaning important ones might disappear when you need them most.

Why I Use Unlimited Bash History

If you’ve ever scrolled through your command history to find one complex command from weeks ago, you know how useful Bash history can be. But out of the box, most systems only store around 500 to 1,000 commands. That might sound like a lot, but if you’re using Bash heavily—like I do when I’m setting up environments or automating tasks—you’ll run out fast.

Unlimited history ensures that every command I type is stored and easily searched. Whether I need to troubleshoot, revisit a long command, or avoid typing the same thing twice, it’s all there at my fingertips. I’ve found it especially useful when switching between machines or virtual environments, where reusing commands is part of my daily workflow.

How I Set Up Unlimited Bash History

Here’s how I set it up on my own systems, and you can do the same:

Remove Ads

Before making any changes, ensure you make a backup of the file.

Open Your Bash Configuration File

You’ll need to tweak either your ~/.bashrc or ~/.bash_profile file. I usually stick with .bashrc since it runs every time I open a terminal. You can open it with nano:

nano ~/.bashrc 

Modify the History Size Variables

Modify these lines in the configuration file:

  • HISTSIZE=-1
  • HISTFILESIZE=-1

This removes the cap on how many commands can be saved in your history.

Enable History Appending

One thing I’ve learned is that without enabling history appending, commands from different sessions might get overwritten. To avoid this, add the following line if not already included.

shopt -s histappend 
Editing the history size in the bashrc file.
Remove Ads

Reload Your Configuration

After making these changes, apply them with:

source ~/.bashrc 

Why Unlimited Bash History Might Not Work for Everyone

As much as I like having unlimited history, I understand that it’s not the right choice for everyone. Here are some situations where it might be overkill—or even risky:

  • Privacy Issues: If you’re working on sensitive systems or sharing your machine, storing every command indefinitely could expose confidential information. For example, commands with passwords or tokens can end up in the history, and that’s not something you want lying around.
  • System Overhead: If you type many commands, your history file can get bloated, which may slow down history searches. I haven’t encountered this often, but it’s something to remember.
  • Cluttered History: Sometimes, having too much history can make it harder to find what you need. If you type the same command multiple times a day, your history can fill up quickly and become unwieldy.

If these concerns apply to you, you might want to increase your history size without going fully unlimited.

Remove Ads

My Tips for Managing Long Bash History

To keep my history clean and relevant, I use HISTCONTROL=ignoreboth setting in my .bashrc. This setting ensures:

  • Duplicate commands aren’t saved in history.
  • Commands starting with a space aren’t logged, which is helpful if I need to run something temporarily or keep certain commands from being stored (e.g., sensitive commands).

Here’s what it looks like in the file:

HISTCONTROL=ignoreboth

This combination offers more control, keeping my history neat and hiding commands when necessary.

The HISTCONTROL=ignoreboth command in bashrc.

Quickly Search Commands with Ctrl+R

One of my favorite shortcuts is Ctrl+R. It lets you search backward through your history by typing part of a command. It saves a ton of time when you’re trying to recall something specific.

Remove Ads
Using CTRL+R to search history in Linux.

Use Aliases for Repetitive Commands (But Watch for Spaces)

Aliases are great for shortening long commands, but be careful when setting them up—spaces can cause errors if not handled correctly. Make sure there are no spaces around the = sign when you create one.


Setting up unlimited Bash history has been a game-changer for me. It’s made my workflow smoother and saved me from retyping or forgetting important commands. But it’s not for everyone—if you’re concerned about privacy, system performance, or clutter, increasing your history size without going fully unlimited might be a better option.

If you want to streamline your workflow and keep every command at your fingertips, though, unlimited Bash history is worth a try. Just remember to keep things manageable with aliases and duplicate filtering so your history stays useful rather than overwhelming.

Remove Ads