0% found this document useful (0 votes)
3 views

Linux notes

The document outlines best practices for DevOps, emphasizing collaboration between development and operations teams to deliver high-quality software quickly. It details deployment steps using various tools such as Git, Sonarqube, Maven, Selenium, Ansible, and Jenkins, along with Linux commands for file management, permissions, and system monitoring. Additionally, it covers advanced topics like secure communication between servers and the differences between hard and soft links.

Uploaded by

rajeshmystuff3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Linux notes

The document outlines best practices for DevOps, emphasizing collaboration between development and operations teams to deliver high-quality software quickly. It details deployment steps using various tools such as Git, Sonarqube, Maven, Selenium, Ansible, and Jenkins, along with Linux commands for file management, permissions, and system monitoring. Additionally, it covers advanced topics like secure communication between servers and the differences between hard and soft links.

Uploaded by

rajeshmystuff3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

DEVOPS

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

>maven will convert the compiled code into jar file

>Selenium will test the application

>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

>DNS Will convert URL Into IP Address viceversa .

LINUX DAY 01

>EC2 instance will take default 5 minutes /300 seconds for status check ,we can even change the
timing .

LINUX COMMANDS

 Clear – it will clear the commands or ctrl s


 pwd – It shows the present working directory (folder )
 mkdir gowthami – makedirectory which creates the folder .
 ls – list which shows the list of files and folders created in current directory/folder
 ls-l >> long list which displays all the files and folders in machine
 cd gowthami – Change directory so now it will go inside gowthami folder
 After creating folder create a file --- touch myfile ,myfile is a file name
 Cd – now it will come out of the gowthami folder
 clear
 touch file1 file2 file3 – creates multiple file
 mkdir folder1
 mkdir folder2
 ls
file1 file2 file3 folder1 forlder2 gowthami
 To display recent files and folders at the top – ls -lt
 To display recent file and folders at the bottom – ls -lrt
 To show content of the file – cat file1
 To write content in file – vi file1 , 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!
w – save ,q – quit ,wq – save and quit
 cat <filename> - cat file1
now it shows the content of file1
 To replace word in vi editor –
Vi file2 , we can give insert button and change else press esc button ,shift:%s/hello/hi/gi
enter
No it shows hi all good morning welcome to devops class
Note - gi-globally insert
 Difference between touch and vi
touch file9 – it will create only empty file
vi filexyz >> now file is created and also we can even write the content here
 To check hidden files – ls -a
 To delete file >> rm -rf file1
Now do ls file1 will be deleted
Note – rm means remove ,rf means recoursive forcefully
 To delete folder >> rm -rf gowthami
 Dangerous command >> rm -rf *
ls – Now all the files and folders will be deletd
It deletes all the files and folders permanently we cant restore back
 rm -rf >> It removes files and folders but can be restored by linux administrator

To display size of the folder

 mkdir folder1 folder2 >> creates folder


ls – shows the list of folder created
du -sh >> It shows the size of ubuntu
cd folder1 >>enter
du -sh >> It shows the size pf folder 1
4.0k
Note – du >>disc usage, sh >>size human readable
 To check systems disc space >> df -h
 To check system memory or RAM >> free

To copy content from one file to other

 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

To move file from source to destination path

 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

Now we will move folderxyz to folder2


mv folderxyz folder2
ls >> folder2
cd folder2
ls >> folderxyz myfile

 history – IT shows the history of commands used

LINUX DAY 2

File Permissions

ls -l >>> total 8

For myfolder permission is rwxrwxr-x


r = read = 4
w = write = 2
x = execute = 1(total number should be 7)
rwx (user) rwx (group) r-x(others)
4+2+1 4+2+1 4+0+1
7 7 5
Permission number is 775

For myfile permission is rw-rw-r--

rw- rw- r--


4+2+0 4+2+0 4+0+0
6 6 4
Permission number is 664

Interview question ----How do you change the permission for particular file or folder ?

Using Chmod command we can change default file permission

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.

Note - Redirect is used to copy output of one command to new file .


 To display File content in number wise

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

Add few more lines of content


NOTE : Head command is used to display first n lines of file and Tail command is used to display last
n lines of file as shown below
WORDCOUNT

It is used to count the number of lines ,no of words ,no of characters of a particular file or directory .

In the above 11 is no of lines ,20 is no of words & 118 is no of characters.

To display only no of lines /words /characters use below commands in fig.


ECHO COMMAND

It is used to print the statement . It is v important command.

 To print multiple statement use below command in fig.


\n is new line ,\t is next tab

Ls and echo* command does the same job as shown below .

 FIND COMMAND
It is used to find the location of file and directory.

SYNTAX – find . -type f -iname kulkarni(file name)

. >>>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

Now to find the file1 location use below command


 TO DISPLAY FILES WHICH IS CREATED OR MODIFIED 3 DAYS(ANY) AGO OR DAYS WITHIN

+ Sign is used for ago


- Sign is used for within

 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.

 TO FIND EMPTY FILES USE BELOW COMMAND


 TO FIND FILES WHICH HAS FULL PERMISSION(777)USE BELOW COMMAND

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.

Command>> ls(it shows list of file)

ln -s filename linkname

ls

cat mylink (everything in file will be present here)

rm -rf filename

ls

cat linkname (error – no such file)

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

cat linkname(still file content is present over here)

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

In below files in ubuntu will not be present in root user.


rm -rf * (we will delete the file in root user)

sudo su - (switched to root user)

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

Now it shows sumeet user which we have created .


Go to sudo option by scrolling up and set sudo permission for sumeet user by insert and save it.
UPTIME

To check from how long our system or server is up and running

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 current system date and time

To display date in mm—dd—year

To display day ,date and 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.

scp -a src dest

Difference between rsync and scp

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

Establishing passwordless communication between one server to another

create 2 servers as below

>>>Linux 1st server

>>>>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 copy the public key content and paste it in notepad++

Now go to server 2 go to ssh file and inthat authorized keys paste the notepad++ public key content

By hitting enter button,insert and save it.


Come down insert and paste here
Now go to server1 type cd command

Type ssh root@server2 private ipaddress as shown below


Now we are accessing server2 from server1

And lets exit we will switch to other server

Again we can switch back to that server using below command .


>> To open all traffic , enable ssh port number where port number is 22

0 to 65,535 ports are there in total

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.

To display only listening ports use below command


To display only listening TCP ports use below command

To display only listening UDP ports use below command

Interview questions on Linux

>>commands for to check longlist ,hidden folders

>why we use vieditor command,

>display recent files folders at the top

>disc size

>> To change particular file permission(chmod)

>Aws services

>devops tool

>Find command ,how we check within 3 months file , permission file

>hard link soft link difference ,scp and rsync command

>uptime , hostname,servername,

>establishing communication between 1 server to other

You might also like