Tuesday, July 30, 2013

Vi Editor basic user guide

vi is a screen-oriented text editor originally created for the Unix operating system.
Here are the few basic and necessary shortcuts to use vi editor effectively-
  • '0'(zero) -move cursor to start of current line
  • ':n' -move cursor to line n
  • ':$' -move cursor to last line in file
  • 'x' -delete single character under cursor
  • 'dd' -delete entire current line
  • 'dw' -delete the single word beginning with character under cursor
  • 'yy' -copy (yank, cut) the current line into the buffer
  • 'Nyy' -copy (yank, cut) the next N lines, including the current line, into the buffer
  • 'p' -put (paste) the line(s) in the buffer into the text after the current line
  • '/string' -search forward for occurrence of string in text
  • '?string' -search backward 
  • 'n'  -move to next occurrence of search string
  • 'N'  -search for previous occurrence 
  • 'u' -Undo last change
  • 'ctrl + r'  - Redo 
  • ':s/OLD/NEW/g'  -Replace OLD with NEW Globally (all) on current line
  • ':%s/OLD/NEW/g'   -Replace OLD with NEW Every occurrence in file

Sunday, July 28, 2013

Some Linux cli tips that you should know

In this post I'm giving few Linux CLI tips/shortcuts which i found very helpful and increase your speed while you are working on Linux using CLI. These tricks are very useful for those who are new to Linux.

  1. 'CTL+L' - Clear screen. (you can use 'clear' also to clear the screen).
  2. 'CTL+R' - Search recent commands from History.
  3. 'CTL+A' - Take the cursor to the start of current command.
  4. 'CTL+E' - Take the cursor to the end of currnet command.
  5. 'CTL+W' - To erase one word in current command.
  6. 'CTL+U' - To erase whole command.
  7. 'CTL+Y' - To type the above command which was erased by 'CTL+U'.
  8. 'CTL+D' - Exit or logout current session.
  9. 'screen' - run multiple session inside a single session. 'CTL+A' then 'N' to go to next session and 'CTL+A' then 'P' to go to previous session.
  10. 'CTL+C' - To halt current command
  11. 'CTL+Z' - Stop current command
  12. '!!' - Repeat previous command