# Linux End To End

# How Internet works

* Internet works through optical fibers cables indise the water they keep cables and attach with the data centers
    
* data transfer through cables , this cables are located in the sea.
    
* between user and cables -data center, a ISP will be there ,
    

what is server :

* a server hey uska kaam kya hey -kisi info ko server karna , server is just basically a computer to server client
    
* the server is to server the info
    
* client ka kaam hey request info to the server
    
* youtube.com ae aek domain hey , iskey against ek application server i mean application ka domain
    
* ek application server hoga jaha pey youtube chalra -is server ka kuch ip address hogi → aek domain aur ip address ko link karnekey liye ek DNS server rehtha hey
    
* facebook.com kultha hey - isp internet ka acess detha hey , oprical fiber data ko flow karathi hey - aur data center mey jo application chalra co aapkey mobile mey stream hotha rehtha hey
    

diff between web server and application server

* web server is nothing but jo b static code deploy kiye rehthey toh vo web servers , static data serve kartha hey
    
* application server bussiness logic data ko server kartha hey
    
* Types of applications
    
    * standalone apps - usko internet ki jaroorat nahi hothi —&gt; koi db ki jaroorat nahi rehthi - aap kabhi airport mey , how was your feedback , click kar diya chaldiya - usko bakhi cheez ka jaroorat nahi hey
        
    * if you have web application like instagram or youtube , youtube mey video streaming hora hey , Notifications jarey ae thab hotha hey aap standalone nahi aap ek group of applications chalare hey - iskey supporting mey app severs, db servers, email server
        
* isiliye ek devops engineer ko pata rehna hey ki vo kis cheez pey kaam karra
    
* agar stahndalone pey kaam karra hey usko db , ki bakhi connections ki jaruru nahi padegi
    
* agar ae web applications pey kaam karra hey isko db connction , frontend connection , backend connection , cloud ae sab dekhna
    

what is application support and maintainance

* ki jo hamare phone mey laptop mey application horey hey ae ssaarey applications kahi ek o.s mey chalre hothey hey
    
* vo applications sahi sey cha;re hey nahi , creash toh nahi horey , us appliocations ko support ki jaruri hey yah nahi dekhthey hey
    
* application chalra hey kabhi bhi connection issue aa ra hogey as a devops or linux admin kounsey server mey dikkath hey
    

ae applications linux pey chalthey hey , linux ae ky ahey cheez

* 90 percent key log windows chalathey hey 90 percent applications linux mey chalthey hey
    
* linux opensource hey , linux ko linus torvalds ney 1991 mey banaya tha , jissey jo basically koi antivirus ki jaruri nahi hey , security top notch hey , community hey , multi tasking hey , updates ki jaruri nahi ,
    
* linux use karthey hey majority companies linux pey hi chalrehey
    

ae jo unix and linux kya hey - unix basically ek o.s hey vo ek commercialised hey - unix ka prime example hey mac o.s

* same as liunux kaam sab linux hi hey .
    
* unix ka hi free version linux
    
* \\linux ko install kaisa karey - pehle tarika hey
    
    1\. wsl for linux
    
    2. virtual box
        
    3. azure / aws/gcp koi b cloud pey koi vm banakey use kar sakthey hey
        
    4. vagrant b hey - hashicorp ki company hey ussey aao linux use kar sakthey hey
        

Difference between linux and windows

* windows is a licence one
    
* linux is a gpl general public license
    
* linux mainly focus on development , networking , tyerminal , programming , scripting \\
    
* windows mey antivirus use karna , linux mey nahi
    
* widnows mey update pusthey hey , linu smey update ki jaruri nahi - ubuntu vala saal mey 2 baar update martha hey
    

softeare remote location server tools

* agar ae mey hu aur yaha mey mai ek dhoor rakhey huey server or vm ko connect karna chahtha hun
    
* * 1. remote desktop protocol
            
            2\. ssh - secure shell
            
            3\. anydesk
            
            4\. ultraviewer
            
* what is kernal , bootloader , shell
    

ki linux kya hotha hey , linux ek o.s hotha hey - har ek o.s ka dil rehtha hey - ud dil ko bolthey hey kernal \]

kernal basically purey o.s ko chalaney liye jo coding files , processors , program required hothi hey vo kernal key pass hothey hey

kernal ka founder linux - ab is kernal ka kuch kaam hotha hey processes chalana ae hotha hey

* ae c program mey likha hua kernal hey , humko c nahi aathi , hum kaisa chalaye , hum ko aek program chahiye is kernal ko bath karey thab aajatha hey shell
    
* * shell basically ek programm terminal hotah hhey jaha sey kernal ko bath kar pathey
        
        \* shell key commands rehthey hey , un commands ko use karkey shell commands sey hum bath karthey hey
        
        \* shell ek gateway hey aapko aur kernal key beech mey rehtha hey
        
        \* bootloader ky ahotha hey - aisa samajlo aap ka computer start hotha hey
        
        boot loader ek aesi proceesor hey jo o.s mey files rehthi hey kerma; mey rakhey huey process ko jagah detha hey - gnu - grub - - it helps to boot your entire system
        
        \* grand unified boot loader (grub)
        

aapkey center mey rehtah hey kernal - kernal key uppar shell - shell key uppar application utilities rehthey hey

shell kernal sey kernal - hardware sey bath kartha hey = kernal change karega hadrware ko

df -h - command jo b disk ka infro hey dikh jayega

* free -h = system memory usage ., ram usage check kartha hey
    
* cpu ka usage - Top command sey dekh sakthey hey
    

Linux file system kya hotah hey

* in lunux everything in system treated as files , everything starts from / - isko bolthey hey / root folder - iskey andar bohot saare folders rehthey hey
    

cd - change directory - ek directiory sey dueri directoey ko jana hey toh cd use kartha hun

cd / - ismey aapko bohot saarey folders dikhthey hey

linux harrek cheez ko segregate kartha hey - agar merey logs aaaye toh linux var mey store kartha hey

agar jithey mey b linux users hey - usr mey store kartha hey

toh linux mey harrek cheez file system sey based hey

#state of proceeses in linux : agar aapko cpu mey kya chalra hey ytoh top - aap dekh sakthey ehy kithey processes het , kithne chalre hey kithey sokey hey dekh sakthey hey

actually ae background mey process id sey run hothey hey

# linux commands ":

* date : date is used to see teh current time and date
    
* ls - list of files it shows cin current directory
    
* mkdir devops - it creates the directory
    
* ls -l - its hows the detaills of file or folders - permissions , owner of thr filr or dir , sixe, date and time and file/folder name - first character denotes teh file or dir
    
* pwd - is used to see hwere we are currently
    
* touch - is used to create a new file
    
* clear - it cl;ears the terminal
    
* cd - change directory - cuurent directory sey kisi aur directory ko jana hey
    
* cd .. - one directory back
    
* rmdir - deletes the empty directory
    
* rm - delete the files
    
* rm -rf folder - if folder has any files or subdirectories - recursively deleted
    
* cat - file ko dekhna hey toh cat use kartha hey
    
    * agar file mey kuch print karna hey “ echo “ hello world” &gt; demofile.txt
        
    * redirect karne | echo "“how are u “ » demofile.txt
        

zcat : agar aapki koi zip file hey compressed file hey vo compressed file ko dekhna hey contents ko dekhney zcat use karthey

head : first 10 lines dekhna hey file key head use karthey hey

tail - nichey key 10 liens dekhne use karthey hey

tail -n number filename

more and less aisa samaj lo aapkey pass badi file hey , agar file ka content ek page ,dusa page , i mean page by page screen dikhayega

it shows in pagenated way

cp : mujey ek file or folder ko kahi aur pey copy karna hey mujhey cp command use karna

* cp oldfilename newfile name - backupfile hojatha
    
* cp -r cloud/ devops/ - cloud folder ko devops name key folder mey copy kar diya
    

mv : mujhey copy nahi move karni hey file i will use mv command

* rename karni hey thabbi mv use karthey hey
    
* * mv oldname newname
        

wc: agar muhey ae file.txt mey kithey words , lines , characters / kithni storage ki hey bytes hey toh mai wc command use kar saktha hun

hardlink : dekho jab windows mey aapko game khelna hotah hey c mey rehtha tha aap hamesh thodi hi c mey jakey khelthey usko shortcut banathey hey dekstop mey

* links are shortcuts - hardllink ae aisa shortcut rehtha hey jaha pey agar aapka jo main vali file delete hogi bhi shortcut hey zinda rehtha hey
    
* softlink aisa hey agar main file dleet hogayi shortcut b delete hojathi
    
* * echo “hi “ &gt; devops.txt
        
        \* ln /home/ubuntu/cloud?devops/devops.txt hardlink-file
        
        \* ln -s /home/ubuntu/cloud/devops/devops.txt softlinkfile
        
        \* ls -ltr , toh agar orinal location mey content change hua toh softlink mey bhi change hojatha
        

cut = cut kya kartha hey jo file mey content hey like “ this is my file” - aisey 4 words hey lets say ek word 2 bytes ka hey

* cut -b 1 myfile.txt → cut -b 1-4 myfile.txt
    
* file mey sey chotasa portion chahiye cut karkey dey detha
    

tee - echo “ heloo” | tee - toh vo cheex screen pey b dikhayegi aur aapko file mey dalni hey vo file mey b dal dethi hey

* echo “heloo” | tee heloo.txt
    
* to take input and display the output on screen and also in file i have to send
    

sort : it allows to sort the order in alphabbetically

clear - clar the terminal

diff - mujhe do files mey kya diff hey dekhna hey

* diff demo.file hardlink.file
    

vim : vim ek editor jaisa hey edit karne key liye

ssh : merey pass ae linux instance hey ae kahi dhoor pey rakha hua instance hey agar muhey udhar thak paunchna hey through ssh sey

* remote server ko secure shell sey connect karna hey toh ssh use kar sakthey hey ssh ko kuch ports use karthey hey 22 ae enable rehna hey
    
* aap rahul aap anjali sey bath karreho , ab anjali aapsey thabhi bath karegi anjali ka numer aapkey pass hoga - anjalaki ka number private hey - anjali rahulko degi , rahul public name hey na toh rahul anjali ko pata hona like public key agar anjali key pass public key hoga toh ki connect hoga
    
* ssh -i pemfile username@[ipaddress](@ipaddress)
    
* aur putty b use kar sakthey hey , mobaxterm use kar sakthey hey
    

df : tumara system hey usmey kithna storage use hua kithna bacha hua hey dekhme key liye dekh sakthey hey

* ismey itney blocks hey ithney used hey ithney available hey
    
* storage key bharame dikhatha hey
    

du : disk utility - kisi particular folder or file ka sixe kithna use kiye dekhnekey liye use karthey hey

ps: processor ps batata hey ki particular command bash hey vo counsi processor pey chalra

top : total saare processor live mey batata hey

fuser : fuser vo ek particular file key liye ,

kill - kisi process ko kill karna hey kill use karthey hey

free : merey pass ithna ram ithna used , ithna available hey regarding ram dikhayega

nohup: generally applications mey use karthey hey - aek application mey loga aarey hey us loga ko kisi file mey store karna hey

* nohub free -h - ek file banadega nohup,out usmey iska output daldega
    
* agar mai chala unga nohub df -h
    
* pehla vala output aisa hi rahega aur dusra vala b aatha hi collect hotha hi hoga
    

vmstat - jo virtual memory rehthi hey aapki vo dikhadetha

* vmstat -a virtual memory mey ithna free hey ithna active inactive ram key bharame bata detha hey
    

# system level commands :

jabbi ek devops engineeer apna sysem open kartha hey usko system key bhaaremey jankari reha hey , kounlogged in kiya kkounsey user sey logged in hey , kounsa o.s hey kithne der sey chalra , last logged in kab hey

1. uname: aap kounsey platform mey linux chalare ho jaisey ubuntu - mujhey pata chaltah hey kounsa platform chalara hun pata chaltha hey
    
2. uptimr: aapka system kithni der sey chalra hey - last 10:41 up 9 min sey , load average - 1 user active hey
    
3. date : current date na dtime
    
4. who , whoami key dif
    
    * who - kounsey user ney loginkab login kiya tha , kithney users ae system ko logged in kiye hey
        
    * whoami - system meu current user logged in user hey uska user name dekhna hey whoami
        
    * agar uskey sab activities dekhna hey who likhdunga
        
5. which : ae devops ko - let say merey pass bash installed hey kounsa bash installed hey
    
    * which bash - vo batadega us batch ki location
        
    * which cp : insatlled ka location batadega
        
6. id : ae bada hi important cheez hotha hey - jis user sey logged in hua uska id kya hey , uska group id kya hey
    
    * id - ubuntu ka id , ubuntu gid ae sab details batadega
        
7. sudo - aap aur ek user banaya same gharoe rehre aap kithna package kamathey hey ae sab farak nahi padtha gharpe sudo papa root ki chalegi
    
    * agar aapka ghar linux ka machine hey jithna b users add chalalo papa si toh koi bada nahi rehtha root user key pass saari permissions rehthi hey
        
    * super user - ubuntu jethalal ki file delete karna hey iskey pass permissions nahi rehtha thab sudo ka permission letha hey
        
    * agar aapko kisi cheez ki permissions nahi mil pari toh sudo use karlethey
        
    * cat /etc/groups
        
        * mujhey agar sudo use karunga yag sudo group mey add karunga
            
8. shutdown: aapkey systemko shutdown karni hey papa ki permission lekey shutdow karo
    
9. reboot: system ko restart karne key liye use karthey hey
    
10. apt , yum , dnf , pacman
    
    * apt - application package manger ubuntu package install karnekey liye use karthey hey
        
    * sudo apt install docker - docker ko isi system mey dhundra hey , heyi nahi toh internet sey lekey aaunag
        
    * sudo apt-get docker.io - internet sey lekey aakey download karrahun
        
    * sudo apt remove docker.io - uninstall hojayega
        
    * YUM , DNF , PACMAN - AE b package managers hey alag alag distributions ka
        
    * centos- yum , dnf - fedora ka , pacman - arch , redhat - rpm
        
11. which docker - kaha pey install hua hey dikhayega
    

# users and files :

linux famous hua because multi user feauture hey

1. user kaisa create karthey hey - useradd -m ajay - permission denied - without sudo you cannot create
    
    * sudo sueradd -m vaseem - creates user wih home directory
        
    * passwd vaseem - creates the password
        
2. su vaseem - switch user - agar merko user switch karni hey su use kar saktha hun
    
    * whoami
        
    * pwd
        
3. userdel : user ko delete karna hey - &gt; sudo userdel ajay
    
4. grouppadd : ap as a devops engineer ek company mey add hothey hey , humdevops engineer hey , bohot saare users add huey company mey , 3 log testers , 2 log devops key
    
    * in devops logon key roles and permissions honge , as a devops engineer in sab ko kaisa add karenge aur roles and permissions denge
        
    * toh mai group banaunag tester and devops us group mey test employee ko tester group mey add , aur devops valaey ko devops group mey
        
    
    #sudo useradd 1, 2, 3,4
    
    #groupadd devops test
    
    #cat /etc/passwd
    
    #cat /etc/group
    
5. gpasswd: group mey members ko add karna hey
    
    * sudo gpasswd -a ajay devops
        
    * sudo gpasswd -a devops devops
        
    * sudo passwd -a rohit tester
        
    * sudo gpasswd -M kohli,rahul,dhawan tetser
        
6. groupdel : sudo groupdel tester ; agar group delete karni hey th ae command use karthey hey
    

# file permission commands

ae groups and users ko kiun create kiya - ae isloye kiyatha un users ko in files and folder ks paoper access miley

file ko permission ki kya zaroorath hey

* agar ls -l kiun toh iska info aaga
    
* first charcter - defines either file , folder or link than next permissions - user , group other
    
* r= read =4 ; write =2 =w ; x=execute=1
    

1. chmod : agar merko file ka permission change karni hey mai chnagemod - chmod use kartah hun
    
    * chmod 777 filename / folder name
        
2. umask : umask 0002 - ki jabbi koi file create karthey ho by default permisions kya honi chhaiye iskey liye umask rehtha hey
    
3. chown : used to change owner
    
4. chgrp used to chnage group
    

# compression command :

1. zip , gunzip ,and gzip : agar merey pass bohot saarey files anf folders hey toh isko mai zip compress karna hey ae commands use karunag
    
    * zip -r backup.zip folder
        
    * unzip backup.zip
        
    
    1.1 : tar : tar -cvf file.tar cloud/
    
2. tar , untar
    
3. scp : secure copy agar merko local sey remote , remote sey local ko files copy karni hey toh scp use karthey hey
    
    * scp -i pem filename username@[ipaddress](@ipaddress).
        
    * scp -i pem username@ip:remotefile loacl path
        
4. rsync : same as scp but here it works as a remote sync
    
    * rsync -e “ssh -i pemfile” -avz linux.file ubuntu@domainorip:/home/ubuntu/
        

# Networking commands:

* aap ho ek devops engineer - day to day life mey kartha kya hey - unka kaam zyada applications systems pey deploy karna
    
* pehle devops kya karega agar application kaam nahi karra - us application ko ping karega
    

1. ping : ping ek command rehthi hey jo aapko batathi hey ae particular cheez po data recieve hori hey , data pahunchpara yah nahi
    

* ping sigmasoftinfotech.com — main pahunch para yah nahi yah mere thak data pahunchra hey yah nahi
    
* aapka internet b chalra aur revice b hora
    
* ping internet bhejtha hey aur recieve b kartha hey
    

2. netstat - netstat ae rehtha hey matlab network statistics - network key related jithney b cheeze b hey bvo batata hey
    
    * bohot imp command - netstat ney kya kiya - top pey active internet connections - matlab aapkey system pey active internet connections ko dikha detha hey
        
    * kissi server pey active connections and protocals kounsey kounsey hey
        
    * jab tum ec2 use karthey hey bohot saarey sockets use hothey hey , sockerts matlab aisa samajloki one system sey dusri system sey yah type key interface sey connect karna hey sockets use hothey hey
        
3. net-tools key andar - netstat ,,traceroot , telnet , ns-lookup ae sab particular tool kit key andar aatha hey isko use karnekey liye net tools install karni hey
    
4. ifconfig : bhaiyay ifconfig kya hey ; interface
    
    * dockero , eth0 , i0 aatha hey - jithney b network interfaces hey idhar dikhata hey
        
    * ethernet cable eth0 - docker ek interface chalatha hey jab install karneke badh , ae ethernet kis cheez key connect hua rehtha (NIC) network interface card ae network ko jodneykey liye kaam aatha hey
        
    * l0 matlab loop back - matlab aapka jo system hey - lets sey nic kuch b connect nahi hua - local server ko loop back server bolthey internally chalega hamare server mey
        
5. traceroute kya hey tracepath kya hey
    
    * ae duniya mey hamko aek jhoot batadiya - server kaisa work hotha hey ae same concept - is cheez ko bolthey hey route is route ko trace karnekey liye trace route command use karthey hey
        
    * traceroute youtube.com-
        
        * sabse pehle traceroute kya kartha hey - pehle kaha gaya phi ekounsey ip pey gaya trace karthey hey kaha kaha pey hops huey dekhney key liye
            
        * ipaddress finder open karkey check karo
            
    * tracepath sigmasoftinfotech.com
        
        * sabsey pehle local host - sey kaha kaha hops hora karkey
            
    * mtr = ping+tracepath ping b karega , path b batayega
        
        * mtr sigmasoftinfotech.com , idhar 9 baar hops kartha hey , traceroute mey 30 baar route hos kartah hey
            
    * nslookup : nslookup sigmasoft.com - koi domain dhang sey chalra active hey yah nahi aur uska ip address '- active ey yah nahi dikhatha hey
        
    * telnet : telnet b same kartah hey particular website domain and port per connect karnemey help kartha hey
        
6. hostname: batadega ki is system ka hostaname kya hey
    
    * agar merko hostaname ka name chane karna hey sudo hostname sigamblr.com
        
    * cat /etc/hosts - idhar b chane kar sakthey hey
        
7. ip : apne computer ka adress dikhana hey - ip address show
    
8. iwconfig - jithney b wireless connections hothey hey — mujhey ab thak - ip , if , iw mila
    
    * aapko wireless cheeze karni hey wireless-tools install karna padtha hey
        
    * * iwconfig - agar koi wifi -wireless hoga toh dikhadega
            
9. ss - ky hotha hey jaisa netstat hey na same ss detha hey
    
10. dig : agar aapko kisi b domainname ka info nikalna hey
    
    * kaha pey host kiya hey
        
    * whois - kaha sey kharida hey domainanme - kaha sey registry hui hey toh whois use karo
        
11. nc:
    
12. arp: address resolution , aapka device ka ddress rehtahey host ek router sey mac address mangatha hey vo router mac affress detha hey vo janneyka command arp.
    
13. ifplugstatus: batata hey aapkey interfacces chalre hey yah nahi
    

ae comands jo b ab padthey hey ae use karthey hi karthey hey

1. curl vs wget : curl jo hotha hey na , ae jo curl ae command aapki end points ko call karne key liye
    
    * api kya hotah hey ae aap ho aur vo aapka server - aap directly sevrer sey bath nahi karthey usi tarikhey sey ae aapho aur ae aek restaurant hey mcdonals aap directly kichen pey nahi ghusthey - waiter ko bolthey hey waiter na api hey
        
    * user will ask api to get something from server then server give the respone .
        
    * * curl -X GET apiendpoint | jq - agar tum ko is reponse ka data ko sundar sey dikhana hey jq likhdo
            
2. wget : aisa samajlo internet se kisi cheez ko download karni hey wget use karthey hey
    
    * wget url
        
3. iptables : pura ek jaisey , vpc peering mey route tables rehthey hey - ip : rote table sab dikhatha hye
    
    * sudo iptables —list-rules
        
4. watch - jo command hey ae agar aapko koi b chalani hey uski output har ek 22 seconds pey dekhni baar baar dekhni hey
    
    * watch -n 5 top , watch top
        
5. nmap : bacially network map rehtha hey - pura network map - kind of route tables - ae ip kidar jatha hey , kya kya port sopen mey hey dekh saktheyhey
    
    * nmap -v sigmasoftinfotech.com
        
6. route : agar aapko aapne routes change karni hey - gatewya dikhatha hey - route table , inetrenet kaha sey route hori hey , subnets kaha sey route horey dikhatha heyy
    

# pro linux command s:

* awk
    
* sed
    
* grep
    
* shellscript nahi likhni commands se hi khelna hey
    

toh awk hey ek command hey khub hi programming hey awk command : aek file hey us file mey , kuch range sof line slikalni hey , count dikahan hey kuch log files hey us log files mey key kuch data extract karna hey ae saari cheezon ko kaisa help karthi hey

* download one log file ,
    
* head -n 2 app.log
    
* mujhey data time chahiye
    
* awk ‘ {print}‘ app.log -→ awk ‘ {print $1,$2}’ app.log -→
    
    * mujhey sirf info lines chahiye -→ awk ‘/INFO/ {print $1,$2,$3,$4}’ app.log &gt; info.log
        
    * kithni baar info aaya hey -→ awk ‘/INFO/ {count++} END {print count}’ app.log
        
        * awk ‘/ipaddress/ {count++} END {print count}’ app.log
            
        * ae logs hey 8:40 pm start huey aur 8:53 mey khatam huey mujhye 8:53 key hi logs chahiye
            
            ae time kounsey column pey aaya hey
            
        * aws ‘ $2 &gt;= “08:53:00” && $2 &lt;= “08:53:59” {print $2,$3,$4}’ app.log
            
        * awk ‘NR &gt;==2 && NR &lt;=10 {print NR}‘ app.log
            
    * * awk mey jo data chahiye na aek format data chahiye , , formated data , csv , tsv - format data hey awk chaltha hey
            

SED: sed hi awk jaisa tool hey stream editor - jo b aapka streaming data aara - vo real time mey edit b kar sakthey hey

* sed -n ‘ /INFO/p‘ app.log # yaha apko expressions dena padthi hey exact match karneke liye -n dena padtha hey , pattern match ko p dalna hey
    
* sed , line by line kaam kartha hey , jaha jaha pey i ibfo likha mujhey INFO hey usko replace kardo LOGS sey jo is cheez ko karthey globally kardo
    
* * sed ‘s/INFO/LOG/g ‘ app.log - info kounsi line pery aay ahey
        
        * sed '-n -e ‘s/INFO/'=’ app.log → = showing line number , row also print karani hey → ed '-n -e ‘/INFO/'=’ -e ‘/INFO/p’ app.log
            
        
        `-sed ‘1,15 s/INFO/LOG/g;1,10p; 11q ’ app.log` #; this symbol is pause the command
        

---

# Linux :

### **1\. How the Internet Works**

The internet is a global network of computers that communicate with each other to share information. Let’s break it down step by step:

* **Optical Fiber Cables**:
    
    * The internet uses optical fiber cables, which are thin cables made of glass or plastic that carry data as light signals.
        
    * These cables are laid under the sea (submarine cables) to connect continents and countries. They transfer data at very high speeds.
        
    * Example: If you’re in India and accessing a website in the USA, your data travels through these undersea cables.
        
* **Data Centers**:
    
    * Data centers are large buildings filled with powerful computers called servers. These servers store and process data for websites, apps, and services like YouTube or Facebook.
        
    * The optical fiber cables connect to these data centers to send and receive data.
        
* **ISP (Internet Service Provider)**:
    
    * The ISP is like a middleman that connects your device (phone, laptop) to the internet.
        
    * Example: Companies like Jio, Airtel, or Comcast provide internet access to your home. They connect your device to the optical fiber cables and data centers.
        
* **How Data Flows**:
    
    * When you open YouTube on your phone, your request goes through your ISP, travels via optical fiber cables to a data center, and the server in the data center sends the video back to you.
        
    * This happens very fast, so you see the video streaming on your phone almost instantly.
        

---

### **2\. What is a Server?**

A server is just a powerful computer that provides (or “serves”) information or services to other devices, called clients.

* **Server’s Job**:
    
    * A server’s main job is to respond to requests from clients. For example, when you visit a website, your browser (the client) asks the server for the website’s data, and the server sends it back.
        
    * Example: You type “[youtube.com](http://youtube.com)” in your browser. The YouTube server sends the video or webpage to your device.
        
* **Client’s Job**:
    
    * A client is your device (phone, laptop, etc.) that requests information from a server.
        
    * Example: Your phone (client) asks the YouTube server for a video, and the server delivers it.
        
* **Domain and DNS**:
    
    * A domain is a human-readable name like “[youtube.com](http://youtube.com)” or “[facebook.com](http://facebook.com)” that points to a server.
        
    * Every server has an IP address (like 192.168.1.1), which is like its unique address on the internet.
        
    * A **DNS server** (Domain Name System) connects the domain name ([youtube.com](http://youtube.com)) to the correct IP address of the server.
        
    * Example: When you type “[youtube.com](http://youtube.com),” the DNS server finds the IP address of YouTube’s server and connects you to it.
        

---

### **3\. Difference Between Web Server and Application Server**

* **Web Server**:
    
    * A web server delivers static content, like HTML pages, images, or CSS files, to your browser.
        
    * Example: If you visit a simple webpage with text and images, the web server sends those files to your browser.
        
    * Common web servers: Apache, Nginx.
        
* **Application Server**:
    
    * An application server handles dynamic content and business logic. This means it processes data, runs calculations, or interacts with databases to create content on the fly.
        
    * Example: When you log in to Instagram, the application server checks your password, fetches your posts, and sends them to your phone.
        
    * Common application servers: Tomcat, JBoss.
        
* **Key Difference**:
    
    * Web servers are for static content (pre-made files like images or HTML).
        
    * Application servers handle dynamic tasks (like processing login requests or generating personalized content).
        

---

### **4\. Types of Applications**

Applications can be divided into two main types:

* **Standalone Applications**:
    
    * These apps don’t need the internet or a database to work.
        
    * Example: A feedback app at an airport where you click “Good” or “Bad” and it works offline without needing a server or database.
        
    * They are self-contained and run on your device alone.
        
* **Web Applications**:
    
    * These apps need the internet and often rely on multiple servers (application server, database server, email server, etc.).
        
    * Example: YouTube or Instagram. These apps stream videos, send notifications, and store data in databases, requiring a group of servers to work together.
        
    * They need a frontend (what you see), backend (business logic), and database (to store data like posts or videos).
        

---

### **5\. Application Support and Maintenance**

* **What It Means**:
    
    * Applications (like apps on your phone or software on your laptop) run on an operating system (like Linux or Windows).
        
    * Support and maintenance mean ensuring these applications run smoothly without crashing and fixing issues if they arise.
        
* **DevOps or Linux Admin’s Role**:
    
    * A DevOps engineer or Linux admin checks if the application is running properly, if there are connection issues, or if a server is causing problems.
        
    * Example: If YouTube stops streaming, they check which server (web server, application server, or database) is having an issue.
        

---

### **6\. What is Linux?**

* **Linux Basics**:
    
    * Linux is an open-source operating system, meaning anyone can use or modify it for free.
        
    * It was created by Linus Torvalds in 1991.
        
    * Most servers (90%) run on Linux because it’s secure, doesn’t need antivirus, supports multitasking, and gets community updates.
        
* **Why Companies Use Linux**:
    
    * It’s free, secure, and highly customizable.
        
    * Most web applications (like YouTube, Instagram) run on Linux servers.
        
* **Linux vs. Unix**:
    
    * Unix is a commercial operating system (like macOS).
        
    * Linux is a free, open-source version inspired by Unix.
        
    * Example: macOS is Unix-based, while Ubuntu is a Linux distribution.
        
* **How to Install Linux**:
    
    1. **WSL (Windows Subsystem for Linux)**: Run Linux inside Windows without a separate machine.
        
    2. **VirtualBox**: Install Linux on a virtual machine on your computer.
        
    3. **Cloud**: Use cloud platforms like AWS, Azure, or GCP to create a Linux virtual machine.
        
    4. **Vagrant**: A tool by HashiCorp to easily set up Linux environments.
        

---

### **7\. Linux vs. Windows**

* **Windows**:
    
    * Requires a license (you pay for it).
        
    * Needs antivirus software.
        
    * Regular updates are mandatory.
        
    * Focused on user-friendly interfaces for general use (like gaming or office work).
        
* **Linux**:
    
    * Free under the General Public License (GPL).
        
    * No need for antivirus due to strong security.
        
    * Updates are optional (e.g., Ubuntu releases updates twice a year).
        
    * Focused on development, networking, programming, and scripting.
        

---

### **8\. Remote Server Connection Tools**

To connect to a remote server (a computer far away), you can use these tools:

1. **RDP (Remote Desktop Protocol)**: Connect to a server’s desktop remotely, like seeing its screen.
    
2. **SSH (Secure Shell)**: Connect to a server’s command line securely using a terminal. Uses port 22.
    
3. **AnyDesk**: A remote desktop tool for graphical access.
    
4. **UltraViewer**: Similar to AnyDesk, for remote desktop access.
    

---

### **9\. Kernel, Bootloader, and Shell**

* **Kernel**:
    
    * The kernel is the core of the operating system. It’s like the heart of Linux.
        
    * It manages hardware, processes, and files. It’s written in the C programming language.
        
    * Example: The kernel controls how your CPU runs programs or how your hard drive stores data.
        
* **Shell**:
    
    * A shell is a program that lets you talk to the kernel using commands.
        
    * It’s like a bridge between you and the kernel.
        
    * Example: When you type a command like ls, the shell sends it to the kernel, which lists the files.
        
* **Bootloader**:
    
    * The bootloader is a program that starts your operating system when you turn on your computer.
        
    * Example: GRUB (Grand Unified Bootloader) loads Linux by finding and starting the kernel and other necessary files.
        
* **How They Work Together**:
    
    * The bootloader starts the kernel.
        
    * The kernel runs the operating system and hardware.
        
    * The shell lets you interact with the kernel by typing commands.
        
    * Example: You type df -h in the shell to check disk space, the shell tells the kernel, and the kernel gets the data from the hardware.
        

---

### **10\. Linux File System**

* In Linux, everything is treated as a file (even folders, devices, or processes).
    
* The file system starts with the root folder, written as /.
    
* **Key Directories**:
    
    * /: The root folder, the top of the file system.
        
    * /var: Stores logs (e.g., system or application logs).
        
    * /usr: Stores user-related data and programs.
        
    * /home: Stores user files (like your documents or downloads).
        
* **Navigating the File System**:
    
    * Use cd to change directories (e.g., cd /var to go to the var folder).
        
    * Use cd .. to go back one directory.
        
    * Use pwd to see your current directory.
        

---

### **11\. Linux Commands**

Here’s a breakdown of the Linux commands you mentioned, explained simply:

1. **date**: Shows the current date and time.
    
    * Example: date → Output: Tue May 27 03:00:00 IST 2025
        
2. **ls**: Lists files and folders in the current directory.
    
    * Example: ls → Output: file1.txt folder1
        
3. **ls -l**: Lists files/folders with details (permissions, owner, size, date).
    
    * Example: ls -l → Output: -rw-r--r-- 1 user group 1024 May 27 file1.txt
        
4. **mkdir devops**: Creates a folder named “devops”.
    
    * Example: mkdir devops → Creates a folder called devops.
        
5. **pwd**: Shows the current directory you’re in.
    
    * Example: pwd → Output: /home/user/devops
        
6. **touch file.txt**: Creates an empty file named file.txt.
    
    * Example: touch file.txt → Creates file.txt.
        
7. **clear**: Clears the terminal screen.
    
8. **cd foldername**: Changes to the folder named “foldername”.
    
    * Example: cd devops → Moves to the devops folder.
        
9. **cd ..**: Goes back one directory.
    
    * Example: If you’re in /home/user/devops, cd .. takes you to /home/user.
        
10. **rmdir foldername**: Deletes an empty folder.
    
    * Example: rmdir devops → Deletes the empty devops folder.
        
11. **rm file.txt**: Deletes a file.
    
    * Example: rm file.txt → Deletes file.txt.
        
12. **rm -rf foldername**: Deletes a folder and all its contents (files and subfolders).
    
    * Example: rm -rf devops → Deletes the devops folder and everything inside it.
        
13. **cat file.txt**: Displays the contents of a file.
    
    * Example: cat file.txt → Output: hello world (if file.txt contains “hello world”).
        
14. **echo "hello world" &gt; file.txt**: Writes “hello world” to file.txt, overwriting it.
    
    * Example: echo "hello world" &gt; file.txt → file.txt now contains “hello world”.
        
15. **echo "how are u" &gt;&gt; file.txt**: Appends “how are u” to file.txt without overwriting.
    
    * Example: echo "how are u" &gt;&gt; file.txt → Adds “how are u” to the end of file.txt.
        
16. **zcat file.gz**: Displays the contents of a compressed (zipped) file without unzipping it.
    
    * Example: zcat file.gz → Shows the contents of file.gz.
        
17. **head file.txt**: Shows the first 10 lines of a file.
    
    * Example: head file.txt → Displays the first 10 lines of file.txt.
        
18. **tail file.txt**: Shows the last 10 lines of a file.
    
    * Example: tail file.txt → Displays the last 10 lines of file.txt.
        
19. **tail -n 5 file.txt**: Shows the last 5 lines of a file.
    
    * Example: tail -n 5 file.txt → Displays the last 5 lines.
        
20. **more file.txt**: Shows a file page by page (press space to see the next page).
    
    * Example: more file.txt → Displays file.txt one screen at a time.
        
21. **less file.txt**: Similar to more, but you can scroll up and down.
    
    * Example: less file.txt → Opens file.txt for scrolling.
        
22. **cp file1.txt file2.txt**: Copies file1.txt to file2.txt.
    
    * Example: cp file1.txt file2.txt → Creates a copy of file1.txt named file2.txt.
        
23. **cp -r folder1 folder2**: Copies a folder and its contents.
    
    * Example: cp -r cloud devops → Copies the cloud folder to a new folder named devops.
        
24. **mv file1.txt file2.txt**: Moves or renames a file.
    
    * Example: mv file1.txt file2.txt → Renames file1.txt to file2.txt.
        
25. **wc file.txt**: Counts words, lines, and bytes (size) in a file.
    
    * Example: wc file.txt → Output: 10 50 300 file.txt (10 lines, 50 words, 300 characters).
        
26. **ln file.txt hardlink-file**: Creates a hard link to a file (a shortcut that stays even if the original file is deleted).
    
    * Example: ln file.txt hardlink-file → Creates a hard link to file.txt.
        
27. **ln -s file.txt softlink-file**: Creates a soft link (a shortcut that breaks if the original file is deleted).
    
    * Example: ln -s file.txt softlink-file → Creates a soft link to file.txt.
        
28. **cut -b 1-4 file.txt**: Extracts a portion of text (bytes 1 to 4) from each line of a file.
    
    * Example: cut -b 1-4 file.txt → Output: “this” (if file.txt contains “this is my file”).
        
29. **tee file.txt**: Writes output to both the screen and a file.
    
    * Example: echo "hello" | tee file.txt → Shows “hello” on the screen and writes it to file.txt.
        
30. **sort file.txt**: Sorts the lines of a file alphabetically.
    
    * Example: sort file.txt → Sorts the lines in file.txt.
        
31. **diff file1.txt file2.txt**: Shows differences between two files.
    
    * Example: diff file1.txt file2.txt → Lists differences between file1.txt and file2.txt.
        
32. **vim file.txt**: Opens a file in the Vim editor for editing.
    
    * Example: vim file.txt → Opens file.txt for editing.
        
33. **ssh user@ipaddress**: Connects to a remote server securely using SSH.
    
    * Example: ssh -i key.pem ubuntu@192.168.1.1 → Connects to a server with IP 192.168.1.1 as the user “ubuntu” using a key file.
        
34. **df -h**: Shows disk space usage in a human-readable format.
    
    * Example: df -h → Output: Shows used and available disk space.
        
35. **du -h foldername**: Shows the size of a folder or file.
    
    * Example: du -h devops → Output: Shows the size of the devops folder.
        
36. **ps**: Shows running processes for the current session.
    
    * Example: ps → Lists processes running in your terminal.
        
37. **top**: Shows live system resource usage (CPU, RAM, processes).
    
    * Example: top → Displays a live view of running processes and system usage.
        
38. **fuser file.txt**: Shows which process is using a file.
    
    * Example: fuser file.txt → Lists the process ID using file.txt.
        
39. **kill 1234**: Stops a process with the given process ID (e.g., 1234).
    
    * Example: kill 1234 → Terminates process ID 1234.
        
40. **free -h**: Shows memory (RAM) usage in a human-readable format.
    
    * Example: free -h → Output: Shows used and free RAM.
        
41. **nohup command**: Runs a command that keeps running even if you close the terminal.
    
    * Example: nohup free -h & → Runs free -h in the background and saves output to nohup.out.
        
42. **vmstat**: Shows virtual memory statistics.
    
    * Example: vmstat -a → Shows active and inactive memory.
        

---

### **12\. System-Level Commands**

These commands give information about the system:

1. **uname**: Shows the operating system name (e.g., Linux, Ubuntu).
    
    * Example: uname → Output: Linux
        
2. **uptime**: Shows how long the system has been running and the load average.
    
    * Example: uptime → Output: 03:00:00 up 9 min, 1 user, load average: 0.01
        
3. **who**: Lists all users currently logged into the system.
    
    * Example: who → Output: Lists usernames and login times.
        
4. **whoami**: Shows the current logged-in user.
    
    * Example: whoami → Output: ubuntu
        
5. **which command**: Shows the location of a command.
    
    * Example: which bash → Output: /bin/bash
        
6. **id**: Shows the user ID and group ID of the current user.
    
    * Example: id → Output: uid=1000(ubuntu) gid=1000(ubuntu)
        
7. **sudo**: Runs a command with superuser (admin) privileges.
    
    * Example: sudo apt install docker → Installs Docker with admin rights.
        
8. **cat /etc/group**: Shows the groups on the system.
    
    * Example: cat /etc/group → Lists all groups and their members.
        
9. **shutdown**: Shuts down the system.
    
    * Example: sudo shutdown now → Shuts down immediately.
        
10. **reboot**: Restarts the system.
    
    * Example: sudo reboot → Restarts the system.
        

---

### **13\. Package Managers**

Package managers install, update, or remove software on Linux.

1. **apt**: Used on Ubuntu/Debian to manage packages.
    
    * Example: sudo apt install docker → Installs Docker.
        
    * Example: sudo apt remove docker → Uninstalls Docker.
        
2. **yum, dnf, pacman**:
    
    * **yum**: Used on CentOS for package management.
        
    * **dnf**: Used on Fedora, an improved version of yum.
        
    * **pacman**: Used on Arch Linux.
        
    * Example: sudo yum install docker → Installs Docker on CentOS.
        

---

### **14\. Users and Groups**

Linux is a multi-user system, meaning many users can use it at once with different permissions.

1. **useradd**: Creates a new user.
    
    * Example: sudo useradd -m vaseem → Creates a user “vaseem” with a home directory.
        
2. **passwd**: Sets a password for a user.
    
    * Example: sudo passwd vaseem → Sets a password for user “vaseem”.
        
3. **su**: Switches to another user.
    
    * Example: su vaseem → Switches to the user “vaseem”.
        
4. **userdel**: Deletes a user.
    
    * Example: sudo userdel vaseem → Deletes the user “vaseem”.
        
5. **groupadd**: Creates a new group.
    
    * Example: sudo groupadd devops → Creates a group named “devops”.
        
6. **gpasswd**: Adds users to a group.
    
    * Example: sudo gpasswd -a ajay devops → Adds user “ajay” to the devops group.
        
7. **groupdel**: Deletes a group.
    
    * Example: sudo groupdel devops → Deletes the devops group.
        

---

### **15\. File Permissions**

Linux files and folders have permissions for the owner, group, and others.

* **Permissions**:
    
    * **r** (read) = 4: Allows reading a file or listing a folder.
        
    * **w** (write) = 2: Allows modifying a file or folder.
        
    * **x** (execute) = 1: Allows running a file (like a script) or entering a folder.
        
* **chmod**: Changes file or folder permissions.
    
    * Example: chmod 777 file.txt → Gives full permissions (read, write, execute) to everyone.
        
* **umask**: Sets default permissions for new files.
    
    * Example: umask 0002 → New files will have permissions like 664 (rw-rw-r--).
        
* **chown**: Changes the owner of a file or folder.
    
    * Example: sudo chown ajay file.txt → Makes “ajay” the owner of file.txt.
        
* **chgrp**: Changes the group of a file or folder.
    
    * Example: sudo chgrp devops file.txt → Sets the group of file.txt to “devops”.
        

---

### **16\. Compression Commands**

These commands compress or decompress files and folders.

1. **zip**: Compresses files/folders into a .zip file.
    
    * Example: zip -r [backup.zip](http://backup.zip) folder → Compresses the folder into [backup.zip](http://backup.zip).
        
2. **unzip**: Extracts a .zip file.
    
    * Example: unzip [backup.zip](http://backup.zip) → Extracts the contents of [backup.zip](http://backup.zip).
        
3. **tar**: Creates or extracts .tar archives.
    
    * Example: tar -cvf file.tar folder → Creates a file.tar archive from the folder.
        
    * Example: tar -xvf file.tar → Extracts the contents of file.tar.
        
4. **gzip/gunzip**: Compresses or decompresses files.
    
    * Example: gzip file.txt → Compresses file.txt to file.txt.gz.
        
    * Example: gunzip file.txt.gz → Decompresses file.txt.gz.
        

---

### **17\. File Transfer Commands**

These commands transfer files between local and remote systems.

1. **scp**: Securely copies files between local and remote systems.
    
    * Example: scp -i key.pem file.txt ubuntu@192.168.1.1:/home/ubuntu → Copies file.txt to a remote server.
        
2. **rsync**: Synchronizes files between local and remote systems, only transferring changes.
    
    * Example: rsync -e "ssh -i key.pem" -avz file.txt ubuntu@192.168.1.1:/home/ubuntu → Syncs file.txt to a remote server.
        

---

### **18\. Networking Commands**

These commands help manage and troubleshoot networks.

1. **ping**: Checks if a server or website is reachable.
    
    * Example: ping [youtube.com](http://youtube.com) → Shows if [youtube.com](http://youtube.com) responds.
        
2. **netstat**: Shows network connections and statistics.
    
    * Example: netstat → Lists active connections and ports.
        
3. **ifconfig**: Shows network interface details (like Ethernet or Wi-Fi).
    
    * Example: ifconfig → Lists interfaces like eth0 (Ethernet) or lo (loopback).
        
4. **traceroute**: Shows the path data takes to reach a server.
    
    * Example: traceroute [youtube.com](http://youtube.com) → Lists all hops (routers) between you and [youtube.com](http://youtube.com).
        
5. **tracepath**: Similar to traceroute but simpler.
    
    * Example: tracepath [sigmasoftinfotech.com](http://sigmasoftinfotech.com) → Shows the path to [sigmasoftinfotech.com](http://sigmasoftinfotech.com).
        
6. **mtr**: Combines ping and traceroute.
    
    * Example: mtr [sigmasoftinfotech.com](http://sigmasoftinfotech.com) → Shows live ping and path data.
        
7. **nslookup**: Finds the IP address of a domain.
    
    * Example: nslookup [sigmasoftinfotech.com](http://sigmasoftinfotech.com) → Shows the IP address and server details.
        
8. **telnet**: Tests if a server is reachable on a specific port.
    
    * Example: telnet [sigmasoftinfotech.com](http://sigmasoftinfotech.com) 80 → Checks if port 80 is open.
        
9. **hostname**: Shows or sets the system’s hostname.
    
    * Example: hostname → Output: mycomputer
        
    * Example: sudo hostname newname → Changes the hostname to “newname”.
        
10. **ip**: Shows IP address and network details.
    
    * Example: ip address show → Lists all network interfaces and their IP addresses.
        
11. **iwconfig**: Shows wireless network details.
    
    * Example: iwconfig → Lists Wi-Fi interfaces and details (if installed).
        
12. **ss**: Shows socket statistics (similar to netstat).
    
    * Example: ss → Lists active network connections.
        
13. **dig**: Gets detailed DNS information for a domain.
    
    * Example: dig [sigmasoftinfotech.com](http://sigmasoftinfotech.com) → Shows DNS records.
        
14. **whois**: Shows who owns a domain and its registration details.
    
    * Example: whois [sigmasoftinfotech.com](http://sigmasoftinfotech.com) → Shows domain owner and registrar.
        
15. **arp**: Shows the Address Resolution Protocol table (maps IP addresses to MAC addresses).
    
    * Example: arp → Lists devices on the network.
        
16. **ifplugstatus**: Checks if network interfaces are connected.
    
    * Example: ifplugstatus → Shows if eth0 is plugged in.
        
17. **curl**: Makes requests to APIs or downloads data from a URL.
    
    * Example: curl -X GET [https://api.example.com](https://api.example.com) → Fetches data from an API.
        
18. **wget**: Downloads files from the internet.
    
    * Example: wget [https://example.com/file.txt](https://example.com/file.txt) → Downloads file.txt.
        
19. **iptables**: Manages firewall rules.
    
    * Example: sudo iptables --list-rules → Shows current firewall rules.
        
20. **watch**: Runs a command repeatedly and shows its output.
    
    * Example: watch -n 5 top → Runs top every 5 seconds.
        
21. **nmap**: Scans a network for open ports and devices.
    
    * Example: nmap [sigmasoftinfotech.com](http://sigmasoftinfotech.com) → Shows open ports on [sigmasoftinfotech.com](http://sigmasoftinfotech.com).
        
22. **route**: Shows or modifies the routing table.
    
    * Example: route → Lists routing information.
        

---

### **19\. Pro Linux Commands (awk, sed, grep)**

These are advanced commands for processing text and logs.

1. **awk**:
    
    * A powerful tool to process and extract data from files.
        
    * Example: awk '{print $1,$2}' app.log → Prints the first two columns (e.g., date and time) from app.log.
        
    * Example: awk '/INFO/ {print}' app.log → Prints lines containing “INFO”.
        
    * Example: awk '/INFO/ {count++} END {print count}' app.log → Counts how many times “INFO” appears.
        
    * Example: awk '$2 &gt;= "08:53:00" && $2 &lt;= "08:53:59" {print}' app.log → Prints logs between 8:53:00 and 8:53:59.
        
2. **sed**:
    
    * A stream editor to edit text in real-time.
        
    * Example: sed -n '/INFO/p' app.log → Prints lines containing “INFO”.
        
    * Example: sed 's/INFO/LOG/g' app.log → Replaces “INFO” with “LOG” in app.log.
        
    * Example: sed -n -e '/INFO/=' app.log → Shows line numbers where “INFO” appears.
        
    * Example: sed '1,15 s/INFO/LOG/g;1,10p;11q' app.log → Replaces “INFO” with “LOG” in lines 1-15, prints lines 1-10, and stops at line 11.
        
3. **grep**:
    
    * Searches for text patterns in files.
        
    * Example: grep "INFO" app.log → Shows lines containing “INFO”.
        

### **20\. Role of a DevOps Engineer**

* A DevOps engineer deploys and maintains applications on servers.
    
* They ensure applications run smoothly, troubleshoot issues, and manage servers (often Linux).
    
* Example: If an application like YouTube stops working, they:
    
    * Check if the server is reachable (ping).
        
    * Check logs for errors (cat, grep, awk).
        
    * Restart the server or service if needed (systemctl or kill).
        
    * Ensure proper permissions (chmod, chown) and network settings (iptables, netstat).
