Skip to content

Instantly share code, notes, and snippets.

@cdcarson
Created July 4, 2013 17:12
Show Gist options
  • Save cdcarson/5929167 to your computer and use it in GitHub Desktop.
Save cdcarson/5929167 to your computer and use it in GitHub Desktop.
List of Terminal shortcuts
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W Delete the word before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor
@spikegrobstein
Copy link

Oh, also, ctrl-D... that works by sending the EOF character which signifies end of input. This is useful not only for when you're in a shell, but for anything that's waiting on input, be it an interactive database session (mysql or psql), or a cat command. It's friendlier than a ctrl-C since that sends an interrupt signal.

An example of the cat thing above:

cat > some_file

you can then type some stuff in, press enter, type more, press enter... type some more, press enter... seems like it's doing nothing... type a ctrl-D and you're brought back to your prompt. Now look at the contents of some_file and it'll contain everything you just typed. If you ctrl-C, it'll do the same, but only because that's how the cat command is written (it outputs data each time it gets a line), but if it were to buffer everything and only write once input is completed, ctrl-C would completely terminate the action and nothing would occur. When you pipe the output of a command into another, when the first command finishes, it sends the EOF to signal the next process that it's done. ctrl-D is a way for you, the operator, to do this manually.

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