Linux_for_DevOps
Devops Engineer
Date: 5 Feb 2023
In the class, we go through the fundamental linux commands, permissions, ssh protocol, directory structure, and the Git version control system.
Explain layers of the Linux Operating System?
Linux Layers:
Mainly There are 3 layers of linux os
Hardware→Kernel→Shell→Application (HKSA)
Explain Directory Structure if Linux Operating System?
Directory Structure:
Beginning with the root directory "/," the directory structure in Linux is hierarchical and resembles a tree. In the Linux directory structure, the following are a few of the major directories:
/bin: Contains essential user binaries (commands), such as ls, cp, and mv.
/boot: This directory houses files necessary for the boot process, including the kernel and boot loader.
/dev: It contains device files for hardware devices attached to the system.
/etc: Contains system configuration files, such as user accounts,network settings & system services.
/home: Contains user home directories.
/lib: Contains shared libraries required by programs in /bin and /sbin.
/mnt: Used for Mounting external systems,such as USB drives and network shares.
/opt: Contains optional software packages installed on the system.
/proc: Contains virtual files that provide imfo about system resources and running processes.
/root: The home directory of the root user.
/sbin: Contains system binaries (commands) used for system administration tasks.
/tmp: Used for temporary files.
/usr: Contains user-releted programs and data, including user binaries, libraries, and documentation.
/var: Contains variable files, such as log files and spool (Software) directories for printing and mail.
What are Linux File Permissions?
Read - 4 (r)
Write - 2 (w)
Execute - 1 (x)
Root [ File 644, Directory 775 ]
Limited User [ File 664, Directory 775 ]
What are editors in Linux?
Vim Editor :
Primarily there are two modes in Vim Editor
Edit Mode
Command Mode
Some Useful Commands for Vim: (Command Mode)
“i” - insert mode
“:wq” - save & quit
“q!” - force quit without save
“dd” - to delete the line
“yy” - to copy the line
“:se nu” - to add serial number into the file
“Shift g” - take us to the last line of file
“%s/word/new_word/g” - To replace the word with new_word
“o” - Create new para from existing line
“gg” - take us to 1st para
“u” - undo text
“ctrl r” - redo text
“d gg” - all delete above
“d shift g” - all delete below
“:gf” - to go to path ( b1 to return)
How to ssh/access server or instance from Windows/Linux?
- From Windows:
Download and install PuTTY from the official website: https://www.putty.org/ & Open PuTTY.
In the "Session" category, enter the hostname or IP address of the remote server you want to connect to in the "Host Name (or IP address)" field.
Ensure that the "Connection type" is set to "SSH".
If you want to save this session for future use, enter a name in the "Saved Sessions" field and click the "Save" button.
In the "Connection" category, expand the "SSH" category and click "Auth".
Click the "Browse" button next to the "Private key file for authentication" field and select the private key file for the server you want to connect to.
In the "Session" category, enter a name for the saved session in the "Saved Sessions" field and click the "Save" button.
Click the "Open" button to connect to the remote server using SSH.
Note: ppk→Putty Private Key, .pem→ Privacy Enhanced Mail
Convert using PuttyGEN which comes with Putty
For more info use https://youtu.be/bi7ow5NGC-U.
- From Linux: (Ubuntu 22.04 LTS)
Create an EC2 instance on AWS
Save the key.ppk
Copy the Public IP and username of OS (eg. for ubuntu→ ubuntu and for CentOS→ec2-user)
Go to terminal type ssh -i key_name.ppk username@IP(Public IP)
Click on yes→ Done
What is Centralized Version Control System (CVCS) and Distributed Version Control System (DVCS)?
Centralized Version Control System (CVCN):
Centralized version control systems (CVCS) have a single, centralized repository that contains all versions of a project's files.
Developers checkout files from the central repository, make changes, and then commit those changes back to the central repository.
Distributed Version Control System (DVCS):
Distributed version control systems (DVCS) allow each developer to have a local copy of the entire repository, including all versions of all files.
Developers can work independently and make changes to their local copy, without the need for constant connectivity to a central server.
Changes can be shared between repositories, allowing for easy collaboration and integration.
What is DevOps?
DevOps is a set of practices that combines software development (Dev) and IT operations (Ops) to facilitate the rapid and efficient delivery of software applications and services.
It emphasizes collaboration, automation, and continuous improvement across the entire software development life cycle.
Process is as follows: (with tools)--> (PCBTDOM)
Plan
Code→Git,Jira,eclipse
Build→Maven, Gradle
Test→Jenkins
Deploy→Chef,Ansible
Operate→Docker
Monitoring→Splunk