Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Tuesday, October 1, 2013

Important keyboard shortcuts in Linux Shell(BASH)

Following keyboard shortcuts are very useful while working in Bash

  1. Ctrl +u Cut the current line
  2. Ctrl+y Paste the line which has been earlier with Ctrl +u
  3. Ctrl +l clear the screen
  4. Ctrl+G get the new line and abandon the current line
  5. Ctrl+a go to beginning of the line
  6. Ctrl+e go to End of line
  7. Ctrl+k Erase from the cursor to the end of line
  8. Ctrl +r search in the history
  9. Ctrl+w cuts a word backwards
  10. Ctrl+d  Tired of typing 'exit' to close a terminal? Just hit ctrl+d on a blank line and boom!
  11. Ctrl+right - Jump one word to the right.
  12. Ctrl+left - Jump one word to the left.
  13. ALT+DEL Delete word(s) to the left of the cursor
  14. !! Repeat last command 
There are some situation when i want to read the log as well redirect it to some file for later view. 
some_command | tee output.txt 
if you want to redirect both STDERR(2) and STDOUT(1) to the same thing then we can use 2 >&1
some_command >big_blob_of_crap.txt 2>&1
The output of the ‘come_command’ is redirected to a ‘big_blob_of_crap.txt’ and the error channel (that is the ’2′ is redirected to a pointer (?) of the output (‘&1′).
So stderr goes to the stdout and that goes to the file.
some_command &>big_blob_of_crap.txt
If you want to redirect STDERR and STDOUT to a single file and at the same time, you want to view them on the screen then we can use use
some_command |tee big_blob_of_crap.txt 2>&1