Skip to content

Instantly share code, notes, and snippets.

@mpouleijn
Created January 26, 2012 08:53
Show Gist options
  • Save mpouleijn/1681816 to your computer and use it in GitHub Desktop.
Save mpouleijn/1681816 to your computer and use it in GitHub Desktop.
Command line shortcuts

Input

Ctrl + a # Move the cursor to the beginning of the current line.
Ctrl + e # Move the cursor to the end of the current line.
Alt + b # Move the cursor to the beginning of the current or previous word.
Alt + f # Move the cursor to the end of the next word. Again, like with all shortcuts that use Alt as the modifier
Tab # Autocomplete commands and file names.
Ctrl + u # Erase the current line.
Ctrl + k # Delete the line from the position of the cursor to the end of the line.
Ctrl + w # Delete the word before the cursor.

Output

Shift + PageUp # Scroll terminal output up.
Shift + PageDown # Scroll terminal output down.
clear # The clear command clears all previously executed commands and their output from the current terminal.
Ctrl + l # Does exactly the same as typing the clear command.
reset # If you mess up your terminal, use the reset command. For example, if you try to cat a binary file, the terminal starts showing weird characters. Note that you may not be able to see the command when you're typing it.

History

history # When you type the history command, you'll see a list of the commands you executed previously.
ArrowUp or Ctrl + p # Scroll up in the history and edit the previously executed commands. To execute them, press Enter like you normally do.
ArrowDown or Ctrl + n # Scroll down in the history and edit the next commands.
Ctrl + r # Find the last command that contained the letters you're typing.

Misc

Ctrl + c # Kill the current process.
Ctrl + z # Send the current process to background. This is useful if you have a program running, and you need the terminal for awhile but don't want to exit the program completely. Then just send it to background with Ctrl+z, do whatever you want, and type the command fg to get the process back.
Ctrl + d # Log out from the current terminal. If you use this in a terminal emulator under X, this usually shuts down the terminal emulator after logging you out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment