The following commands are used in vi editor
To Display Line number for each Line
:set number
To remove line number
:set nonumber
To view all the set options
:set all
To move the cursor left,right,up,down
h - Left
j - down
l-right
k-up
To move beginning of the line
0 (zero)
To move end of the line
$
To move beginning of next word
w/W
To move end of next word
e/E
To delete current line
dd
To delete the character under cursor
x
For multiple deletion
Delete 5 characters : 5x
Delete 10 lines : 10dd
To copy a group of 'n' consecutive lines, use 'yy' and 'p'.
For example, to copy 4 lines (in command mode):
1. Move the cursor to the first line to be copied.
2. '4yy'
3. Move cursor to the destination.
4. 'p'
To view special characters
:set list
To find and replace all the occurrence
: %s/<<actual text>>/<<replace text>>
To have the properties of vi editor to be customized for a user changeor create the file in the home directory
.exrc or .vimrc
The following of few general Commands
To know where is the command
where is <<command>>
Eg: where is ls
To know the size of each directory in a given directory
du -sh *
To know the pervious commands given
history
To remove all the files and directory and sub directory use the below command (be cautions)
rm -rf <<directory>>
To zip a directory us the foollowing command
zip -r <<filename.zip>> <<directory>>
To unzip the file
unzip <<filename.zip>>
To identify available shells in your system
cat /etc/shells
To identify the currently used shell
echo $SHELL
Shell Script can be executed in one of the following way
bash myscript
sh myscript
./myscript
Note: In the last syntax ./ means current directory, But only . (dot) means execute given command file is current shell without starting the new copy of shell. The syntax for .(dot) commands is as follows
If we want to run a command in background append '&' at the end of command
du -sh * &
To know about re-directions
> filename - redirects standard output to the filename - it will overwrite existing files, not append.
>& filename - redirects standard output and standard error to the filename
>> filename and >>& filename appends to, rather than overwrites, the file.
< filename - redirects standard input from the file to the program
<< word - see below for the word
| - connect the standard output of the prior command/program to the standard input of the subsequent command/program (i.e. a pipe).
|& - same thing as | but also connects standard error to standard input
We have value for Standard input, output and error
Stdin - 0
Stdout - 1
Stderr - 2
To search the files under sub directories use find command
find <<directory>> -name "*.java"
To identify the number of processors in Solaris use the following command
psrinfo
To identify the number of processors in Linux use the following command
cat /proc/cpuinfo | grep processor
To identify the Domain Name or IP address ( In result the first section specifies the server and address of that server that provided you with the domain name and IP address displayed in the second section.)
nslookup google.com
To send a process from foreground to background we have the following option to give ctrl + z
and give bg in the nextline
To know the process running in background
ps -ef
To know the process is started and few more details use
top -c
***************************************************
https://linuxize.com/post/less-command-in-linux/
*****************************************************
To create multiple windows/multitask inside putty use the below screen command
reference : https://www.tecmint.com/screen-command-examples-to-manage-linux-terminals/
screen -ls --> to know the session available or created
screen -S <<name>> --> To create a session with user defined name
screen -r <<name>> --> to attach the /activate the session with sepcified name
cltr+ a and then press d --> to release the session
****************************************************************
https://www.geeksforgeeks.org/netstat-command-linux/
netsat -na | grep -i time_wait | grep -c 29680 --> prod
***********************************************
netstat -tlnp --> gives the port and services which are running
*****************************************
Package Manager
https://www.makeuseof.com/tag/power-choice-power-package-management/