← Back to list

A Handful of Terminal Habits That Quietly Save You Hours Over a Year

Repeat your last command without retyping it

Sabit in Bash & DevOps & Life Lessons · 2026-06-17 12:19 · 0 claps · 3.8 min read paywalled
#devops #linux #terminal #programming #coding
Open on Medium ↗
Wiki topics: PSY · Psychology 💻 · Programming ☁️ · DevOps & Cloud 🔧 · Data Engineering 🔓 · Open Source 🚀 · Self Improvement 🥊 · Combat Sports

A Handful of Terminal Habits That Quietly Save You Hours Over a Year

Repeat your last command without retyping it

Photo by Carl Heyerdahl on Unsplash

Photo by Carl Heyerdahl on Unsplash

There’s a particular kind of annoyance that happens when you’re working in the terminal.

You run a command, it fails because you forgot to add sudo in front of it, and now you have to type the whole thing again.

Or you ran something five minutes ago, it worked, and now you need to run it again but you've already forgotten the exact wording.

Most people just retype it. Every time. They do this for years.

There’s a faster way. It’s been sitting in your terminal the entire time. You don’t need any new software. You just need to know a few keys and commands that almost nobody shows you when you’re starting out.

Just press the up arrow

This is the simplest one and somehow still the most underused. Your terminal remembers everything you’ve typed in that session. Press the up arrow once and your last command reappears, ready to run again by hitting enter.

Press it twice and you go back two commands. Keep pressing and you scroll backward through your entire session, one command at a time. If you go too far, the down arrow brings you back the other way.

This alone fixes the most common annoyance. That is rerunning the same command after fixing a typo or adding a missing flag. Instead of retyping anything, you press up, edit the one part that was wrong, and hit enter.

Repeat the exact last command with two characters

If you just want to run your last command again, with zero changes, there’s a shortcut for that too.

!!

Typing two exclamation marks and pressing enter reruns whatever you just ran. This is especially handy for the classic mistake of forgetting sudo. Instead of retyping the whole command with sudo stuck on the front, you can do this.

For example, you typed a command (particularly a long one) and you forgot to add sudo, just do the below:

sudo !!

That takes your last command, drops sudo in front of it, and runs it again. It feels like a small thing, but once it becomes a habit you'll notice how often you reach for it.

Search through everything you’ve ever typed

This is the one that tends to surprise people the first time they see it work.

Your terminal keeps a running history of commands. Sometimes going back months. You can search through all of it without scrolling at all. Press these two keys together.

Ctrl + R

A prompt appears asking you to search. Start typing any part of a command you remember, even just a fragment, and it instantly jumps to the most recent matching command in your history.

Keep pressing Ctrl + R to cycle backward through older matches if the first one isn’t the one you wanted. When you find the right one, press enter to run it. Or press the right arrow key to drop it into your prompt for editing first.

So, if you ran some long, complicated command involving ffmpeg three weeks ago to convert a video, and you don't remember the exact syntax, you don't need to look it up again. You just press Ctrl + R, type "ffmpeg," and it surfaces the exact command you used, flags and all.

See your whole history at once

Sometimes you don’t want to search. You just want to scroll through everything you’ve done recently and pick something out visually. That’s what this command is for.

history

This prints a numbered list of every command you’ve run, often going back hundreds of entries. Here’s where it gets interesting and super useful.

If the list is long, you can pipe it through grep to filter it down to just what you're looking for.

history | grep git

This shows you only the commands in your history that contain the word “git,” which is useful when you know roughly what you were doing but not the exact command.

You can also rerun a specific command from that numbered list directly without retyping it, just by referencing its number.

!482

That reruns whatever command was numbered 482 in your history list. It feels a little like time travel the first time you use it.

Make your history actually worth searching

By default, some systems only keep a modest number of past commands. And certain setups quietly skip saving a command if it’s identical to the one before it. If you want your history to be a useful archive going back months, you can increase how much it stores.

This usually involves adding a couple of lines to your shell’s configuration file, often called .bashrc or .zshrc depending on what shell you're using.

HISTSIZE=10000
HISTFILESIZE=20000

Save the file, restart your terminal, and from that point on your history holds onto far more than it used to.

Why this is worth the five minutes it takes to learn

None of this requires installing anything or learning to code. It’s just remembering that your terminal already keeps a detailed record of everything you’ve done. And that record is searchable in seconds if you know where to look.

Once Ctrl + R becomes a reflex, you’ll notice yourself reaching for it constantly, especially for those long commands you only use occasionally and never quite memorize. Instead of digging through old notes or rebuilding a command from scratch, you just search for a fragment of it and let your own history hand it back to you.

It’s a small change. But it’s the kind that quietly removes a little bit of friction from your day, every single day.


메타데이터
post_id
4ca1834e8238
slug
a-handful-of-terminal-habits-that-quietly-save-you-hours-over-a-year-4ca1834e8238
url
https://medium.com/my-lifes-mirrow/a-handful-of-terminal-habits-that-quietly-save-you-hours-over-a-year-4ca1834e8238
canonical_url
https://medium.com/my-lifes-mirrow/a-handful-of-terminal-habits-that-quietly-save-you-hours-over-a-year-4ca1834e8238
author_url
https://medium.com/@tibas
status
ok
fetched_at
2026-06-20 20:29:01