Linux Terminal Tips and Tricks


Bash Shortcuts

  • clear current line no matter where the cursor is: ctrl+k+u
Ctrl+ a/eMove the cursor to the beginning/end of the current line
Ctrl + Lclear the terminal
Ctrl+ u/kRemove till the beginning/end
Ctrl + zSend the current process to background
Ctrl + dClose the bash shell By sending EOF signal
Ctrl + rSearch the history backwards
(some prefix) Alt + nSearch the history backwards non-incremental
up/downgo to previous/next command in history

Terminal Shortcuts

Alt+1(..9,0)Switch to tab 1.. 10
Shift+PageUp/DownGo up/down a whole page
Ctrl+Shift+Up/downGo up/down by line
Ctrl+,(or .)Switch to previous/next tab
Ctrl+<(or >)Move tab to left/right
F11Toggle full screen

Customize Shortcuts for GNOME Terminal

  • Go to edit -> Preferences -> Shortcuts
  • Ctrl+f to search
  • Ctrl+,/. to go to previous/next tab
  • Ctrl+Shift+,/. to move to previous/next tab
  • Ctrl+t/n to create new tab/window
  • Ctrl+w to close tab

Make Ctrl+C/V to copy and paste

  • By default, ctrl+c is mapped to interrupt a program, Ctrl+Shift+C/V to copy/paste data.
  • We can go to “Edit” -> “Keyboard Shortcuts…”, map Ctrl+C/V to copy/paste, the interrupt command will automatically be remapped to Ctrl + Shift + C.

Middle-click copy-paste

  • Select the text and middle click to copy it; then middle click to paste it. This works in all applications.
  • The clipboard buffer used for middle-click copy-paste is separate from the one used for Ctrl-C/Ctrl-V, which makes possible to have two different bits of text copied at the same time.
  • Useful in Terminal(as in terminal we can only paste at last line), but for other apps, it’s difficult to control where it pastes.

Show menubar again after accidentally unchecked View -> Show Menubar

  • Right click anywhere inside the Terminalthen select “Show Menubar”

Terminal Tips

  • User history | grep x | grep y to find command

Labels

adsense (5) Algorithm (69) Algorithm Series (35) Android (7) ANT (6) bat (8) Big Data (7) Blogger (14) Bugs (6) Cache (5) Chrome (19) Code Example (29) Code Quality (7) Coding Skills (5) Database (7) Debug (16) Design (5) Dev Tips (63) Eclipse (32) Git (5) Google (33) Guava (7) How to (9) Http Client (8) IDE (7) Interview (88) J2EE (13) J2SE (49) Java (186) JavaScript (27) JSON (7) Learning code (9) Lesson Learned (6) Linux (26) Lucene-Solr (112) Mac (10) Maven (8) Network (9) Nutch2 (18) Performance (9) PowerShell (11) Problem Solving (11) Programmer Skills (6) regex (5) Scala (6) Security (9) Soft Skills (38) Spring (22) System Design (11) Testing (7) Text Mining (14) Tips (17) Tools (24) Troubleshooting (29) UIMA (9) Web Development (19) Windows (21) xml (5)