Bash Shortcuts

Bash provides several shortcuts and key combinations that can help you work more efficiently in the command line. Here are some commonly used Bash shortcuts:

  1. Moving the cursor:
  • Ctrl + A: Move the cursor to the beginning of the line.
  • Ctrl + E: Move the cursor to the end of the line.
  • Alt + F or Alt + →: Move the cursor forward one word.
  • Alt + B or Alt + ←: Move the cursor backward one word.
  1. Editing the command line:
  • Ctrl + U: Clear the line before the cursor.
  • Ctrl + K: Clear the line after the cursor.
  • Ctrl + W: Delete the word before the cursor.
  • Ctrl + Y: Paste the previously deleted text.
  • Ctrl + L: Clear the screen (similar to the clear command).
  • Ctrl + C: Cancel the currently running command.
  • Ctrl + D: Exit the current shell or end input (used when there is no text on the command line).
  • Ctrl + R: Search command history interactively.
  1. Command history:
  • Up Arrow or Ctrl + P: Move to the previous command in history.
  • Down Arrow or Ctrl + N: Move to the next command in history.
  • Ctrl + R: Search command history interactively.
  • Ctrl + G: Escape from the history search mode without executing a command.
  1. Tab completion:
  • Tab: Auto-complete a command, file, or directory name. Pressing Tab twice shows available options if there are multiple matches.
  1. Miscellaneous:
  • Ctrl + Z: Suspend the current foreground process (can be resumed with the fg command).
  • Ctrl + S: Stop the terminal output (can be resumed with Ctrl + Q).
  • Ctrl + Q: Resume terminal output (after it has been stopped with Ctrl + S).
  • Ctrl + \\: Send the QUIT signal to the current process (similar to pressing Ctrl + C, but more forceful).
  • Ctrl + H or Backspace: Delete the character before the cursor.

These are just a few of the many shortcuts available in Bash. You can find more shortcuts and customize them by modifying your Bash configuration file (~/.bashrc or ~/.bash_profile).

Leave a Comment

Your email address will not be published. Required fields are marked *