Skip to content

Linux Shell Line Editing Shortcuts

Common terminal line editing shortcuts for Bash and other readline-style shells. These shortcuts help edit long commands without reaching for the mouse or repeatedly pressing Backspace.

Use these shortcuts while typing or editing a command in the terminal.

Action Shortcut
Delete previous word Ctrl + W
Delete next word Alt + D
Delete from cursor to start of line Ctrl + U
Delete from cursor to end of line Ctrl + K
Undo last edit Ctrl + _ or Ctrl + X then Ctrl + U

Given this command:

Terminal window
python manage.py runserver --settings config.local
  • If the cursor is after local, pressing Ctrl + W deletes config.local.
  • Pressing Ctrl + W again deletes –settings.

Ctrl + W deletes based on shell/readline word boundaries. Paths and punctuation can behave differently depending on terminal and readline settings.

Terminal window
cd /home/user/projects/myapp

In a path like this, Ctrl + W may delete the whole path or delete chunks of it depending on the active shell/readline behavior.

Use these shortcuts to move through long commands quickly.

Action Shortcut
Move back one word Alt + B
Move forward one word Alt + F
Delete previous word Ctrl + W
Delete next word Alt + D
  • On compact keyboards, Alt may also be treated as Meta.
  • In most terminals, normal Alt + B, Alt + F, and Alt + D work directly.