Interview Questions
Interview Questions
Answer: CSS can be applied in three ways: inline (using the style
attribute), internal (using a <style> block in the <head>), and external
(linking to a separate CSS file using <link>).
Answer: The CSS box model consists of four areas: content, padding,
border, and margin, which define the space and layout of an element.
Answer: Padding is the space inside an element between its content and
border, while margin is the space outside the element's border, separating
it from adjacent elements.
Answer: The clear property specifies that an element should not float
alongside the other floated elements.
Answer: block elements take up the full width and start on a new line,
inline elements take up only as much width as necessary, and inline-block
elements allow setting width and height like a block element but remain
inline.
Answer: You can center a block element by setting margin: 0 auto; and
ensuring the element has a defined width.
Answer: The flex property defines how a flex item will grow, shrink, or
distribute space within a flex container. For example:
display: flex;
justify-content: center;
Answer: The float property is used for positioning elements to the left or
right, allowing inline content to wrap around them.
Answer: The box-sizing property defines how the total width and height
of an element are calculated, either including or excluding padding and
borders (content-box or border-box).
Answer: The object-fit property defines how an image or video should fit
within its container, e.g., cover, contain, or fill.
Answer: Flexbox is a CSS layout model that allows items to align and
distribute space within a container efficiently, using properties like flex-
direction, justify-content, and align-items.
Answer: The gap property defines the space between rows and columns
in CSS Grid and between items in a Flexbox container.
Answer: min-width sets the minimum width an element can have, while
max-width sets the maximum width.
Answer: em units are relative to the font size of the parent element, while
rem units are relative to the root element's font size.
Answer: visibility: hidden hides an element but keeps its space in the
document, while display: none removes the element from the document
flow.
What is CSS Subgrid and how does it differ from the Grid layout?
Answer: Subgrid allows nested grid items to inherit the parent grid’s row
and column definitions, giving more precise control over nested elements.
Answer: CSS sprites combine multiple images into one larger image to
reduce the number of server requests and improve performance.
Individual images are shown using the background-position property.
Python
1. What is Python?
o Answer: Python is a high-level, interpreted programming language
with dynamic semantics, known for its simplicity and readability. It
supports multiple programming paradigms including procedural,
object-oriented, and functional programming.
2. What are the key features of Python?
o Answer: Key features include simplicity, readability, interpreted
nature, portability, dynamic typing, support for multiple
programming paradigms, and an extensive standard library.
3. How is Python an interpreted language?
o Answer: Python is interpreted because the code is executed line by
line by the Python interpreter, rather than being compiled into
machine code beforehand.
4. What is PEP 8 and why is it important?
o Answer: PEP 8 is the style guide for writing Python code. It
promotes readability and consistency, helping developers adhere to
standard conventions in Python programming.
5. What is a dynamically typed language?
o Answer: In a dynamically typed language like Python, variable
types are determined at runtime, meaning you don’t need to declare
types explicitly.
6. What are Python’s built-in data types?
o Answer: Common built-in data types include:
Numeric types: int, float, complex
Sequence types: list, tuple, range
Text type: str
Set types: set, frozenset
Mapping type: dict
Boolean type: bool
7. What is the difference between a list and a tuple in Python?
o Answer: Lists are mutable, meaning their contents can change,
while tuples are immutable, meaning they cannot be altered once
created.
8. What are Python's control flow statements?
o Answer: Python’s control flow statements include if, else, elif, for,
while, break, continue, and pass.
9. How do you write comments in Python?
o Answer: Single-line comments start with #. Multi-line comments
can be written using triple quotes ''' ... ''' or """ ... """.
10.What is the purpose of the pass statement?
o Answer: The pass statement is a placeholder that does nothing. It’s
useful for defining blocks of code that will be implemented later.
11.What are Python functions, and how do you define one?
o Answer: Functions in Python are blocks of reusable code. They are
defined using the def keyword:
o def function_name(parameters)# function body
12.What is the difference between return and print in Python?
o Answer: return exits a function and returns a value to the caller,
while print simply outputs a value to the console without affecting
the function’s execution.
13.What is the scope of a variable in Python?
o Answer: Variable scope refers to the region of the code where a
variable can be accessed. Python has four types of scopes: local,
enclosing, global, and built-in.
14.What is a lambda function?
o Answer: A lambda function is an anonymous function defined
using the lambda keyword. It can have any number of arguments
but only one expression:lambda arguments: expression
15.What is the purpose of the self keyword in Python classes?
o Answer: self represents the instance of the class and is used to
access variables and methods that belong to the instance.
16.What is inheritance in Python?
o Answer: Inheritance allows a class to inherit properties and
methods from another class, promoting code reuse. The class that
inherits is called a subclass, and the class being inherited from is
called the superclass.
17.What is a Python module?
o Answer: A module is a file containing Python code (functions,
classes, variables) that can be imported and reused in other
programs.
18.How do you import a module in Python?
o Answer: Modules are imported using the import keyword. For
example:import math
19.What are Python packages?
o Answer: A package is a directory of Python modules. It contains
an __init__.py file that makes the directory a package, allowing it
to be imported as a module.
20.What is __init__.py?
o Answer: __init__.py is a special Python file that initializes a
package when imported, often used to initialize package-level
variables or perform setup.
21.What are decorators in Python?
o Answer: Decorators are a way to modify or extend the behavior of
a function or method by wrapping another function around it.
22.What is the dir() function in Python?
o Answer: dir() returns a list of valid attributes and methods
associated with an object.
23.What is the help() function?
o Answer: help() displays the documentation of modules, classes,
functions, and other objects.
24.What is the __name__ == "__main__" construct in Python?
o Answer: This construct is used to check if a script is being run
directly or imported as a module. If run directly, the block of code
under if __name__ == "__main__": will execute.
25.What is list comprehension in Python?
o Answer: List comprehension is a concise way to create lists based
on existing lists. For example:squares = [x**2 for x in range(10)]
o Answer: append() adds a single element to the end of the list, while
extend() concatenates another list or iterable to the original list.
27.What is the difference between is and == operators in Python?
o Answer: is checks if two variables refer to the same object in
memory, while == checks if their values are equal.
28.What is a dictionary in Python?
o Answer: A dictionary is a collection of key-value pairs. Each key is
unique, and the values can be of any data type.
29.What is the get() method in dictionaries?
o Answer: The get() method returns the value associated with a key,
and allows you to provide a default value if the key is not present.
30.How do you handle exceptions in Python?
o Answer: Python uses try-except blocks to handle exceptions. You
can optionally add else for code that runs if no exception occurs,
and finally for code that always runs:
o try:# code that may raise an exception
o except ExceptionType:
o # code to handle the exception
o else:
o # runs if no exception
o finally:
o # always runs
31.What are custom exceptions in Python?
o Answer: Custom exceptions are user-defined exceptions that
inherit from Python's base Exception class. You can create them to
handle specific error cases in your application.
32.What is a generator in Python?
o Answer: A generator is a special type of iterable that yields values
one at a time. It uses the yield keyword instead of return to produce
values lazily, i.e., when they are needed.
33.What is the difference between yield and return in Python?
o Answer: yield produces a value without exiting the function,
allowing it to be called again later, while return exits the function
and returns a value.
34.What is the map() function in Python?
o Answer: map() applies a given function to each item of an iterable
(e.g., list) and returns a map object (which can be converted to a
list or other data structures).
35.What is the filter() function?
o Answer: filter() applies a function to an iterable, returning only
those elements for which the function returns True.
36.What is the difference between map() and filter()?
o Answer: map() applies a function to all items in an iterable, while
filter() applies a function to an iterable but only returns items that
satisfy a condition.
37.What is reduce() in Python, and how does it work?
o Answer: reduce() is a function in the functools module that
repeatedly applies a binary function (a function that takes two
arguments) to the items of an iterable, reducing it to a single value.
38.What is the purpose of the with statement in Python?
o Answer: The with statement ensures that resources are properly
acquired and released, particularly when working with files. It is
used to wrap the execution of a block of code within methods
defined by a context manager.
39.What is a context manager?
o Answer: A context manager defines methods __enter__() and
__exit__() that allow for resource management, often used in
conjunction with the with statement.
40.What is the global keyword in Python?
o Answer: The global keyword is used to declare that a variable
inside a function is global (i.e., it refers to a variable defined
outside the function).
41.What is the nonlocal keyword in Python?
o Answer: nonlocal is used to refer to variables in an outer function’s
scope (but not the global scope) when working with nested
functions.
42.What is the difference between a shallow copy and a deep copy in
Python?
o Answer: A shallow copy creates a new object, but inserts
references into it from the original object. A deep copy creates a
completely independent copy of the original object and its nested
objects.
43.How do you create a shallow copy and a deep copy in Python?
o Answer: Use the copy() method for shallow copies, and
copy.deepcopy() from the copy module for deep copies.
44.What are *args and **kwargs in Python?
o Answer: *args allows a function to accept any number of positional
arguments, while **kwargs allows a function to accept any number
of keyword arguments.
45.What is the difference between range() and xrange() in Python 2?
o Answer: In Python 2, range() returns a list, while xrange() returns
an iterator that generates values on demand (more memory
efficient). In Python 3, range() behaves like xrange().
46.What is a class in Python?
o Answer: A class is a blueprint for creating objects, defining
attributes and methods that the objects (instances) will have.
47.What is the difference between a class and an instance in Python?
o Answer: A class is the blueprint for creating objects, while an
instance is an actual object created from that class.
48.What is the super() function in Python?
o Answer: super() allows you to call methods from a parent or
sibling class within a child class, useful for extending inherited
methods.
49.What is the difference between staticmethod() and classmethod()?
o Answer: staticmethod() is bound to the class and not the instance,
meaning it cannot access or modify class or instance state.
classmethod() is bound to the class and can access the class itself
as the first argument.
50.What are magic methods in Python?
o Answer: Magic methods (or dunder methods) are special methods
in Python that start and end with double underscores, such as
__init__, __str__, __len__, and __repr__. They enable custom
behavior for operators and built-in functions
DevoPS
1. What is DevOps?
o Answer: DevOps is a set of practices that combines software
development (Dev) and IT operations (Ops) to shorten the
development life cycle and deliver high-quality software
continuously.
2. What are the key benefits of DevOps?
o Answer: Benefits include faster time to market, improved
collaboration, increased automation, continuous delivery, enhanced
quality, and better reliability.
3. What is Continuous Integration (CI)?
o Answer: CI is a development practice where developers integrate
code into a shared repository frequently, with each integration
automatically tested to detect issues early.
4. What is Continuous Delivery (CD)?
o Answer: CD is an approach where software changes are
automatically built, tested, and prepared for release to production,
ensuring that the software is always in a deployable state.
5. What is the difference between Continuous Deployment and
Continuous Delivery?
o Answer: In Continuous Deployment, every change that passes
automated tests is deployed to production automatically, while in
Continuous Delivery, the deployment is ready but requires manual
approval.
6. What is Infrastructure as Code (IaC)?
o Answer: IaC is the practice of managing and provisioning
computing infrastructure using code and automation tools instead
of manual processes.
7. What are some common DevOps tools?
o Answer: Common DevOps tools include:
CI/CD tools: Jenkins, Travis CI, CircleCI
Configuration management: Ansible, Puppet, Chef
Containerization: Docker, Kubernetes
Monitoring: Nagios, Prometheus, Grafana
8. What is version control, and why is it important in DevOps?
o Answer: Version control is a system that records changes to files
over time. It is important in DevOps for collaboration, tracking
changes, and enabling CI/CD practices.
9. What is Git?
o Answer: Git is a distributed version control system used to track
changes in source code, allowing multiple developers to
collaborate on a project.
10.What is Jenkins, and why is it used in DevOps?
o Answer: Jenkins is an open-source automation server used for
CI/CD pipelines. It helps automate the building, testing, and
deployment of applications.
11.What is Docker?
o Answer: Docker is a platform that enables the creation,
deployment, and management of lightweight, portable containers
that run applications in isolation.
12.What is Kubernetes?
o Answer: Kubernetes is an open-source container orchestration
platform that automates the deployment, scaling, and management
of containerized applications.
13.What are microservices?
o Answer: Microservices are an architectural style where
applications are built as a collection of loosely coupled,
independently deployable services that communicate via APIs.
14.What is the purpose of configuration management in DevOps?
o Answer: Configuration management ensures that the system’s
environment and resources are maintained in a consistent state,
using automation tools like Ansible, Puppet, or Chef.
15.What is a CI/CD pipeline?
o Answer: A CI/CD pipeline automates the process of integrating,
testing, and delivering code. It typically involves stages such as
build, test, and deploy.
16.What is Ansible, and how does it differ from Puppet?
o Answer: Ansible is an open-source automation tool used for
configuration management, application deployment, and task
automation. Unlike Puppet, Ansible is agentless and uses SSH for
communication.
17.What is the role of automation in DevOps?
o Answer: Automation in DevOps ensures that repetitive tasks such
as testing, deployment, and monitoring are performed consistently
and efficiently, reducing human errors and increasing speed.
18.What is a container, and how is it different from a virtual machine
(VM)?
o Answer: Containers virtualize the operating system and run
applications in isolated user spaces. Unlike VMs, containers share
the host OS kernel and are more lightweight.
19.What is the purpose of monitoring in DevOps?
o Answer: Monitoring helps track the performance and health of
applications and infrastructure in real-time, ensuring that issues are
detected and addressed before they affect users.
20.What are some popular monitoring tools in DevOps?
o Answer: Popular monitoring tools include Prometheus, Nagios,
Grafana, Datadog, and Zabbix.
21.What is a blue-green deployment?
o Answer: Blue-green deployment is a technique where two
identical environments (blue and green) are used. One (blue) serves
production traffic while the other (green) is idle or used for testing.
Once the new version is verified on green, the traffic is switched
over.
22.What is a canary release?
o Answer: A canary release is a deployment strategy where a small
percentage of users receive the new version of an application
before a full rollout, ensuring the new version works as expected.
23.What is rollback in DevOps?
o Answer: Rollback is the process of reverting to a previous stable
version of an application if an issue arises in the current
deployment.
24.What is the importance of logging in DevOps?
o Answer: Logging captures detailed information about an
application’s behavior, helping diagnose problems, improve
performance, and monitor security in production environments.
25.What are feature toggles in DevOps?
o Answer: Feature toggles (or feature flags) allow developers to
enable or disable features in production without deploying new
code, enabling safe experimentation and gradual feature rollouts.
37.What is DevSecOps?
Answer: A reverse proxy is a server that sits between client requests and
backend servers, forwarding client requests to the appropriate service. It
is often used for load balancing, caching, and SSL termination.
44.How does Ansible differ from Terraform?
59.What are sidecar containers, and how are they used in Kubernetes?
Answer: A sidecar container is a secondary container that runs alongside
the main container in a pod, typically used to handle logging, monitoring,
or networking functions without modifying the main application.
61.What is GitOps?
DoCker
Basic Docker Questions (1–25)
1. What is Docker?
o Answer: Docker is an open-source platform that automates the
deployment, scaling, and management of applications using
containerization. It allows developers to package applications and
their dependencies into containers that can run consistently across
different environments.
2. What is a container?
o Answer: A container is a lightweight, standalone, and executable
package that includes everything needed to run a piece of software,
including the code, runtime, libraries, and system tools.
3. What is the difference between a container and a virtual machine
(VM)?
o Answer: Containers share the host operating system kernel and are
lightweight, while VMs run a full operating system and hypervisor,
which makes them heavier and more resource-intensive.
4. What is a Docker image?
o Answer: A Docker image is a read-only template used to create
containers. It contains the application code, libraries, environment
variables, and configuration files.
5. How do you create a Docker image?
o Answer: You create a Docker image using a Dockerfile, which
contains a set of instructions for building the image. The command
docker build is used to build the image from the Dockerfile.
6. What is a Dockerfile?
o Answer: A Dockerfile is a text file that contains a series of
instructions for Docker to build an image. It defines the base
image, application files, environment variables, and commands to
run.
7. What command is used to run a Docker container?
o Answer: The command docker run is used to create and start a
container from a Docker image.
8. What is the purpose of the Docker Hub?
o Answer: Docker Hub is a cloud-based registry service for sharing
and managing Docker images. It allows users to store, distribute,
and collaborate on images.
9. How do you list all Docker images on your system?
o Answer: You can list all Docker images using the command
docker images or docker image ls.
10.What is the purpose of the docker-compose tool?
o Answer: docker-compose is a tool for defining and running multi-
container Docker applications. It uses a docker-compose.yml file to
configure application services, networks, and volumes.
11.What is a volume in Docker?
o Answer: A volume is a persistent storage mechanism for Docker
containers that allows data to be stored and managed outside of the
container’s filesystem, making it available even after the container
is removed.
12.What is the difference between a bind mount and a volume?
o Answer: A bind mount links a specific directory on the host
machine to a container, while a volume is managed by Docker and
resides in Docker’s storage area, providing more flexibility and
features like backup and sharing.
13.How do you stop a running Docker container?
o Answer: You can stop a running Docker container using the
command docker stop <container_id_or_name>.
14.What is the purpose of the docker exec command?
o Answer: The docker exec command is used to run a command in a
running container, allowing you to interact with the container’s
environment.
15.What is Docker networking?
o Answer: Docker networking allows containers to communicate
with each other and with external systems. Docker provides several
networking modes, such as bridge, host, and overlay.
16.What is the bridge network in Docker?
o Answer: The bridge network is the default network created by
Docker for containers. It allows containers to communicate with
each other on the same host and isolates them from the host
network.
17.How do you remove a Docker container?
o Answer: You can remove a stopped Docker container using the
command docker rm <container_id_or_name>.
18.What is the purpose of the docker logs command?
o Answer: The docker logs command is used to retrieve the logs
generated by a specific container, helping you troubleshoot issues
or monitor application behavior.
19.How do you view the processes running inside a container?
o Answer: You can view the processes running inside a container
using the command docker top <container_id_or_name>.
20.What is Docker Swarm?
o Answer: Docker Swarm is Docker’s native clustering and
orchestration tool that allows you to manage a cluster of Docker
engines, enabling deployment and scaling of services across
multiple Docker hosts.
21.What is a Docker registry?
o Answer: A Docker registry is a storage system for Docker images.
Docker Hub is a public registry, while you can also create private
registries using tools like Docker Registry or other cloud services.
22.What is the docker pull command used for?
o Answer: The docker pull command is used to download a Docker
image from a registry (e.g., Docker Hub) to your local machine.
23.What is the docker push command used for?
o Answer: The docker push command is used to upload a local
Docker image to a remote registry, making it available for others to
use.
24.How do you check the version of Docker installed?
o Answer: You can check the version of Docker installed on your
system using the command docker --version.
25.What is a Docker context?
o Answer: A Docker context is a mechanism for managing different
Docker environments, allowing users to switch between different
Docker daemon configurations easily.
kuberneteS
1. What is Kubernetes?
o Answer: Kubernetes is an open-source container orchestration
platform that automates the deployment, scaling, and management
of containerized applications.
2. What are Pods in Kubernetes?
o Answer: A Pod is the smallest deployable unit in Kubernetes,
which can contain one or more containers that share the same
network namespace and storage.
3. What is a Node in Kubernetes?
o Answer: A Node is a worker machine in Kubernetes that runs one
or more Pods. Nodes can be physical or virtual machines.
4. What is a Cluster in Kubernetes?
o Answer: A Cluster is a set of Nodes that run containerized
applications managed by Kubernetes, which includes a master node
and worker nodes.
5. What is a Deployment in Kubernetes?
o Answer: A Deployment is a Kubernetes resource that manages the
deployment of Pods, providing features like scaling, updating, and
rolling back applications.
6. What is a Service in Kubernetes?
o Answer: A Service is an abstraction that defines a logical set of
Pods and a policy to access them, typically through a stable IP
address or DNS name.
7. What are Labels and Selectors in Kubernetes?
o Answer: Labels are key-value pairs assigned to Kubernetes objects
(like Pods) to organize and identify them. Selectors are queries that
select objects based on these labels.
8. What is a ReplicaSet in Kubernetes?
o Answer: A ReplicaSet ensures that a specified number of Pod
replicas are running at any given time, maintaining availability and
scaling.
9. What is a Namespace in Kubernetes?
o Answer: A Namespace is a virtual cluster within a Kubernetes
cluster, allowing for resource separation and management in multi-
tenant environments.
10.What is the Kubernetes API?
o Answer: The Kubernetes API is the primary interface for
interacting with the Kubernetes control plane, allowing users to
create, update, and manage Kubernetes resources.
11.What is a ConfigMap in Kubernetes?
o Answer: A ConfigMap is a Kubernetes resource that allows you to
store non-confidential configuration data in key-value pairs, which
can be consumed by Pods.
12.What is a Secret in Kubernetes?
o Answer: A Secret is a Kubernetes resource used to store sensitive
information, such as passwords and tokens, in a secure manner.
13.What is a StatefulSet in Kubernetes?
o Answer: A StatefulSet is a Kubernetes resource for managing
stateful applications, providing stable identities, persistent storage,
and ordered deployment and scaling.
14.What is Helm in Kubernetes?
o Answer: Helm is a package manager for Kubernetes that simplifies
the deployment and management of applications by using Helm
charts, which are collections of Kubernetes manifests.
15.What is a DaemonSet in Kubernetes?
o Answer: A DaemonSet ensures that a copy of a Pod runs on all (or
a subset of) Nodes, useful for background tasks such as logging
and monitoring.
16.What are Volumes in Kubernetes?
o Answer: Volumes are storage resources in Kubernetes that can be
shared among Pods, providing persistent storage that survives Pod
restarts.
17.What is a Job in Kubernetes?
o Answer: A Job is a Kubernetes resource that manages the
execution of one or more Pods to completion, ensuring that the
specified number of Pods successfully terminate.
18.What is a CronJob in Kubernetes?
o Answer: A CronJob is a scheduled Job that runs periodically at
specified times, similar to the Unix cron service.
19.What is Ingress in Kubernetes?
o Answer: Ingress is a Kubernetes resource that manages external
access to services, providing routing rules based on the URL or
host.
20.What is a LoadBalancer service type in Kubernetes?
o Answer: The LoadBalancer service type provisions a cloud
provider’s load balancer, exposing the service to the external world
with a stable IP address.
21.What is a PersistentVolume (PV) in Kubernetes?
o Answer: A PersistentVolume is a storage resource in Kubernetes
that provides an abstraction for managing storage independently of
Pods.
22.What is a PersistentVolumeClaim (PVC) in Kubernetes?
o Answer: A PersistentVolumeClaim is a request for storage by a
user, specifying size and access modes, and is bound to a
PersistentVolume.
23.What are Resource Requests and Limits in Kubernetes?
o Answer: Resource Requests define the minimum CPU and
memory required for a Pod, while Limits define the maximum
resources a Pod can consume.
24.What is a NodePort service type in Kubernetes?
o Answer: The NodePort service type exposes a service on a static
port on each Node’s IP address, allowing external traffic to access
the service.
25.What is kubectl?
o Answer: kubectl is the command-line tool for interacting with the
Kubernetes API, allowing users to deploy applications, inspect
resources, and manage clusters.
Linux
1. What is Linux?
o Answer: Linux is an open-source operating system kernel that
serves as the foundation for various operating systems, collectively
known as Linux distributions.
2. What is a Linux distribution (distro)?
o Answer: A Linux distribution is a packaged version of the Linux
operating system, which includes the Linux kernel, system utilities,
libraries, and application software. Examples include Ubuntu,
CentOS, and Fedora.
3. What are the key components of a Linux system?
o Answer: Key components include the kernel, shell, system
libraries, and utilities.
4. What is the Linux kernel?
o Answer: The Linux kernel is the core part of the operating system
that manages hardware resources, processes, memory, and system
calls.
5. What is a shell in Linux?
o Answer: A shell is a command-line interface that allows users to
interact with the operating system by executing commands.
Common shells include Bash, Zsh, and Ksh.
6. How do you check the current working directory in Linux?
o Answer: You can use the pwd (print working directory) command
to display the current directory.
7. What are file permissions in Linux?
o Answer: File permissions control access to files and directories,
defined for the owner, group, and others. They include read (r),
write (w), and execute (x) permissions.
8. How do you change file permissions in Linux?
o Answer: Use the chmod command followed by the permission
settings and the file name. For example, chmod 755 file.txt.
9. What is the difference between absolute and relative paths?
o Answer: An absolute path specifies the complete path from the
root directory, while a relative path specifies the path relative to the
current directory.
10.How do you list files in a directory in Linux?
o Answer: You can use the ls command to list files and directories.
Options like -l for detailed view and -a for hidden files can be
added.
11.What is the purpose of the man command?
o Answer: The man command displays the manual pages for
commands, providing information on usage, options, and
examples.
12.How do you create a new directory in Linux?
o Answer: Use the mkdir command followed by the directory name.
For example, mkdir new_directory.
13.How do you copy files in Linux?
o Answer: Use the cp command. For example, cp source.txt
destination.txt copies a file from the source to the destination.
14.How do you move or rename files in Linux?
o Answer: Use the mv command. For example, mv oldname.txt
newname.txt renames a file, and mv file.txt /path/to/destination/
moves it.
15.What is a symbolic link in Linux?
o Answer: A symbolic link (symlink) is a special type of file that
acts as a reference to another file or directory, allowing for easier
access.
16.What command is used to view the contents of a file?
o Answer: You can use commands like cat, less, or more to view file
contents. For example, cat file.txt.
17.How do you search for a specific file in Linux?
o Answer: Use the find command to search for files. For example,
find /path/to/search -name "filename.txt".
18.What is a process in Linux?
o Answer: A process is an instance of a running program, which
includes the program code, current activity, and allocated
resources.
19.How do you check the running processes in Linux?
o Answer: Use the ps command to display currently running
processes. ps aux shows detailed information about all processes.
20.What is the top command used for?
o Answer: The top command displays real-time information about
system processes, including CPU and memory usage.
21.What is a package manager in Linux?
o Answer: A package manager is a tool used to install, update, and
manage software packages on a Linux system. Examples include
apt for Debian-based distros and yum for Red Hat-based distros.
22.How do you install a package using the package manager?
o Answer: Use the command specific to your package manager. For
example, sudo apt install package-name for Debian-based systems
or sudo yum install package-name for Red Hat-based systems.
23.What is a shell script?
o Answer: A shell script is a file containing a series of commands
that the shell can execute, used to automate tasks.
24.How do you execute a shell script?
o Answer: You can execute a shell script by using ./script.sh after
ensuring it has executable permissions (chmod +x script.sh).
25.What is the purpose of the grep command?
o Answer: The grep command searches for specific patterns within
files and outputs matching lines. For example, grep "pattern"
file.txt.
SqL
1. What is SQL?
o Answer: SQL (Structured Query Language) is a standard
programming language used to manage and manipulate relational
databases.
2. What are the different types of SQL statements?
o Answer: SQL statements are categorized into five types: DDL
(Data Definition Language), DML (Data Manipulation Language),
DCL (Data Control Language), TCL (Transaction Control
Language), and SQL queries.
3. What is a primary key?
o Answer: A primary key is a unique identifier for a record in a
database table, ensuring that no two records have the same key
value.
4. What is a foreign key?
o Answer: A foreign key is a field in one table that links to the
primary key of another table, establishing a relationship between
the two tables.
5. What is a SQL SELECT statement?
o Answer: The SQL SELECT statement is used to query data from a
database, allowing you to specify which columns to retrieve and
from which table.
6. How do you filter records in SQL?
o Answer: You can filter records using the WHERE clause in a
SELECT statement. For example: SELECT * FROM table_name
WHERE condition;.
7. What is the purpose of the GROUP BY clause?
o Answer: The GROUP BY clause groups rows that have the same
values in specified columns into aggregate data, often used with
functions like COUNT, SUM, AVG, etc.
8. What are aggregate functions in SQL?
o Answer: Aggregate functions perform calculations on a set of
values and return a single value. Examples include COUNT(),
SUM(), AVG(), MAX(), and MIN().
9. How do you sort the results of a query?
o Answer: You can sort the results using the ORDER BY clause.
For example: SELECT * FROM table_name ORDER BY
column_name ASC|DESC;.
10.What is the difference between INNER JOIN and LEFT JOIN?
o Answer: INNER JOIN returns records with matching values in
both tables, while LEFT JOIN returns all records from the left table
and matched records from the right table, with NULLs for non-
matching rows.
11.What is a subquery?
o Answer: A subquery is a nested query inside another SQL query,
used to retrieve data that will be used in the main query.
12.What is a view in SQL?
o Answer: A view is a virtual table based on the result set of a
SELECT query. It can simplify complex queries and enhance
security by restricting access to specific data.
13.How do you create a table in SQL?
o Answer: You can create a table using the CREATE TABLE
statement, specifying the table name and columns. For example:
o CREATE TABLE table_name ( column1 datatype, column2
datatype,);
14.What is normalization?
o Answer: Normalization is the process of organizing data in a
database to minimize redundancy and improve data integrity, often
through a series of normal forms (1NF, 2NF, 3NF, etc.).
15.What is denormalization?
o Answer: Denormalization is the process of intentionally
introducing redundancy into a database to improve read
performance, often at the expense of write performance.
16.What are SQL constraints?
o Answer: SQL constraints are rules applied to table columns to
ensure data integrity, such as NOT NULL, UNIQUE, PRIMARY
KEY, FOREIGN KEY, and CHECK.
17.How do you update records in SQL?
o Answer: You can update records using the UPDATE statement.
For example:UPDATE table_name SET column1 = value1
WHERE condition;
18.What is the purpose of the DELETE statement?
o Answer: The DELETE statement removes records from a table
based on a specified condition. For example:DELETE FROM
table_name WHERE condition;
19.What is an index in SQL?
o Answer: An index is a database object that improves the speed of
data retrieval operations on a database table by providing quick
access to rows.
20.How do you create an index in SQL?
o Answer: You can create an index using the CREATE INDEX
statement. For example:CREATE INDEX index_name ON
table_name(column_name);
21.What is a transaction in SQL?
o Answer: A transaction is a sequence of one or more SQL
operations that are treated as a single unit of work, ensuring that all
operations are completed successfully or none at all.
22.What are ACID properties?
o Answer: ACID properties (Atomicity, Consistency, Isolation,
Durability) ensure that database transactions are processed reliably.
23.How do you rollback a transaction in SQL?
o Answer: You can rollback a transaction using the ROLLBACK
statement, which undoes all operations since the last COMMIT.
24.What is the purpose of the COMMIT statement?
o Answer: The COMMIT statement saves all changes made during
the current transaction to the database.
25.How do you retrieve unique records in SQL?
o Answer: You can retrieve unique records using the DISTINCT
keyword in a SELECT statement. For example:SELECT
DISTINCT column_name FROM table_name;