Skip to content

Instantly share code, notes, and snippets.

@gordinmitya
Created February 28, 2025 06:25
Show Gist options
  • Save gordinmitya/2cfe0fe9d2d9b9e442aeccbf09f89ca8 to your computer and use it in GitHub Desktop.
Save gordinmitya/2cfe0fe9d2d9b9e442aeccbf09f89ca8 to your computer and use it in GitHub Desktop.

Cursor Movement

  • Ctrl+A - Move the cursor to the beginning of the line.
  • Ctrl+E - Move the cursor to the end of the line.
  • Ctrl+B - Move the cursor backward one character (left).
  • Ctrl+F - Move the cursor forward one character (right).
  • Alt+B - Move the cursor backward one word.
  • Alt+F - Move the cursor forward one word.

Editing Text

  • Ctrl+U - Cut (delete) everything from the cursor to the beginning of the line.
  • Ctrl+K - Cut (delete) everything from the cursor to the end of the line.
  • Ctrl+W - Cut (delete) the word before the cursor.
  • Ctrl+Y - Paste (yank) the last thing you cut (works with Ctrl+U, Ctrl+K, or Ctrl+W).
  • Ctrl+D - Delete the character under the cursor.
  • Ctrl+T - Swap (transpose) the character under the cursor with the one before it.

Command History

  • Ctrl+P - Scroll up through your command history (same as the up arrow).
  • Ctrl+N - Scroll down through your command history (same as the down arrow).
  • Ctrl+R - Search your command history interactively. Type a few letters, and it’ll show matching commands. Press Ctrl+R again to cycle through matches, or Enter to run the selected command.
  • Alt+. - Insert the last argument from the previous command (e.g., if you ran ls dir_name, this pastes dir_name).

Process Control

  • Ctrl+C - Terminate (kill) the currently running command.
  • Ctrl+Z - Suspend the currently running command (put it in the background). Use fg to bring it back or bg to let it run in the background.
  • Ctrl+D - Exit the terminal or shell session (when the line is empty; otherwise, it deletes a character).

Miscellaneous

  • Ctrl+L - Clear the screen (same as typing clear, but faster).
  • Tab - Auto-complete commands, filenames, or paths. Double-tap Tab to see all possible completions if ambiguous.
  • Ctrl+_ - Undo the last edit you made to the command line (handy if you accidentally delete something).

Bonus Tips

  • Combine these! For example, Ctrl+A then Ctrl+K deletes the entire line quickly.
  • If you mess up a command, Ctrl+U clears it from the cursor back, letting you start over.
  • Use Ctrl+R for history searches—it’s a game-changer when you can’t remember a long command you ran earlier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment