Abt Some Linux Commands

Interesting Linux Terminal Commands

Notation => | - Cursor

CTRL + w
= Delete a word of the command typed
Ex:
$ echo this is a line|
$ echo this is a |[After ^w]

CTRL + b = Move the cursor one character left[Backward]
Ex:
$ cat filename|
$ cat filenam|e

CTRL + a = Move to the start of the command [Equivalent to Home]
Ex:
$ cat filename|
$ |cat filename

CTRL + u = Clear the command from the cursor's point
Ex:
$ cat file1 |file2
$ file2

CTRL + r
= Reversed search, Searchs for the pattern in the commands entered in the past and displays one after another continuously [Last entered command first]


CTRL + e
= Move to the end of the command
Ex:
$ cat |file1 file2
$ cat file1 file2|

!! = Executes the last entered commmand

!$ = Returns the last argument of previously entered command
Ex:
$ mkdir /home/user/temp
$ cd !$

!pattern = Executes the last command with this pattern

!pattern:p = Prints the last command with this pattern instead executing
 

_whatever = Never stores the command in history[_ = space character]
Ex:
$  echo hai
 

Interesting things in vim

:earlier n[Sec 's'|Min 'm'|Hour 'h'|changes '']
:later n[Sec 's'|Min 'm'|Hour 'h'|changes '']

Ex:
:earlier 10s

Switches from current to n[Sec|Min|Hour|changes] before[earlier] or after[later]

:w !sudo tee %
Write even in non-sudo user mode without exiting.
 

gg=G
Indent the entire file

:set tabstop=n
Sets tab characters to n length

:set smartindent|autoindent|cindent
Sets the appropriate indentation

VU = Uppercase the current line

Vu = Lowecase the current line


VEU = Uppercase the word

g~~ = Invert case of the current line [~ - tilde]
In visual mode you can select the text and use tilde to invert case


CTRL + x = Decrements the number under the cursor by 1
CTRL + a = Increments the number under the cursor by 1

:split filename = Opens another file in the same window, split happens horizontally
:vsplit filename = Opens another file in the same window, split happens vertically
CTRL + w
[twice] = Move around the opened files

:hide = Hide current window
CTRL + g = Details of the file[Total no. of lines and % to go from current line]
H = Start of Screen 
M = Middle of Screen
L = Last of Screen
zt = Bring the line to the top [Kind of page up]
zz = Bring the line to the middle
zb = Bring the line to the bottom [Kind of page down]
G = End of file
gg = Start of file 
q: = Command History
q/ = Search History
$ = End of line
b = Beginning of non white space word in  backword direction
B = Beggining of non white space word in forward direction
* = Moves to next occurence [highlights all matches if enabled] of current word in forward direction
#Moves to next occurence of current word in backward direction
^ = Start of line
$ = End of line
<aB || >aB = Intend a Block
c% = Cut the current block
. = Repeat the previous action
CTRL+SHIFT+R+" = Paste the clip board content in insert mode
:set paste = Preserve Indentation
:set ignorecase = ignores case on file search 
All above mentioned commands are useful only if you find the use of them :) For example See the Ex. mentioned for !$ mentioned in the list.

Comments

Popular posts from this blog

Headless Chrome/Firefox Selenium Java in Amazon EC2

Cassandra PHPCassa & Composite Types

Selenium Webdriver in Nodejs + Javascript