0% found this document useful (0 votes)
15 views4 pages

DevOps Scripting SQL CheatSheet

This document is a cheat sheet for freshers covering essential DevOps scripting and SQL basics. It includes examples of Bash, Python, and PowerShell scripting for file operations, automation, and AWS integration using Boto3. Additionally, it provides fundamental SQL commands for creating, inserting, selecting, updating, and deleting data in a database.

Uploaded by

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

DevOps Scripting SQL CheatSheet

This document is a cheat sheet for freshers covering essential DevOps scripting and SQL basics. It includes examples of Bash, Python, and PowerShell scripting for file operations, automation, and AWS integration using Boto3. Additionally, it provides fundamental SQL commands for creating, inserting, selecting, updating, and deleting data in a database.

Uploaded by

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

DevOps + Scripting + SQL Cheat Sheet for Freshers

Bash Scripting Basics

# For loop

for i in 1 2 3

do

echo "Number $i"

done

# If-else

if [ -f "file.txt" ]; then

echo "File exists"

else

echo "File not found"

fi

# File Operations

touch file.txt # Create file

echo "Hello" > file.txt # Write to file

cat file.txt # Show file content

rm file.txt # Delete file

# Automation Scripts

# Backup

cp /var/log/syslog /backup/syslog-$(date +%F).log

# Start/Stop Services

sudo systemctl start nginx

sudo systemctl stop nginx

Python Scripting for DevOps


DevOps + Scripting + SQL Cheat Sheet for Freshers

# Loop and condition

for i in range(1, 4):

print(f"Number {i}")

import os

if os.path.exists("file.txt"):

print("File exists")

# File operations

with open("file.txt", "w") as f:

f.write("Hello")

print(open("file.txt").read())

os.remove("file.txt")

Python + Boto3 for AWS

# Upload file to S3

import boto3

s3 = boto3.client('s3')

s3.upload_file('file.txt', 'your-bucket', 'file.txt')

# Launch EC2 instance

ec2 = boto3.resource('ec2')

ec2.create_instances(

ImageId='ami-0abcdef1234567890',

MinCount=1, MaxCount=1,

InstanceType='t2.micro',

KeyName='your-key'

)
DevOps + Scripting + SQL Cheat Sheet for Freshers

# List EC2 instances

ec2 = boto3.client('ec2')

for res in ec2.describe_instances()['Reservations']:

for inst in res['Instances']:

print(inst['InstanceId'], inst['State']['Name'])

PowerShell Basics

# Loop

foreach ($i in 1..3) { Write-Output "Number $i" }

# If-else

if (Test-Path "file.txt") {

Write-Output "File exists"

} else {

Write-Output "File not found"

# File operations

New-Item file.txt # Create file

Set-Content file.txt "Hi" # Write to file

Get-Content file.txt # Read file

Remove-Item file.txt # Delete file

SQL Basics for DevOps Interviews

-- Create Table

CREATE TABLE employees (

id INT PRIMARY KEY,

name VARCHAR(50),
DevOps + Scripting + SQL Cheat Sheet for Freshers

department VARCHAR(50)

);

-- Insert Data

INSERT INTO employees (id, name, department) VALUES (1, 'Geena', 'IT');

-- Select Data

SELECT * FROM employees;

SELECT name FROM employees WHERE department = 'IT';

-- Update Data

UPDATE employees SET department = 'HR' WHERE id = 1;

-- Delete Data

DELETE FROM employees WHERE id = 1;

You might also like