commit 244ad643f08c693a4cdf9323616c7b8f9f86b268 Author: amitrana01 Date: Tue Jan 6 16:46:52 2026 +0530 Add Linux DevOps notes (Day 1-3) diff --git a/01_Linux_Basics.md b/01_Linux_Basics.md new file mode 100644 index 0000000..23e72b0 --- /dev/null +++ b/01_Linux_Basics.md @@ -0,0 +1,53 @@ +# Linux – Basic Commands (Day 1) + +## What is Linux? +Linux is an operating system used to run servers and applications. + +## Why Linux is important for DevOps? +Most servers run on Linux, and DevOps engineers manage everything using Linux commands. + +## Linux Folder Structure +- / → root +- /home → user files +- /etc → configuration files +- /var → logs and data +- /bin → system commands + +## Navigation Commands +```bash +pwd # show current directory +ls # list files +ls -l # detailed list +ls -a # show hidden files +cd folder # move into folder +cd .. # go back +cd ~ # go to home +``` + +## Create & Delete Commands +```bash +mkdir app +touch file.txt +rm file.txt +rm -r app +``` + +## Working with File Content +```bash +cat file.txt +head file.txt +echo "Linux for DevOps" > info.txt # write content +echo "Day 1 completed" >> info.txt # append content +cat info.txt # view file content +``` + +## Daily Useful Linux Commands +```bash +clear # clear terminal screen +history # show command history +whoami # show current user +uname -a # show system information +``` + + + diff --git a/02_Linux_Permissions.md b/02_Linux_Permissions.md new file mode 100644 index 0000000..8bdc437 --- /dev/null +++ b/02_Linux_Permissions.md @@ -0,0 +1,207 @@ +# Linux – File Permissions (Day 2) + +## What are File Permissions? +File permissions control **who can read, write, or execute** a file or folder in Linux. + +They protect the system from: +- accidental deletion +- unauthorized access +- hacking + +--- + +## Why Permissions are Important for DevOps? +DevOps engineers manage **live servers**. +Wrong permissions can: +- break applications +- expose data +- allow hackers access + +So permissions are **critical**. + +--- + +## Permission Types + +There are 3 permissions: + +- r → read +- w → write +- x → execute + +--- + +## Permission Groups + +Permissions are set for 3 types of users: + +- u → user (owner) +- g → group +- o → others + +Order is always: + +## user | group | others + +--- + +## Checking Permissions + +```bash +ls -l +-rwxr-xr-- +Meaning: + +user → rwx + +group → r-x + +others → r-- + +Add values to set permissions. + +Examples: + +7 = rwx (4+2+1) + +6 = rw- (4+2) + +5 = r-x (4+1) + +4 = r-- +``` + +--- + +## Setting Permissions + +```bash +chmod 755 file.txt +``` + +Meaning: + +user → 7 (rwx) + +group → 5 (r-x) + +others → 5 (r-x) + +## Symbolic Method + +```bash +chmod u+x file.sh +chmod g-w file.sh +chmod o+r file.sh +``` + +## Common Permission Examples + +```bash +chmod 755 file.txt +chmod 644 file.txt +chmod 777 file.txt +chmod 666 file.txt +chmod 700 file.txt +chmod 600 file.txt +``` + +## Execute Permission (Very Important) + +To run a script: + +```bash +./script.sh +``` + + +If permission denied: + +```bash +chmod +x script.sh +``` + +## Folder Permissions Rule + +```bash +r → list files +w → create/delete files +x → enter folder +``` + + Without x, you cannot cd into folder. + +## Execute Permission (Very Important) + +To run a script: + +```bash +./script.sh +``` + + +If permission denied: + +```bash +chmod +x script.sh +``` + +## Folder Permissions Rule + +```bash +r → list files + +w → create/delete files + +x → enter folder +``` +Without x, you cannot cd into folder. + + +## Mini Practice Task + +```bash +mkdir test +touch test/app.sh +ls -l test +chmod 755 test/app.sh +ls -l test +``` + +## Common Mistakes + +- Giving 777 permissions (very dangerous) +- Not understanding folder execute permission +- Changing permissions blindly on production servers + + +## Changing Ownership + +To change the owner of a file: +```bash +sudo chown username file.txt +``` + +To change both owner and group: +```bash +sudo chown username:groupname file.txt +``` + +To change the group ownership: +```bash +sudo chgrp groupname file.txt +``` + +## Recursive Changes +Apply permissions or ownership to a directory and all its contents: +```bash +chmod -R 755 folder_name/ +chown -R username:groupname folder_name/ +``` + +## Checking Current Permissions +To see detailed permissions for all files in a directory: +```bash +ls -la +``` + diff --git a/03_Linux_Users_Ownership.md b/03_Linux_Users_Ownership.md new file mode 100644 index 0000000..46d6472 --- /dev/null +++ b/03_Linux_Users_Ownership.md @@ -0,0 +1,207 @@ +# Linux – Users & Ownership (Day 3) + +## What are Users in Linux? +Linux is a multi-user system. +Each file and process runs under a specific user. + +This prevents: +- accidental damage +- security issues +- one app affecting another + +--- + +## Why Users Matter in DevOps? +Applications **never run as root** in production. +Each service has its own user for safety. + +DevOps engineers: +- create users +- assign ownership +- control access + +--- + +## User Types +- root → superuser (full access) +- normal user → regular work +- system user → runs services (nginx, docker) + +--- + +## Check Current User +```bash +whoami +``` + +## View All Users +```bash +cat /etc/passwd +``` + +## Create a New User +```bash +sudo useradd devuser +``` + +## Set password: +```bash +sudo passwd devuser +``` + +## Switch User +```bash +su devuser +``` + +## Exit user +```bash +exit +``` + +## Groups in Linux + +Users belong to groups. +Groups help manage permissions easily. + +## Check groups: + +```bash +groups +``` + +## Add user to group: + +```bash +sudo usermod -aG sudo devuser +``` + +## File Ownership + +Each file has: + +owner + +group + +## Check ownership: + +```bash +ls -l +``` + +## Change Ownership (chown) +```bash +sudo chown devuser file.txt +sudo chown devuser:devuser file.txt +``` + +## Change Group Only +```bash +sudo chgrp devuser file.txt +``` + +## Real DevOps Scenario + +Application folder: + +owned by app user + +not by root + +correct permissions + +Example: + +```bash +sudo mkdir /var/myapp +sudo chown devuser:devuser /var/myapp +sudo chmod 755 /var/myapp +``` + +## Common Mistakes + +Running apps as root + +Wrong ownership causing permission denied + +Using sudo unnecessarily + +DevOps Rule + +❌ root everywhere +✅ least privilege access + + +## Exit user: + +```bash +exit +``` + +## Groups in Linux + +Users belong to groups. +Groups help manage permissions easily. + +## Check groups: + +groups + +## Add user to group: + +sudo usermod -aG sudo devuser + +## File Ownership + +Each file has: + +owner + +group + +## Check ownership: + +```bash +ls -l +``` + +## Change Ownership (chown) +```bash +sudo chown devuser file.txt +sudo chown devuser:devuser file.txt +``` + +## Change Group Only +```bash +sudo chgrp devuser file.txt +``` + +## Real DevOps Scenario + +Application folder: + +owned by app user + +not by root + +correct permissions + +Example: + +sudo mkdir /var/myapp +sudo chown devuser:devuser /var/myapp +sudo chmod 755 /var/myapp + +## Common Mistakes + +Running apps as root + +Wrong ownership causing permission denied + +Using sudo unnecessarily + +## DevOps Rule + +❌ root everywhere +✅ least privilege access \ No newline at end of file diff --git a/04_Linux_Networking_Basics.md b/04_Linux_Networking_Basics.md new file mode 100644 index 0000000..8bf9cd1 --- /dev/null +++ b/04_Linux_Networking_Basics.md @@ -0,0 +1,134 @@ +# Linux – Networking Basics (Day 4) + +## What is Networking in Linux? +Networking means how computers and servers communicate with each other +using IP addresses, ports, and protocols. + +Every DevOps engineer must understand networking +because applications run on networks. + +--- + +## Why Networking is Important for DevOps? +If networking fails: +- app will not open +- server looks “down” +- deployment fails + +Most DevOps issues are actually network issues. + +--- + +## IP Address +An IP address identifies a machine on a network. + +Check IP: +```bash +ip a +``` +or +```bash +ifconfig +``` + +--- + +## Hostname +```bash +hostname +``` + +--- + +## Ping Command +```bash +ping google.com +``` +Stop ping: +```bash +Ctrl + C +``` + +--- + +## curl Command (VERY IMPORTANT) +```bash +curl google.com +curl -I google.com +``` + +--- + +## wget Command +```bash +wget https://example.com/file.txt +``` + +--- + +## Ports (CRITICAL CONCEPT) +Common ports: +- 22 → SSH +- 80 → HTTP +- 443 → HTTPS +- 3306 → MySQL + +--- + +## Check Open Ports +```bash +netstat -tuln +``` +or +```bash +ss -tuln +``` + +--- + +## Check Which Process Uses a Port +```bash +sudo netstat -tulnp +``` + +--- + +## DNS Resolution +```bash +nslookup google.com +dig google.com +``` + +--- + +## Test Server Connectivity +```bash +telnet google.com 80 +``` + +--- + +## Real DevOps Scenario +Commands used: +```bash +curl +ping +netstat +ss +``` + +--- + +## Common Mistakes +- Forgetting port number +- Confusing localhost and public IP + +--- + +## DevOps Rule +If something doesn’t work → check network first. + +--- + +## Summary +Linux networking basics: IP, ports, ping, curl, DNS, and open ports. diff --git a/05_Linux_SSH_Remote_Access.md b/05_Linux_SSH_Remote_Access.md new file mode 100644 index 0000000..6023426 --- /dev/null +++ b/05_Linux_SSH_Remote_Access.md @@ -0,0 +1,163 @@ +# Linux – SSH & Remote Server Access (Day 5) + +## What is SSH? +SSH (Secure Shell) is used to securely connect to a remote server. +DevOps engineers use SSH daily to manage cloud servers. + +--- + +## Why SSH is Important for DevOps? +- Access cloud servers (AWS EC2, VPS) +- Deploy applications +- Debug production issues +- Manage configurations + +No SSH = no DevOps work. + +--- + +## Basic SSH Syntax +```bash +ssh user@server_ip +``` + +Example: +```bash +ssh ubuntu@13.234.56.78 +``` + +--- + +## Default SSH Port +- Port 22 + +Custom port example: +```bash +ssh -p 2222 user@server_ip +``` + +--- + +## SSH First-Time Connection +You may see: +``` +Are you sure you want to continue connecting (yes/no)? +``` + +Type: +```text +yes +``` + +--- + +## SSH Key-Based Authentication (VERY IMPORTANT) + +Instead of passwords, DevOps uses SSH keys. + +Benefits: +- More secure +- No password typing +- Required by cloud providers + +--- + +## Generate SSH Key +```bash +ssh-keygen +``` + +Press Enter for defaults. + +This creates: +- private key → ~/.ssh/id_rsa +- public key → ~/.ssh/id_rsa.pub + +--- + +## Copy SSH Key to Server +```bash +ssh-copy-id user@server_ip +``` + +Or manually copy: +```bash +cat ~/.ssh/id_rsa.pub +``` + +Paste into server: +```bash +~/.ssh/authorized_keys +``` + +--- + +## Login Using SSH Key +```bash +ssh user@server_ip +``` + +(No password needed) + +--- + +## SSH Config File (PRO TIP) +Create: +```bash +~/.ssh/config +``` + +Example: +```text +Host myserver + HostName 13.234.56.78 + User ubuntu + IdentityFile ~/.ssh/id_rsa +``` + +Now connect using: +```bash +ssh myserver +``` + +--- + +## Common SSH Commands +```bash +exit # logout +whoami # check user +hostname # server name +uptime # server running time +``` + +--- + +## Common SSH Errors +- Permission denied +- Wrong user +- Wrong key +- Port blocked by firewall + +--- + +## DevOps Best Practices +- Disable password login +- Use key-based auth only +- Never share private key +- Use least privilege users + +--- + +## Real DevOps Scenario +1. Create EC2 instance +2. SSH into server +3. Install Docker +4. Deploy application + +SSH is the entry point. + +--- + +## Summary +Today I learned SSH basics, key-based authentication, +and how DevOps engineers securely connect to remote servers.