1: DevOps Prerequisite course Flashcards
What is a LAMP stack application?
Linux, Apache, MySQL, PHP. You can substitute some of those though.. my Nginx instead of apache, or python instead of PHP , for example.
What are the 4 steps of building and pushing an app to prod?
1: Develop -> GIT
2: Build : on build server complies/builds app
3: On test server: test app for bugs
4: move to prod server
What is the point of CI/CD? some common tools?
Helps automate the develop, build, test, deploy. Jenkins, Github actions, Gitlab CI/CD are examples. This can automate the entire process to allow bug fixes and such to happen faster.
What is the benefit of a docker file in the develop, build, test production pipeline?
A developer can configure a docker file to contain all of the application dependencies which ensures the entire pipeline has those dependencies available. “docker build” “docker run”
Kubernetes orchestrates the containers, what handles the underlying servers?
Terraform can configure servers regardless of what cloud platforms they are on. If someone changes a server config, teraform will changed it back! this is IaC. storage, networking, virtual machine, all of it in this code. terraform is used for provisioning infrastructure.
Where does ansbile come into there Kubernetes/terraform stack?
Kubernetes is for the contains. Terraform configures the underlying infrastructure. Ansible is automated tool to configure infrastructure once created. this code is also stored on github
Where does Prometheus/Grafana come into the kubernetes/terraform/ansible stack?
Prometheus collects and visualizes metrics. Grafana will visualize this data.
Linux command: echo $shell
This will show which shell is being used. /bin/bash should be the most common. that is the bash shell.
Linux command: echo Hi
This will write Hi to the screen
Linux command: ls
Used to list files in directory
Linux command: pwd
Used to display current path
Linux operator to run multiple commands on same line?
semi-colon : example: cd /home/my_dir; ls
linux cmd: md
Make directory
What is the linux command to create an entire directory tree for /mydir/mydir1/mydir2/mydir3
mkdir -p /mydir/mydir1/mydir2/mydir3
linux command to remove directory and all if its contents?
rm -r /mp/my_dir
linux command to copy a directory and all contents?
cp -r /temp/mydir1 /temp/mydir2
Linux command : touch myfile.txt
Creates an empty file, or updates the timestamp on an existing file
How do I add some text to a text file in linux?
cat > my_file.txt <enter> some test <control></control></enter>
How do I view a file in linux?
cat file.txt
How do I copy a file in linux?
cp source_file.txt destination_file.txt
How do I move a file in linux?
mv my_file.txt New_location.txt - this is also used to rename a file
How do I remove a file in linux?
rm my_file.txt
VI editor has two modes, what are they and describe
Command Mode: default mode, issue commands like copy and paste line or navigate, but cannot write contents.
Insert Mode: type “i” to enter insert mode to edit. escape key to exit back to command mode
basics VI command mode options:
- arrow keys to move around
- x : to delete a character
-dd : delete a line
-Copy and paste a line : yy then p
-Scroll page: ctrl+U or ctrl+D - :w - does a save file
- :w filename - save a file to a name
- :q = quit
- :qw = save and quit
- FIND : do a /mydata
- N: command to use for find next
linux command: whoami
Tells me my user
linux command: id
tells me current user, userid and groups
How do I change my logged in user?
su OtherUser
How do I SSH into a different system with a different name than currently logged into?
ssh username@host
linux command: curl http://www.site.com/file.txt -O
this will download a file. the -O specifies to save it to file otherwise it would just pipe to screen.
linux command wget http://www.site.com/file.txt -O MyFile.txt
downloads a file using -O to save it and a file after to give it name
Linux command: cat /etc/release
will display details about the OS
What is RPM?
Redhat Package Manager (runs on redhate therefor centos)
what are rpm switch -i -e -q ?
rpm -i telnet.rpm installs a package
rpm -e telnet.rpm removes a package
rpm -q telnet.rpm queries a package
Does RPM install prereqs? how about YUM?
No, if you install Ansible, it will not install the prereqs. this is where YUM comes into play. yum install ansible : will find and install prereqs and Ansible itself. YUM still uses RPM
How does YUM know where to find files?
This is stored in /etc/yum/repos.d . this contains a default list of repositories, but you may want to add repositories, so you would add it here. or remove.
command to view the list of yum repositories?
yum repolist to view repositories
ls /etc/yum/repos.d/ will list each file that represents a repository.
catting one of the files will show the URL to the repo
command: yum list
Lists installed yum packaged
command: yum remove ansible
remove ansible
command: yum –showduplicates list ansibles
Shows if there are duplicates available inside of the yum repos.
command: yum install -y ansible-2.4.2.0
the ansible-2.4.2.0 will specify which ansible to install when there are duplicates across repos.
command: RPM -qa
List all installed RPM packages can | grep also
how do I start and stop the httpd server?
New way: systemctl start httpd “system cuddle”
systemctl stop httpd
old way: service httpd start
How do I check a service status?
systemctl status httpd
how do I enable or disable a service to start at system startup?
systemctl enable httpd
systemctl disable httpd
How do I configure a python app to run as a service? for example my_app.py ? automatically start at startup and restart if crashes.
1: create a unit file in /etc/systemd/system - the file will be the name of the service.
2: in my_app.service file insert the following
[Service]
ExecStart=/user/bin/pyton3 /opt/code/my_app.py
3: systemctl daemon-reload (have systemD reread the files)
4: systemctl start my_app
5: systemctl status my_app : to check the service
6: systemctl stop my_app to stop
7: to have it start with the system you edit the unit file and add a section. this will have it run during boot up after everything else has status
[Install]
WantedBy=multi-user.target
8:you can also add:
[Unit]
description=My service description
9: to have application automatically restart under [service] write
Restart=always
Linux CMD: ip link
provides basic network information for all ETH adapters.
What command do you use to assign an IP address to a network adapter “eth0” in linux?
ip address add 192.168.1.10/24 dev eth 0 - note persistent across restart /etc/network/inerfaces for persistent
What is the linux command to view the local route table?
Route
What is the command to add a route in linux?
ip route add 192.168.2.0/24 via 192.168.1.1
Linux : how do I assign the default gateway as 192.168.2.1?
ip route add default via 192.168.2.1
Also could : ip route add 0.0.0.0 via 192.168.2.1
If I have a linux host behaving as a router, how do I enable packet forwarding?
must modify /proc/sys/net/ipv4/ip_forward and set the contents from 0 to 1. “echo 1 > /proc/sys/net/ipv4/ip_forward”. This will not maintain after reboot, to make it stay after reboot you must do the same change to the /etc/sysctl.conf files and set net.ipv4.ip_forward to 1.
Linux DNS: How to I set a manual DNS entry for 192.168.1.11 as host DB
cat»_space; /etc/hosts
192.168.1.11. DB
Linux how do I assign a DNS server to a host?
cat /etc/resolv.conf
namerserver 192.168.1.100
Linux : How do I change If the local DNS or the DNS server should be checked first when resolving names?
cat /etc/nsswitch.conf
hosts : files dns
This means it will. check local first, swap if you want to check DNS server first.
Linux: How do I add a local DNS suffix for mycompany.com
cat»_space; /etc/resolv.conf
search mycompany.com
Linux commands: download, extract and check java version
wget https://download.java.net
tar -xvf VersionDownoads.tar.gz
idk(FromOutput)/bin/java -version
or
java -version
What is Java JDK?
Java Development Kit (JDK) when you install java you install a kit that helps you with develop -> build -> run. It comes with:
DEVELOP
jdb: debug
javadoc: document code
BUILD
Javac: compile
jar: archive code and library into single jar file
RUN
JRE : Java Runtime Environment
java: java command line utility or loader to run app
In java what is the summary for Develop - compile - run
Develop: write the code for MyClass.java
Complies : Javac MyClass.java
Run : java MyClass
In Java, what is JAR(Java Archive)? How about WAR(Web Archive)?
JAR combines all necessary class files and dependencies into a single distributiatble package.
WAR is specifically structured to be a web app
What is the command to create a JAR file for service1.class and service2.class
jar cf MyApp.jar service1.class service2.class
This will also create a META-INF/manifest.mf that will show the contents.
How of I run a JAR java app?
java -jar MyApp.jar
In Java how do add documentation to MyClass.java
javadoc -d doc MyClass.java
What are popular build tools for Java? give examples of what they do use ANT as an example
Maven, Gradle, ANT
The tools will automatically execute your compile, package, build process.
ANT for example:
MANUAL
Javac MyClass.java
javadoc MyClass.java
jar cf MyClass.jar
W/ ANT you cover to an XML ANT build file.
Once ANY XML is created run:
ant <enter></enter>
How do you install apache ant?
Sudo yum install -y ant
what is apache ant?
Apache Ant is a Java-based build tool that uses XML files to automate software build processes, such as compiling code and packaging JAR files. It’s often used for Java projects but has been mostly superseded by Maven and Gradle.
What is node.js?
Node.js is a runtime environment that allows you to run JavaScript code server-side. Built on the V8 JavaScript engine from Google, it’s commonly used for building web servers, APIs, and other networking applications. Node.js is known for its non-blocking, event-driven architecture, making it well-suited for scalable and real-time applications.
How do you install node.js?
Add the repository:
1: curl -sL https://rpm.nmodesource.com/setup_13.x | bash -
then install:
2: yum install nodejs
How do I identify the node.js version?
node -v
What is node.js NPM?
npm stands for Node Package Manager. It’s a package manager for JavaScript and is commonly used with Node.js. npm allows you to install libraries and packages to use in your projects, manage versions, and handle dependencies. It provides a large repository of open-source packages, making it easier to develop and distribute Node.js applications.
how can you tell the version of node.js NPM?
npm -v
unrelated to install npm package use : npm install MyPackage
Why is Python pip? how can I tell the version?
pip = Python Package Manager
pip3 -V or
pip2 -V or
pip -V
How do install python flask with pip?
pip install flask
bonus:
pip show flask - will show where flash installed
A large python app may require many packages to install. You could install all packages with pup one at a time, or:
or you can created a requirements.txt file and list all of the dependencies are run: pip install -r requirements.txt.
This is handy for making your application more portable.
What is a python .egg file in python?
This is a python package that is installed with the python easy_install command. so : easy_install install MyApp
What is a python wheels? .whl file?
It is a python package like .egg files. you install with : pip install app.whl
Overview of GIT start to finish:
0: Install : yum install git
1: init git repo: git init (inits an empty repo)
1.5: list files tracker: git status
2: config files to track: git file1.py file2.py file3.py….
3: Tracks changes: when file is changed git status shows which file is modified
4: stage the changed file: git add ChangedFile.py
4.5: all the other files were already staged, now the changed file is as well
4.6: basically the git add will add a file to the stage. when you change the file it upstages it.
5: commit changes: git commit -m “Initial commit”
Steps to submit to GitHub
1: set up local repo, and commit local
2: create GitHub repo on GitHub web ui
—-Transfer to remote repo
3: get remote add <RemoteRepoName> <urlProvideByGitHub> - this tells local repo remote is available.
4: push from local to remote: git push -u <remote> <branch(master by default></remote></urlProvideByGitHub></RemoteRepoName>
Steps to pull code down from github :
1: Clone the repot: get clone <url>
1.5: because it was cloned do not need to set-up remote, like someone original pushing
3: if there are remote changed, you can use "git pull"</url>
How do I install apache, start it, check it’s status?
yum install httpd
service httpd start
service httpd status
How do I view apache access and error logs?
cat /var/log/httpd/access_log
cat/vat/log/httpd/error_log
Where is the apache(httpd) config file?
/etc/httpd/conf/httpd.conf
What is the difference between apache web and Apache Tomcat?
Apache web = web server
Apache Tomcat = App server