Yanking :
Yank is a synonym for pull
It expresses the idea of copying text to a buffer or clipboard for subsequent use.
yy:
Copy the single line from the terminal
<number>yy:
Copy 3 lines from the terminal e.g. 3yy
p:
Paste the lines copied
dd:
Delete the single line from the terminal
<number>dd:
Delete 3 lines from the terminal. e.g. 4dd
cc:
Delete the line and enter into insert mode
gg:
Cursor will move to the top of the file
G:
Cursor will move to the end of the file
:<number>:
Cursor will move to the fourth line of the file. e.g.:4
/<word> :
Find the word. e.g /Pranav
:q:
Quit a file without saving the file
:wq:
Quit the file by saving the file:
wq!:
"!" used to forcefully
:set nu:
It is used for setting the number of the lines
:%s/<wordtoreplace>/<wordtoreplacewith>/g :
It is used for replacing the words, Here "g" stands for Globally. e.g. :%/Red/Black/g
:!<command> :
It is used for performing the command without getting out of the file. e.g.:!ls
Modes In Terminal :
Insert Mode
By clicking "i" we get into insert mode.
Where we can write/modify the file.Save and Exit Mode
Once we are done with the modification, to save the file we use this mode.
There are two options, Either you can just quit/exit from the file without saving or else you can save and exit.
You can use ":wq" for save and exit and ":q" for only exit.Visual Mode
By clicking "v" in the terminal the Visual Mode is activated.
Shift + v - Select the line
Cltl + v - To delete the selected box
File Redirection In Linux :
Redirection is accomplished by using either the ">" (greater-than symbol) or the "|" (pipe) operator, which sends the standard output of one command as standard input to another command.
Redirecting messages into the file using echo
#echo "message" > <filename>
echo "Hello Pranav" > Test.txt
Show the error message and output using the "find" command
#find <locationto search> -user <username>
find / -user Pranav
Redirecting error into the file and showing only output
#find <locationto search> -user <username> 2> <ErrorFileName>
find / -user Pranav 2> Error.txt
Redirecting output into the file and showing only error
#find <locationto search> -user <username> > <OutputFileName>
find / -user Pranav > Output.txt
Redirecting both error and output into a separate file
#find <locationto search> -user <username> > <OutputFileName> 2> <ErrorFileName>
find / -user Pranav > Output.txt 2> Error.txt
Redirecting both error and output into a single file
#find <locationto search> -user <username> &> <ErrorOutputFileName>
find / -user Pranav > CompleteOutput.txt
Redirecting output to a file and showing it on the terminal as well
#find <locationto search> -user <username> | <OutputFileName>
find / -user Pranav | Output.txt