Linux notes
Linux notes
It is a best practice to build fast and reliable software application in collaboration with development
and operation team. OR
It is a practice that actually brings the developers ,operators ,HR and testing and their techniques to
release the fastest and high quality software.
DEPLOYMENT STEPS
>Here developers will install Git service in local machine and store the code in git hub repository
where any developer can view .
> Sonarqube is tool which will check the syntax of the code
>ansible will deploy the java /any application in primary &secondary Servers
>Load balancer will distribute the traffic equally if one goes down the other one become primary
>Jenkins is a set of pipeline which contains build(maven) ,test (selenium), code check(sonarqube),
deploy tools (ansible)
AFTER DEPLOYMENT
>Client send URL request via internet which will be sent to Load balancer which will distribute traffic
across the server
LINUX DAY 01
>EC2 instance will take default 5 minutes /300 seconds for status check ,we can even change the
timing .
LINUX COMMANDS
ls
folder 1 folder2
vi myfile >> enter , press I in keyboard ,it shows insert now write the content here for eg
(hello all good morning welcome to devops class) , press esc button insert will go , press shift
colon(:)wq!
cat myfile
hello all good morning welcome to devops class
ls >> folder1 folder2 myfile
cp -r file1 folder1
cd folder1
ls >> myfile my file is copied to folder1
rm -rf myfile>> now myfile is removed
cd
ls >>folder1 folder2 myfile
mv myfile folder1
ls >>folder1 folder2
cd folder1
ls > my file
To rename file
cd
ls>> folder1 folder2
mv folder1 folderxyz
ls >> folder2 folderxyz
LINUX DAY 2
File Permissions
ls -l >>> total 8
Interview question ----How do you change the permission for particular file or folder ?
For eg in the above for myfile to give full access the command is chmod 777 myfile
Now we will change folder2 permission where for users only read ,groups only execute , others only
write permission using chmod 412 folder2 command as shown below.
Next we will give full permission to myfile using chmod 777 myfile command as shown below.
To redirect /copy ouput of history command or from any file to particular file we use
history > myfile command as shown below.
Press enter and , press I in keyboard ,it shows insert now write the content here for eg
(…………………….) , press esc button insert will go , press shift colon(:)wq! As shown below.
cat -n Kulkarni
TO Display first N and last N lines
It is used to count the number of lines ,no of words ,no of characters of a particular file or directory .
FIND COMMAND
It is used to find the location of file and directory.
. >>>current directory
F >>> file
Now we will create folder by name folder2 inside the myfolder and create the file file1 inside
folder2 as shown below and come out of the folders using cd.. com
To Display in minutes use, find . -type f -mmin -10 (within 10 minutes ) shown below
SCENARIO >> To Display or list some files which is created or modified within 60 days and 30
days ago use below command consisting of ! symbol as shown below.
LINK
Link is a shortcut to the file .If we make any changes to link it also reflects in file.Their are two types
of link Soft link(symbolic) and hard link.
Interview question>>difference between hardlink and soft link and command for that
Softlink >> It is also shortcut to a file if we make any changes to original file it reflects in link also and
if we delete the original file than link doesn’t work.
ln -s filename linkname
ls
rm -rf filename
ls
Hardlink>> It is also shortcut to a file if we make any changes to original file it reflects in link also and
if we delete the original file link still works.
Command>> ls
ln filename linkname
ls
cat linkname
cat filename
rm -rf filename
ls
Linux day 3
Here lets see how we switch user from administrator (for eg ubuntu)to root user and
permissions ,we should create files and folders in root user only.
Sudo>> superuser do ,su>> switch user so we switched to root user as shown below
Now we will create the user and set the password,and switch to that user and exit as below.
To check users we have created in root user and check sudo permission(read write ,execute
permission) use below command
vi /etc/group
Here it is from 19 minutes its up. 2:16:01 if we add 5 :30 according to IST we get current IST time.
To display servername ,ip ,full server name,which os flavour,ubuntu version,kernal version use below
commands
>>To check other systems server up and running use ping command
ping ipaddress
SCP(secure copy)
It is a command used to copy files and directory from one server to other server.
rsync is also used to copy file or directory from one server to other server but while copying if
stopped due to any issue and we try again it resume copying from where it left last time, where as
scp will copy from the beginning.
Package manager--- use sudo apt command in ubantu and dbn while installing any package (eg
git),redhat or amazon linux use sudo yum command
>>>>2nd server
In linux server create public and private key using ssh command and hit enter button 4 times
Now private and public will be in hidden folder to check that use ls -a command and it is present
in .ssh
Now go to server 2 go to ssh file and inthat authorized keys paste the notepad++ public key content
scp – 22
http -80
https -443
telnet – 23(command used to check weather remote server port is open or not )
smtp-25
ftp -21
DNS -53
netstat
It is a command used to see available ports and listening port(which are all used)on the system.
Install the nettools and check available ports & listening ports as shown below.
>disc size
>Aws services
>devops tool
>uptime , hostname,servername,