DevOps Learning Notes
2 Followers
In this lecture you are learning LINUX VI Editor & AWS Security Group:
VI-EDITOR: is used to add/modify/edit the data in any regular files. Vi-Editor has two operating modes
VI-EDITOR begins in command mode, where the cursor movement and text deletion and pasting occur. Insertion mode begins upon entering an insertion (i) or change (a) command.
[ESC] returns the editor to command mode. Most commands execute as soon as you type them except for "colon" commands which execute when you press the return key.
Command mode: This mode enables user to perform administrative tasks such as saving files, executing commands, moving the cursor, cutting (yanking) and pasting lines or words, and finding and replacing. In this mode, whatever user type is interpreted as a command.
Insert mode: This mode enables user to insert text into the file. Everything that's typed in this mode is interpreted as input and finally it is put in the file.
The vi always starts in command mode. To enter text, user must be in insert mode. To come in insert mode user simply type i. To get out of insert mode, press the Esc key, which will put user back into command mode.
Here describing Vi-Editor commands which mostly used to manage the content in a file in Linux.
How to Move the Cursor
Below table shows very frequently used commands in Vi-Editor:
Insert Mode:
i To begin insert mode at the cursor position
I To insert at the beginning of line
a To append to the next word’s letter
A To Append at the end of the line
o To insert a new line below the cursor position
O To insert a new line above the cursor position
Command Mode:
gg To go to the beginning of the page
G To go to end of the page
w To move the cursor forward, word by word
b To move the cursor backward, word by word
nw To move the cursor forward to n words (5W)
nb To move the cursor backward to n words (5B)
u To undo last change (word)
U To undo the previous changes (entire line)
Ctrl+R To redo the changes
yy To copy a line nyy To copy n lines (5yy or 4yy)
p To paste line below the cursor position
P To paste line above the cursor position
dw To delete the word letter by letter (like Backspace)
x To delete single character at cursor position
dd To delete entire line
ndd To delete n no. of lines from cursor position(5dd)
/ To search a word in the file
Extended Mode: (Colon Mode)
Extended Mode is used for save and quit or save without quit using “Esc” Key with “:”
:w To Save the changes
:q To quit (Without saving)
:wq To save and quit
:w! To save forcefully
wq! To save and quit forcefully
:x To save and quit
:X To give password to the file and remove password
:20(n) To go to line no 20 or n
: set nu To set the line numbers to the file
:set nonu To Remove the set line numbers
Linux Environment Variable:
Environment variables stores the dynamic system values that can be used within the shell or its child processes. To know the list of environment variables that are set in linux system run the command below.
[edwiki@ip-10-8-2-22 ~]$ env
SHELL=/bin/bash
TERM=screen
HISTSIZE=1000
USER=edwiki
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
PWD=/home/edwiki
HOME=/home/edwiki
LOGNAME=edwiki
[edwiki@ip-10-8-2-22 ~]$
Below are the most common environment variables that will be used in Linux systems:
AWS Security Group:
Security groups are way to control inbound and outbound traffic to EC2 instance. AWS security groups will act as a virtual firewall for EC2 instances, and provide more and additional layer of security for your resources in the AWS cloud.
Inbound and Outbound rule: Security groups can have rules for both inbound and outbound traffic, allowing you to control traffic from both inbound and outbound traffic.
Stateful: Security groups are stateful, this means if we make any changes applied on inbound rule it will be automatically applied to the outbound rule.
Key Notes:
Network Terminologies:
Protocol:
A protocol is a set of rules that must be followed between the client and server to process the data/request. Client ensure the protocol to send the request that can be understand by the server.
Let say SSH client ensure to follow the SSH protocol to send the Login request to the server and in the server side the SSHD daemon ensure to receive the request and understand the request by using the SSH protocol and process the request.
Port: Network port is just a logical number that will be sending throught the client request to let the server program know who is responsible to process this request.
Service: Service is the process that runs on the server side to process the client requrst. Each service is binded with a port number to be responsible to process the requests that reach to that port number.
Below table shows some common services and the associated port assignments in linux systems
Linux Commands:
uptime: To check since how long the system is in running state.
[edwiki@ip-10-8-2-22 ~]$ uptime
02:14:19 up 36 min, 1 users, load average: 0.08, 0.19, 0.19
[edwiki@ip-10-8-2-22 ~]$
whereis: whereis command shows the binary file path by searching the system directories that are stored in the PATH environment variable.
[edwiki@ip-10-8-2-22 ~]$ whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
[edwiki@ip-10-8-2-22 ~]$