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

DevOps Interview Handbook

The document is a comprehensive guide covering various technical topics including Git, Linux, Docker, CI/CD, Kubernetes, and Terraform fundamentals. It provides detailed instructions, commands, and concepts essential for understanding and implementing these technologies. Each chapter includes practical exercises and best practices to enhance learning and application.

Uploaded by

Tabassum
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

DevOps Interview Handbook

The document is a comprehensive guide covering various technical topics including Git, Linux, Docker, CI/CD, Kubernetes, and Terraform fundamentals. It provides detailed instructions, commands, and concepts essential for understanding and implementing these technologies. Each chapter includes practical exercises and best practices to enhance learning and application.

Uploaded by

Tabassum
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Table of Content

Chapter 1: Git Fundamentals ...........................................................................12


How to set up git? .....................................................................................................12
How to initialize a git repository?..........................................................................12
Basic git commands ..................................................................................................12
Why specify origin <branch-name> in git pull or git push?...........................13
What is <upstream>? ................................................................................................13
What does it mean to have multiple remotes? ..................................................13
List all remote..............................................................................................................13
View details about the specific remote branch ................................................14
Rewrite the most recent commit message.........................................................14
Rewrite older commit messages............................................................................14
Remove local commit ................................................................................................14
Remove remote commit ...........................................................................................14
How to undo a commit? ...........................................................................................15
The difference between revert, rebase, and reset............................................15
Which command is used to delete a specific commit?...................................15
How to take commits of one branch and put it in another branch? ...........16
What is a diverged branch?.....................................................................................17
What is git merge? .....................................................................................................18
Common branching strategy ..................................................................................19
Chapter 2: Linux Fundamentals ..................................................................... 20
How to check the current user? .......................................................................... 20
How to check which users are currently logged in? ...................................... 20
How to list all users on the system?................................................................... 20
How to change the user?........................................................................................ 21
What is a login shell?................................................................................................ 21
Difference between login and non-login shell?................................................ 21
How to check if the shell is a login shell or not? .............................................. 21
How to switch to the login shell? ......................................................................... 21
How to create a user?.............................................................................................. 21
How to modify existing users?..............................................................................22
How to delete a user? ..............................................................................................22
Can multiple users be deleted with userdel command? ................................22
How to add a new user to a group? .....................................................................22
How to create a group?...........................................................................................23
How to change the group name? .........................................................................23
How to change the group ID?................................................................................23
How to delete a group? ...........................................................................................23
How to remove a user from a group?.................................................................24
How to change the owner of a file/directory?................................................24
How to change group ownership only? ............................................................24
How to modify a file/directory? ..........................................................................24
How to view permissions? ................................................................................... 26
How to modify file attributes? ........................................................................... 26
List directory........................................................................................................... 26
How to check the current working directory?............................................... 26
How to change directory?....................................................................................27
mkdir command .......................................................................................................27
rm command.............................................................................................................27
Remove directory and subdirectory................................................................. 28
cp command............................................................................................................ 28
mv command ........................................................................................................... 28
How to create a file? ............................................................................................. 29
How to check file type? ....................................................................................... 29
How to zip and unzip?........................................................................................... 29
tar command ........................................................................................................... 29
cat command .......................................................................................................... 30
grep command......................................................................................................... 31
sed command...........................................................................................................32
head command ........................................................................................................32
tail command............................................................................................................32
awk command ......................................................................................................... 33
sort command......................................................................................................... 33
cut command .......................................................................................................... 34
diff command .......................................................................................................... 34
tee command .......................................................................................................... 34
locate command......................................................................................................35
find command ..........................................................................................................35
What is a soft link and a hard link?.................................................................... 36
Chapter 3: Linux networking commands .................................................... 39
How to find the public and private IP of the current device? ................... 39
How to check open ports on the current device?........................................ 39
How to open a port? ............................................................................................. 39
How to check if a host is live? ............................................................................ 39
How to check which ports are currently engaged?..................................... 39
How to check network bandwidth?.................................................................. 39
How to check network speed?........................................................................... 39
How to check the open ports of a server? ..................................................... 40
How to check which IP tried to establish ssh connection? ....................... 40
Decide which user can establish a remote ssh connection....................... 40
How to ban an IP that failed to establish ssh connection? ....................... 40
How to find details of a domain?........................................................................ 41
How to monitor the network in real time?........................................................ 41
What is a domain query tool? .............................................................................. 41
What is reverse lookup? ........................................................................................ 41
Chapter 4: Shell Scripting Fundamentals ................................................... 43
How to create a shell file? ................................................................................... 43
How to print in a shell script? ............................................................................. 43
How to pass input?................................................................................................ 43
How to declare a variable? .................................................................................. 43
How to read environment files in a shell script?............................................ 44
How to Create a Function .................................................................................... 44
How to Create a Parameterized Function ........................................................ 44
How to create an if-else statement.................................................................. 44
How to create Nested if-else .............................................................................. 45
How to create a Case statement ....................................................................... 45
How to create For Loop ........................................................................................ 45
How to create While Loop .................................................................................... 46
How to create Until Loop ..................................................................................... 46
Chapter 5: Networking Fundamentals ........................................................ 48
Basic Networking Concepts................................................................................ 48
What is a computer network?......................................................................... 48
What are the main types of computer networks?.................................... 48
What is the difference between IPv4 and IPv6? ........................................ 48
What are private and public IP addresses? Provide examples............... 48
What is a subnet mask, and why is it important? ..................................... 49
Network Protocols ................................................................................................. 49
What is the OSI model? Explain its seven layers........................................ 49
How does the TCP/IP model differ from the OSI model? .......................... 49
Explain the differences between TCP and UDP. ......................................... 49
What is the purpose of ARP (Address Resolution Protocol)? ................ 50
What is ICMP, and how is it used in networking? ....................................... 50
How does DNS (Domain Name System) work?............................................ 50
What is DHCP, and how does it work? ........................................................... 50
Explain NAT (Network Address Translation) and its types ...................... 50
What is a firewall, and how does it work?.................................................... 50
Advanced Networking Concepts ................................................................... 50
What is a VPN, and how does it work? .......................................................... 50
Advanced Networking Concepts ....................................................................... 50
What is a VPN, and how does it work? ......................................................... 50
What are VLANs, and why are they used? ....................................................... 50
What is a load balancer, and what are its types?........................................... 51
What is BGP (Border Gateway Protocol), and why is it important? ........... 51
What are SDN (Software-Defined Networking) and NFV
(Network Function Virtualization)? .................................................................... 51
Chapter 6: Subnet Calculation .................................................................... 53
Subnet........................................................................................................................53
Subnet Mask.............................................................................................................53
Binary Representation...........................................................................................53
Converting a Decimal Number to a Binary........................................................53
Example Binary Conversion ................................................................................. 54
Subnet Calculation Problem.................................................................................55
Exercises .................................................................................................................. 58
Exercise 1: Binary Conversion ......................................................................... 58
Exercise 2: Subnet Mask Calculation ............................................................ 58
Exercise 3: Find the Network Address .......................................................... 58
Exercise 4: Find the Broadcast and Host Range ....................................... 58

Chapter 7: Docker Fundamentals................................................................ 60


Host Machine .......................................................................................................... 60
Virtual Machine (VM) ............................................................................................. 60
Docker ....................................................................................................................... 60
Hypervisor................................................................................................................ 60
Kernel......................................................................................................................... 60
VM Layer.................................................................................................................... 61
Docker Layer............................................................................................................. 61
Docker inside VM Layer ........................................................................................ 62
Essential Docker Components............................................................................ 63
Docker Engine ..................................................................................................... 63
Docker Daemon................................................................................................... 63
Docker CLI ............................................................................................................ 63
Docker REST APIs ................................................................................................ 63
Docker Image....................................................................................................... 63
Docker Container ............................................................................................... 63
Docker Registry .................................................................................................. 64
Docker Volumes .................................................................................................. 64
Docker Mount...................................................................................................... 64
Docker Network .................................................................................................. 64
Essential Docker Commands ............................................................................... 65
Images:.................................................................................................................. 65
Containers:........................................................................................................... 66
Networks:...............................................................................................................67
Volumes:................................................................................................................ 68
Mounts (for Bind Mounts and Volumes): ..................................................... 69
Additional Useful Commands:......................................................................... 69
Default File Locations ........................................................................................... 69
DockerFile..................................................................................................................70
Exercises ...................................................................................................................72
What is Docker? ...................................................................................................72
What are the key components of Docker? ..................................................72
What is the difference between a Docker Image and a Docker
Container? ............................................................................................................72
What is a Dockerfile?..........................................................................................72
What is the difference between CMD and ENTRYPOINT in a
Dockerfile? ............................................................................................................72
What are Docker Volumes and why are they used? ..................................72
What is the difference between Docker Volumes and Bind Mounts?...73
What are the different Docker networking modes? ..................................73
How do you create a Docker network? .........................................................73
How do you connect a running container to a network?........................73
What is Docker Compose and why is it useful? ..........................................73
What is a multi-stage build in Docker?..........................................................73
How do you reduce the size of a Docker image? .......................................73
How can you debug a running Docker container? ....................................73
How do you check if a Docker container is running? ...............................74
What happens when you run docker system prune? ...............................74
How do you restart a stopped container? ..................................................74
How do you inspect a Docker image? ...........................................................74
How do you troubleshoot a container that keeps restarting? ..............74
Chapter 8: CI/CD Fundamentals .................................................................76
Introduction to CI/CD ...........................................................................................76
Why CI/CD?..............................................................................................................76
CI/CD Workflow Overview.....................................................................................77
Setting Up CI/CD Pipelines ..................................................................................77
Rollback Strategies in CI/CD .............................................................................. 78
Tool-Agnostic CI/CD Concepts ......................................................................... 79
Chapter 9: Kubernetes Fundamentals ....................................................... 81
Kubernetes Components .................................................................................... 81
Control Plane Components................................................................................. 81
Node Components ................................................................................................ 81
Additional Kubernetes Objects ........................................................................ 82
Kubernetes Commands ...................................................................................... 83
Cluster and Node Management.................................................................... 83
Pod Management ............................................................................................. 83
Deployment Management ............................................................................... 84
Service and Networking ................................................................................... 84
Configuration and Secrets .............................................................................. 84
Logs and Debugging ......................................................................................... 85
Persistent Storage............................................................................................. 85
Namespace Management ................................................................................ 86
Exercises ................................................................................................................ 87
What is Kubernetes? ......................................................................................87
What is a Pod in Kubernetes? ......................................................................87
What is a Kubernetes Cluster? ....................................................................87
What is a Deployment in Kubernetes? ......................................................87
What is a Service in Kubernetes? ...............................................................87
What is the difference between a Pod and a Container? ....................87
What are Namespaces in Kubernetes?......................................................88
What is a ConfigMap in Kubernetes?.........................................................88
What is a Secret in Kubernetes? .................................................................88
What is a ReplicaSet in Kubernetes? .........................................................88
What is Helm in Kubernetes?........................................................................88
What is a Persistent Volume (PV) and Persistent Volume Claim
(PVC) in Kubernetes?......................................................................................88
What is a Kubernetes Ingress? ....................................................................89
What is the role of Kubelet in Kubernetes? .............................................89
What is a Node in Kubernetes?....................................................................89
What is Kubernetes Autoscaling?...............................................................89
What is the difference between StatefulSet and Deployment?........89
What are Kubernetes Volumes? ..................................................................89
What is the purpose of kubectl in Kubernetes?.....................................89
How does Kubernetes handle container scheduling? ..........................90
Chapter 10: Terraform Fundamentals.........................................................92
Introduction to Infrastructure as Code (IaC)................................................ 92
What is Terraform? ............................................................................................... 92
Core Concepts of Terraform .............................................................................. 92
How Terraform Works: The Basic Workflow.................................................... 93
Example Terraform Configuration .................................................................... 94
Key Terraform Commands .................................................................................. 94
Best Practices for Using Terraform ................................................................. 95
Chapter 11: Questionnaires ........................................................................97
GIT..............................................................................................................................97
Basic Git Concepts ......................................................................................... 97
Git Commands .................................................................................................. 97
Collaboration and Workflows ....................................................................... 97
Git for DevOps ..................................................................................................98
Git Best Practices ...........................................................................................98
Linux ........................................................................................................................ 99
Basic Linux Server Concepts .......................................................................99
Linux Commands for File Management .....................................................99
Linux Process Management .........................................................................99
Networking Commands................................................................................100
System Monitoring and Log Management.............................................100
Linux User and Permissions Management..............................................100
Linux System Administration .....................................................................100
Security and Backup.....................................................................................101
Networking............................................................................................................102
Basic Networking Concepts....................................................................... 102
Networking Protocols and Ports ............................................................... 102
Network Topologies and Devices .............................................................. 102
Networking Security .................................................................................... 103
Network Troubleshooting and Monitoring ............................................. 103
Cloud Networking.......................................................................................... 103
Advanced Networking Topics ....................................................................104
Docker ....................................................................................................................105
Basic Docker Concepts ............................................................................... 105
Docker Containers and Images.................................................................. 105
Docker Networking ....................................................................................... 105
Docker Volumes and Storage..................................................................... 106
Docker Compose and Multi-container Environments ......................... 106
Docker Security and Best Practices ........................................................ 106
Docker Swarm and Orchestration ............................................................. 107
Docker in CI/CD and DevOps ....................................................................... 107
CI/CD ...................................................................................................................... 108
Basic CI/CD Concepts...................................................................................108
Tools and Technologies in CI/CD................................................................108
CI/CD Pipeline Implementation ..................................................................108
Testing in CI/CD.............................................................................................. 109
Automation in CI/CD...................................................................................... 109
CI/CD Best Practices......................................................................................110
CI/CD Challenges and Troubleshooting ....................................................110

Kubernetes ............................................................................................................ 111


Basic Kubernetes Concepts.........................................................................111
Pods and Containers ......................................................................................111
Deployments and ReplicaSets ....................................................................111
Services and Networking .............................................................................112
Storage and Volumes ....................................................................................112
StatefulSets and DaemonSets ...................................................................112
Kubernetes Security .....................................................................................113
Monitoring and Logging...............................................................................113
Kubernetes in CI/CD.......................................................................................113
Advanced Kubernetes Topics .....................................................................114

Terraform & IaC ..................................................................................................... 115


Basic Concepts of Terraform and IaC .......................................................115
Terraform Workflow and Execution ...........................................................115
State Management and Backend ..............................................................115
Terraform Modules and Reusability ..........................................................116
Managing Variables and Secrets................................................................116
Terraform Cloud and Enterprise ................................................................. 117
Advanced Terraform Topics ......................................................................... 117
Terraform and CI/CD Integration................................................................. 117
Terraform and Multi-Cloud...........................................................................118

AWS ......................................................................................................................... 119


Basic AWS Concepts .....................................................................................119
AWS Compute Services.................................................................................119
AWS Storage Services ...................................................................................119
AWS Networking and Content Delivery ................................................... 120
AWS Security and IAM.................................................................................. 120
AWS Databases ...............................................................................................121
AWS Monitoring, Logging, and Management..........................................121
AWS DevOps and CI/CD Tools...................................................................... 122
Advanced AWS Topics .................................................................................. 122
https://youtu.be/XeBNm_zpMmc?si=LdYbLnUTiEV9lTM6
https://youtu.be/a68KOT1l59Q?si=_S9ff00uJLXd8VV5
Chapter 1 Git Fundamentals
How to set up git?

How to initialize a git repository?

Basic git commands


Why specify origin <branch-name> in git pull or git push?
If the repository has multiple remotes (e.g., origin, upstream, fork), specifying the
remote (origin) and branch name allows it to target a specific repository and
branch to pull or push changes.

Specifying the branch name is useful when you are working on multiple branches
locally or need to interact with a branch different from the one you are currently
on.

What is <upstream>?
In Git, the term upstream refers to the remote branch that the local branch is
currently tracking.

What does it mean to have multiple remotes?

Having multiple remotes in a Git repository means that your local repository is
configured to interact with more than one remote repository.

List all remote


View details about the specific remote branch

Rewrite the most recent commit message

Rewrite older commit messages

Remove local commit

Remove remote commit


How to undo a commit?

The difference between revert, rebase, and reset

git revert: Creates a new commit that reverses the changes made by a specific
commit, preserving the original commit history.

git rebase: Moves or combines a series of commits to a new base commit,


allowing you to "replay" commits from one branch onto another or to reorder,
squash, or edit individual commits.

git reset: Moves the current branch's HEAD backward to a specific commit,
potentially modifying or discarding recent commits.

Which command is used to delete a specific commit?

git rebase: used for specific commit removal

git reset: used for removing latest commit


How to take commits of one branch and put
it in another branch?
What is a diverged branch?
A diverged branch in Git is a branch that has developed independently from
another branch since they last shared a common commit history.

Let’s say there was a branch named dev from which two branches were created
named featA and featB

As we can see, dev, featA, and featB shared a common commit history until
commit c. After that, all three branches were developed separately. So, we can
say all three branches diverged from each other after commit c.
What is git merge?
git merge incorporates changes from the named commits (since the time their
histories diverged from the current branch) into the current branch.

So, let’s say we want to merge featB to dev

It will replay the changes made on the featB branch since it diverged from dev
(i.e., D) until its current commit (J ) on top of dev, and record the result in a new
commit along with the names of the parent commits and a log message from the
user describing the changes.
Common branching strategy
main: Latest stable production codebase

dev: Main branch for active development. Other development branches merge
here.

stage: Codebase for testing in an identical production-like environment.

prod: Codebase ready to be deployed in production.

setup: For initial project setups or environment configurations (e.g., CI/CD


pipelines, testing frameworks).

chore: For non-functional updates like refactoring code, updating dependencies,


or improving documentation.

bugfix: For fixing non-critical bugs found during development.

hotfix: For urgent fixes that need immediate production deployment.

release: Prepares code for a new release.


Chapter 2 Linux Fundamentals
How to check the current user?

How to check which users are currently logged in?

How to list all users on the system?


How to check the current user?

You might also like