Terminal 101: Keyboard Shortcuts

Every Monday, we’ll show you how to do something new and simple with Apple’s built-in command line application. You don’t need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type ’em out!

Dealing with text in the command line can be a bit overwhelming for some — and typing text into the command line interface can be the source of time wasted, if you mistype the command. Fortunately, there are some time-saving keyboard shortcuts that are built into the command line to help you navigate around and edit text more efficiently. We’ll show you how to use all of these keyboard shortcuts in this week’s Terminal 101.

Moving the Cursor

When you’re at the command line, and entering a command, moving the cursor around with the forward and back arrows on your keyboard can be a huge time-waster. Fortunately, you can easily jump around on a single line with a few simple keyboard shortcuts.

Control + A

Use Control + A to jump to the beginning of the line of text. After using this keyboard shortcut, your cursor will be placed at the beginning of the typed command.

Control + E

Use Control + E to jump to the end of the line of text. After using this keyboard shortcut, your cursor will be placed at the end of the typed command.

Control + F

Use Control + F to move forward by one character in the line of text. This has the same result as using the forward arrow key on your keyboard.

Control + B

Use Control + B to move back by one character in the line of text. This has the same effect as using the back arrow key on your keyboard.

Editing Command Text

Removing and otherwise editing text already typed into the command line can be a bit of a hassle, especially if you only use the delete key. Here’s some shortcuts that are sure to improve your text editing abilities.

Control + D

Use Control + D to delete the character at your cursor location. Using this keyboard shortcut, the character that is currently selected by the cursor will be removed.

Control + T

Use Control + T to exchange the character to the left cursor location with the one at the cursor location. After using this shortcut, the cursor will be advanced by one position.

Control + K or Control + U

Use Control + K to “kill” (or remove) the text from the cursor’s location to the end of the line; alternatively, you can “kill” (or remove) the entire line by using Control + U.

Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article’s author on Twitter.