Nuxified

FOSS technologies explained

  • Useful Articles
  • Blogs
  • Images
  • Tips
  • Archives

May 12, 2007

Ctrl-R in the Bash Shell

Recently I came across the command Ctrl-R in the bash shell. It allows you to search and browse your bash history.

For instance you ssh into your server every day, in between each ssh you do a bunch of other things, this makes in impractical to use the Up arrow key to go through your history to find the command. Instead hit Ctrl-R, and start typing ss, it will search your bash history for the last time you used a command with ss in it:

(reverse-i-search)`ss': ssh foo.servername.com

(reverse-i-search)`ss': ssh foo.servername.com

You hit ‘Enter’ and the line will be executed.

If you hit Ctrl-R again in will go back again in your history to the previous time you used a line with ss in it such as:

(reverse-i-search)`ss': vim /etc/ssh/sshd_config

(reverse-i-search)`ss': vim /etc/ssh/sshd_config

If you wish to change your search parameters just hit the backspace key and write your new search, e.g.
[backspace] [c]

(reverse-i-search)`sc': screen -r

(reverse-i-search)`sc': screen -r

I hope this helps people who’ve become annoyed with hitting the Up arrow all the time to get at yesterday’s command!

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Article by dylunio / Community Blogs

Learn Unix

I run Unix Tutorial website and help anyone interested to pick up Unix skills. If you have questions or just want to share your ideas – please join the Unix Tutorial on Facebook.

Tech Stack Solutions

Tech Stack Solutions is my company that provides Unix support. Sign up or simply get in touch to find out how I can help!

Search this Website

You May Also Like

Recent Posts

  • Advice on using SUDO
  • FFmpeg 4.0
  • KDE Plasma 5.9.0 Release
  • How to Install Ubuntu Linux without a DVD or USB
  • How to Securely Save All Your Passwords with Keepass
  • 9 Signs You Should Use Linux on Your Computer
  • The Easiest Way to Optimize Your MySQL Database Performance
  • Setting up a Linux Web Development Environment in Windows
  • Hunting Down Disk Space Hogs on Linux Command Line
  • 6 Simple Android Apps for Monitoring and Managing Your Linux Server

Archives

Categories

  • Community Blogs
  • Images and Screenshots
  • News
  • Technical Topics
  • Useful Articles

Basic Unix Commands

Basic Unix Commands
  • ls command
  • mkdir command
  • man command in unix
  • cd command - change directory
  • uname command

Advanced Unix Commands

Advanced Unix Commands
  • ln command - symlinks
  • tune2fs unix command - filesystem parameters
  • du command - disk usage
  • lsb_release command
  • find unix command

Unix Reference

Unix Reference
  • SSH port forwarding
  • unix commands
  • visudo tutorial
  • mtime unix
  • lrwxrwxrwx
  • Unix Tutorial digest

Unix Books

Unix Tutorials

Unix How-Tos
  • check raspbian version
  • autostart in KVM
  • List files in Ubuntu package
  • check CentOS version
  • create bootable USB in MacOS
  • Useful Articles
  • Blogs
  • Images
  • Tips
  • Archives

Copyright © 2021 · Education Pro Theme on Genesis Framework · WordPress · Log in