├── .gitignore ├── 01-getting-started ├── 01-fundamentals.md ├── 02-linux-structure.md ├── 03-linux-distributions.md ├── 04-setup.md └── 05-package-manager.md ├── 02-folder-structure └── README.md ├── 03-user-management └── README.md ├── 04-file-management └── README.md ├── 05-vi-shortcuts └── README.md ├── 06-file-permissions └── README.md ├── 07-process-management └── README.md ├── 08-monitoring └── README.md ├── 09-networking └── README.md ├── 10-disk-management └── README.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # UV 98 | # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | #uv.lock 102 | 103 | # poetry 104 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 105 | # This is especially recommended for binary packages to ensure reproducibility, and is more 106 | # commonly ignored for libraries. 107 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 108 | #poetry.lock 109 | 110 | # pdm 111 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 112 | #pdm.lock 113 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 114 | # in version control. 115 | # https://pdm.fming.dev/latest/usage/project/#working-with-version-control 116 | .pdm.toml 117 | .pdm-python 118 | .pdm-build/ 119 | 120 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 121 | __pypackages__/ 122 | 123 | # Celery stuff 124 | celerybeat-schedule 125 | celerybeat.pid 126 | 127 | # SageMath parsed files 128 | *.sage.py 129 | 130 | # Environments 131 | .env 132 | .venv 133 | env/ 134 | venv/ 135 | ENV/ 136 | env.bak/ 137 | venv.bak/ 138 | 139 | # Spyder project settings 140 | .spyderproject 141 | .spyproject 142 | 143 | # Rope project settings 144 | .ropeproject 145 | 146 | # mkdocs documentation 147 | /site 148 | 149 | # mypy 150 | .mypy_cache/ 151 | .dmypy.json 152 | dmypy.json 153 | 154 | # Pyre type checker 155 | .pyre/ 156 | 157 | # pytype static type analyzer 158 | .pytype/ 159 | 160 | # Cython debug symbols 161 | cython_debug/ 162 | 163 | # PyCharm 164 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 165 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 166 | # and can be added to the global gitignore or merged into this file. For a more nuclear 167 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 168 | #.idea/ 169 | 170 | # Ruff stuff: 171 | .ruff_cache/ 172 | 173 | # PyPI configuration file 174 | .pypirc 175 | -------------------------------------------------------------------------------- /01-getting-started/01-fundamentals.md: -------------------------------------------------------------------------------- 1 | # Linux over Windows 2 | 3 | ### Cost-Effectiveness 4 | - **Free and Open Source**: Linux does not require expensive licensing fees, making it a cost-effective choice for companies. 5 | - **Lower Maintenance Costs**: Linux is stable and requires minimal maintenance, reducing operational expenses. 6 | 7 | ### Performance and Efficiency 8 | - **Better Resource Utilization**: Linux is lightweight and consumes fewer system resources compared to Windows. 9 | - **High Scalability**: Linux efficiently scales from small embedded systems to enterprise data centers without performance degradation. 10 | 11 | ### Security and Reliability 12 | - **Less Vulnerable to Malware**: Linux has strong user privilege separation, making it more secure against viruses and malware. 13 | - **Frequent and Transparent Updates**: Regular security patches ensure system stability without requiring frequent reboots. 14 | - **High Stability**: Linux systems can run for years without crashes, ensuring better uptime and reliability. 15 | -------------------------------------------------------------------------------- /01-getting-started/02-linux-structure.md: -------------------------------------------------------------------------------- 1 | # Core components of a Linux Machine 2 | 3 | ```plaintext 4 | +----------------------------------------------------+ 5 | | User Applications (Vim, Docker, Apache, etc.) | 6 | +----------------------------------------------------+ 7 | | Shell (Bash, Zsh, Fish, etc.) | <-- Part of the OS 8 | +----------------------------------------------------+ 9 | | System Libraries (glibc, libc, OpenSSL, etc.) | <-- Part of the OS 10 | +----------------------------------------------------+ 11 | | System Utilities (ls, grep, systemctl, etc.) | <-- Part of the OS 12 | +----------------------------------------------------+ 13 | | Linux Kernel (Process, Memory, FS, Network) | <-- Core of the OS 14 | +----------------------------------------------------+ 15 | | Hardware (CPU, RAM, Disk, Network, Peripherals) | 16 | +----------------------------------------------------+ 17 | 18 | 19 | (a) Hardware Layer 20 | 21 | 🔹 The physical components of the computer (CPU, RAM, disk, network interfaces, etc.). 22 | 🔹 The OS interacts with hardware using device drivers. 23 | (b) Kernel (Core of Linux OS) 24 | 25 | 🔹 The Linux Kernel is responsible for directly managing system resources, including: 26 | 27 | Process Management – Schedules processes and handles multitasking. 28 | 29 | Memory Management – Allocates and deallocates RAM efficiently. 30 | 31 | Device Drivers – Acts as an interface between software and hardware. 32 | 33 | File System Management – Manages how data is stored and retrieved. 34 | 35 | Network Management – Handles communication between systems. 36 | 37 | (c) Shell (Command Line Interface - CLI) 38 | 39 | 🔹 A command interpreter that allows users to interact with the kernel. 40 | 🔹 Examples: Bash, Zsh, Fish, Dash, Ksh. 41 | 🔹 Converts user commands into system calls for the kernel. 42 | (d) User Applications 43 | 44 | 🔹 End-user programs like web browsers, text editors, DevOps tools, etc. 45 | 🔹 Applications interact with the OS using system calls via the shell or GUI. -------------------------------------------------------------------------------- /01-getting-started/03-linux-distributions.md: -------------------------------------------------------------------------------- 1 | # Linux Distributions 2 | 3 | Linux distributions (distros) are different versions of Linux that package the Linux kernel with various software, system utilities, and package managers. Each distro is designed for different use cases, such as personal computing, server management, or security. 4 | 5 | Here are some popular Linux distributions: 6 | 7 | Ubuntu – One of the most beginner-friendly distros, widely used for personal and server use. It has great community support. 8 | 9 | CentOS (discontinued, replaced by AlmaLinux/Rocky Linux) – Previously a popular choice for servers, based on Red Hat Enterprise Linux (RHEL). 10 | 11 | Debian – A very stable and reliable distro, often used as a base for other distros like Ubuntu. 12 | 13 | Fedora – A cutting-edge distro that introduces new features before they reach RHEL. 14 | 15 | Arch Linux – A lightweight, rolling-release distro for advanced users who like customization. 16 | 17 | Kali Linux – Designed for cybersecurity and penetration testing. 18 | 19 | Alpine Linux – A lightweight, security-focused distro often used in containers. 20 | 21 | 22 | ### Useful References: 23 | 24 | - Linux Kernel Source code: 25 | http://git.kernel.org/ 26 | 27 | - Mirror of Linux Kernel on GitHub: 28 | http://github.com/torvalds/linux 29 | 30 | -------------------------------------------------------------------------------- /01-getting-started/04-setup.md: -------------------------------------------------------------------------------- 1 | # Setup Linux Environment on Windows and MacOS 2 | 3 | There are multiple ways to setup a Linux environment on a Windows or Mac machines such as `cloud vm`, `wsl2`, `virtualbox`, `Hyperkit` e.t.c.,. However what I would recommend is using a container as a Linux environment. 4 | 5 | Just install Docker desktop, run the below command and create linux container of any distribution without worrying about the cost and connectivity issues. 6 | 7 | ### Docker Command to Run Ubuntu Linux Container in windows host (Persistent & Long-Term) 8 | 9 | - Create a folder with name `ubuntu-data` in your downloads folder. 10 | 11 | - Then run the below command in `poweshell` updating your `username`. 12 | 13 | ```bash 14 | docker run -dit ` 15 | --name ubuntu-container ` 16 | --hostname ubuntu-dev ` 17 | --restart unless-stopped ` 18 | --cpus="2" ` 19 | --memory="4g" ` 20 | --mount type=bind,source="C:/Users/Monica Korla/Downloads/ubuntu-container",target=/data ` 21 | -v /var/run/docker.sock:/var/run/docker.sock ` 22 | -p 2222:22 ` 23 | -p 8080:80 ` 24 | --env TZ=Asia/Kolkata ` 25 | --env LANG=en_US.UTF-8 ` 26 | ubuntu:latest /bin/bash 27 | ``` 28 | 29 | ### Docker Command to Run Ubuntu Linux Container in mac or linux host (Persistent & Long-Term) 30 | 31 | ```bash 32 | docker run -dit \ 33 | --name ubuntu-container \ 34 | --hostname ubuntu-dev \ 35 | --restart unless-stopped \ 36 | --cpus="2" \ 37 | --memory="4g" \ 38 | --mount type=bind,source=/tmp/ubuntu-data,target=/data \ 39 | -v /var/run/docker.sock:/var/run/docker.sock \ 40 | -p 2222:22 \ 41 | -p 8080:80 \ 42 | --env TZ=Asia/Kolkata \ 43 | --env LANG=en_US.UTF-8 \ 44 | ubuntu:latest /bin/bash 45 | 46 | ``` 47 | 48 | ## Explanation of Each Parameter 49 | 50 | | Parameter | Description | 51 | |-----------|-------------| 52 | | `-dit` | Runs the container in **detached (-d)**, **interactive (-i)**, and **terminal (-t)** mode. | 53 | | `--name ubuntu-container` | Assigns a name to the container for easy management. | 54 | | `--hostname ubuntu-dev` | Sets the container’s hostname. | 55 | | `--restart unless-stopped` | Ensures the container restarts automatically unless manually stopped. | 56 | | `--cpus="2"` | Limits the container to **2 CPU cores**. | 57 | | `--memory="4g"` | Allocates **4GB RAM** to the container. | 58 | | `--mount type=bind,source=C:/ubuntu-data,target=/data` | **Mounts a folder** from Windows into the container to persist data. | 59 | | `-v /var/run/docker.sock:/var/run/docker.sock` | Allows running Docker commands inside the container (optional). | 60 | | `-p 2222:22` | Maps port **2222** on the host to **22** (SSH) inside the container. | 61 | | `-p 8080:80` | Maps port **8080** on the host to **80** (for web services). | 62 | | `--env TZ=Asia/Kolkata` | Sets the **timezone** (modify based on your location). | 63 | | `--env LANG=en_US.UTF-8` | Sets the **language** settings inside the container. | 64 | | `ubuntu:latest /bin/bash` | Uses the latest **Ubuntu** image and runs Bash shell. | 65 | -------------------------------------------------------------------------------- /01-getting-started/05-package-manager.md: -------------------------------------------------------------------------------- 1 | # Package Managers in Linux 2 | 3 | ## 📌 What is a Package Manager? 4 | A **package manager** is a tool that automates the process of installing, updating, configuring, and removing software in a Linux system. It ensures that software and its dependencies are managed efficiently. 5 | 6 | ## 🔍 How Does a Package Manager Work? 7 | 1. **Repositories (Repos):** 8 | - A package manager fetches software from **official repositories (online storage of packages).** 9 | - Example: Ubuntu gets packages from `archive.ubuntu.com`. 10 | 11 | 2. **Installing Software:** 12 | - When you install software, the package manager: 13 | ✅ Downloads the package from the repository. 14 | ✅ Resolves dependencies (installs additional required software). 15 | ✅ Installs and configures the software automatically. 16 | 17 | 3. **Updating Software:** 18 | - A single command updates all installed packages to the latest version. 19 | 20 | 4. **Removing Software:** 21 | - The package manager also **removes** software cleanly without leaving unnecessary files. 22 | 23 | ## 📦 Popular Package Managers in Linux 24 | | Linux Distro | Package Manager | Command Example | 25 | |---------------|----------------|----------------| 26 | | Ubuntu, Debian | `apt` (Advanced Package Tool) | `sudo apt install nginx` | 27 | | Fedora, RHEL, CentOS | `dnf` (or `yum` for older versions) | `sudo dnf install nginx` | 28 | | Arch Linux | `pacman` | `sudo pacman -S nginx` | 29 | | OpenSUSE | `zypper` | `sudo zypper install nginx` | 30 | 31 | ## 🌍 How Package Managers Fetch Software from Repositories 32 | A **repository** is a server that stores software packages. When a package manager installs software: 33 | 34 | 1. It **checks the repository list** (e.g., `/etc/apt/sources.list` in Ubuntu). 35 | 2. It **downloads the package** and its dependencies. 36 | 3. It **installs and configures the software** automatically. 37 | 38 | ### 📁 Example of an Ubuntu Repository Entry 39 | ```plaintext 40 | Types: deb 41 | URIs: http://ports.ubuntu.com/ubuntu-ports/ 42 | Suites: noble noble-updates noble-backports noble-security 43 | Components: main universe restricted multiverse 44 | Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg 45 | ``` 46 | 47 | ## 🔄 Why Should You Run `apt update` After Installing Ubuntu? 48 | When you install Ubuntu, the packages included in the ISO image might be outdated. Running: 49 | ```bash 50 | apt install sudo 51 | sudo apt update 52 | ``` 53 | ✅ Updates the package list from repositories. 54 | 55 | Then, to install the latest versions of packages, run: 56 | ```bash 57 | sudo apt upgrade -y 58 | ``` 59 | 60 | ## 🛠 Essential Package Manager Commands 61 | ### **APT (Debian, Ubuntu)** 62 | ```bash 63 | sudo apt update # Update package lists 64 | sudo apt upgrade -y # Upgrade installed packages 65 | sudo apt install nginx # Install a package 66 | sudo apt remove nginx # Remove a package 67 | sudo apt autoremove # Remove unused dependencies 68 | sudo apt search nginx # Search for a package 69 | ``` 70 | 71 | ### **DNF (Fedora, RHEL, CentOS)** 72 | ```bash 73 | sudo dnf check-update # Check for updates 74 | sudo dnf update # Update all packages 75 | sudo dnf install nginx # Install a package 76 | sudo dnf remove nginx # Remove a package 77 | ``` 78 | 79 | ### **Pacman (Arch Linux)** 80 | ```bash 81 | sudo pacman -Syu # Sync and update all packages 82 | sudo pacman -S nginx # Install a package 83 | sudo pacman -R nginx # Remove a package 84 | ``` 85 | 86 | ### **Zypper (OpenSUSE)** 87 | ```bash 88 | sudo zypper refresh # Refresh package list 89 | sudo zypper update # Update all packages 90 | sudo zypper install nginx # Install a package 91 | sudo zypper remove nginx # Remove a package 92 | ``` 93 | 94 | ## 🚀 Best Practices for Using Package Managers 95 | - ✅ **Always update your package list before installing software:** 96 | ```bash 97 | sudo apt update && sudo apt upgrade -y 98 | ``` 99 | - ✅ **Use `autoremove` to clean up unused dependencies:** 100 | ```bash 101 | sudo apt autoremove 102 | ``` 103 | - ✅ **Enable automatic security updates (Ubuntu):** 104 | ```bash 105 | sudo apt install unattended-upgrades 106 | sudo dpkg-reconfigure unattended-upgrades 107 | ``` 108 | 109 | --- 110 | This document provides a solid foundation for understanding package managers in Linux! 🚀 111 | -------------------------------------------------------------------------------- /02-folder-structure/README.md: -------------------------------------------------------------------------------- 1 | # Understanding the Folder Structure 2 | 3 | ### Explanation of System Directories 4 | 5 | ### **Symbolic Links (Less Significant)** 6 | | Directory | Description | 7 | |-----------|-------------| 8 | | `/sbin -> /usr/sbin` | System binaries for administrative commands (linked to `/usr/sbin`). | 9 | | `/bin -> /usr/bin` | Essential user binaries (linked to `/usr/bin`). | 10 | | `/lib -> /usr/lib` | Shared libraries and kernel modules (linked to `/usr/lib`). | 11 | 12 | ### **Important System Directories** 13 | | Directory | Description | 14 | |-----------|-------------| 15 | | `/boot` | Stores files needed for booting the system (not relevant in containers). | 16 | | `/usr` | Contains most user-installed applications and libraries. | 17 | | `/var` | Stores logs, caches, and temporary files that change frequently. | 18 | | `/etc` | Stores system configuration files. | 19 | 20 | ### **User & Application-Specific Directories** 21 | | Directory | Description | 22 | |-----------|-------------| 23 | | `/home` | Default location for user home directories. | 24 | | `/opt` | Used for installing optional third-party software. | 25 | | `/srv` | Holds data for services like web servers (rarely used in containers). | 26 | | `/root` | Home directory for the root user. | 27 | 28 | ### **Temporary & Volatile Directories** 29 | | Directory | Description | 30 | |-----------|-------------| 31 | | `/tmp` | Temporary files (cleared on reboot). | 32 | | `/run` | Holds runtime data for processes. | 33 | | `/proc` | Virtual filesystem for process and system information. | 34 | | `/sys` | Virtual filesystem for hardware and kernel information. | 35 | | `/dev` | Contains device files (e.g., `/dev/null`, `/dev/sda`). | 36 | 37 | ### **Mount Points** 38 | | Directory | Description | 39 | |-----------|-------------| 40 | | `/mnt` | Temporary mount point for external filesystems. | 41 | | `/media` | Mount point for removable media (USB, CDs). | 42 | | `/data` | Likely your **mounted volume** from Windows (`C:/ubuntu-data`). | -------------------------------------------------------------------------------- /03-user-management/README.md: -------------------------------------------------------------------------------- 1 | # User Management in Linux 2 | 3 | ## Introduction to User Management in Linux 4 | Linux is a multi-user operating system, meaning multiple users can operate on a system simultaneously. Proper user management ensures security, controlled access, and system integrity. 5 | 6 | Key files involved in user management: 7 | - `/etc/passwd` – Stores user account details. 8 | - `/etc/shadow` – Stores encrypted user passwords. 9 | - `/etc/group` – Stores group information. 10 | - `/etc/gshadow` – Stores secure group details. 11 | 12 | ## Creating Users in Linux 13 | To create a new user in Linux, use: 14 | 15 | ### `useradd` Command (For most Linux distributions) 16 | ```bash 17 | useradd username 18 | ``` 19 | This creates a user without a home directory. 20 | 21 | To create a user with a home directory: 22 | ```bash 23 | useradd -m username 24 | ``` 25 | 26 | To specify a shell: 27 | ```bash 28 | useradd -s /bin/bash username 29 | ``` 30 | 31 | ### `adduser` Command (For Debian-based systems) 32 | ```bash 33 | adduser username 34 | ``` 35 | This is an interactive command that asks for a password and additional details. 36 | 37 | ## Managing User Passwords 38 | To set or change a user’s password: 39 | ```bash 40 | passwd username 41 | ``` 42 | 43 | ### Enforcing Password Policies 44 | - **Password expiration**: Set password expiry days 45 | ```bash 46 | chage -M 90 username 47 | ``` 48 | - **Lock a user account** 49 | ```bash 50 | passwd -l username 51 | ``` 52 | - **Unlock a user account** 53 | ```bash 54 | passwd -u username 55 | ``` 56 | 57 | ## Modifying Users 58 | Modify an existing user with `usermod`: 59 | - Change the username: 60 | ```bash 61 | usermod -l new_username old_username 62 | ``` 63 | - Change the home directory: 64 | ```bash 65 | usermod -d /new/home/directory -m username 66 | ``` 67 | - Change the default shell: 68 | ```bash 69 | usermod -s /bin/zsh username 70 | ``` 71 | 72 | ## Deleting Users 73 | To remove a user but keep their home directory: 74 | ```bash 75 | userdel username 76 | ``` 77 | To remove a user and their home directory: 78 | ```bash 79 | userdel -r username 80 | ``` 81 | 82 | ## Working with Groups 83 | ### Creating Groups 84 | ```bash 85 | groupadd groupname 86 | ``` 87 | 88 | ### Adding Users to Groups 89 | ```bash 90 | usermod -aG groupname username 91 | ``` 92 | 93 | ### Viewing Group Memberships 94 | ```bash 95 | groups username 96 | ``` 97 | 98 | ### Changing Primary Group 99 | ```bash 100 | usermod -g new_primary_group username 101 | ``` 102 | 103 | ## Sudo Access and Privilege Escalation 104 | ### Adding a User to Sudo Group 105 | On Debian-based systems: 106 | ```bash 107 | usermod -aG sudo username 108 | ``` 109 | On RHEL-based systems: 110 | ```bash 111 | usermod -aG wheel username 112 | ``` 113 | 114 | ### Granting Specific Commands with Sudo 115 | Edit the sudoers file: 116 | ```bash 117 | visudo 118 | ``` 119 | Then add: 120 | ```bash 121 | username ALL=(ALL) NOPASSWD: /path/to/command 122 | ``` 123 | -------------------------------------------------------------------------------- /04-file-management/README.md: -------------------------------------------------------------------------------- 1 | # File management in Linux 2 | 3 | ### File and Directory Management 4 | 1. **`ls`** – Lists files and directories in the current location. 5 | 2. **`cd /path/to/directory`** – Changes the working directory. 6 | 3. **`pwd`** – Prints the current working directory. 7 | 4. **`mkdir new_folder`** – Creates a new directory. 8 | 5. **`rmdir empty_folder`** – Removes an empty directory. 9 | 6. **`rm file.txt`** – Deletes a file. 10 | 7. **`rm -r folder`** – Deletes a folder and its contents. 11 | 8. **`cp file1.txt file2.txt`** – Copies a file. 12 | 9. **`cp -r dir1 dir2`** – Copies a directory recursively. 13 | 10. **`mv old_name new_name`** – Moves or renames a file or directory. 14 | 15 | ### File Viewing and Editing 16 | 11. **`cat file.txt`** – Displays file content. 17 | 12. **`tac file.txt`** – Displays file content in reverse order. 18 | 13. **`less file.txt`** – Opens a file for viewing with scrolling support. 19 | 14. **`more file.txt`** – Similar to `less`, but only moves forward. 20 | 15. **`head -n 10 file.txt`** – Displays the first 10 lines of a file. 21 | 16. **`tail -n 10 file.txt`** – Displays the last 10 lines of a file. 22 | 17. **`nano file.txt`** – Opens a simple text editor. 23 | 18. **`vi file.txt`** – Opens a powerful text editor. 24 | 19. **`echo 'Hello' > file.txt`** – Writes text to a file, overwriting existing content. 25 | 20. **`echo 'Hello' >> file.txt`** – Appends text to a file without overwriting. 26 | 27 | 28 | -------------------------------------------------------------------------------- /05-vi-shortcuts/README.md: -------------------------------------------------------------------------------- 1 | # VI Editor Shortcuts 2 | 3 | ### Modes in VI Editor 4 | - **Normal Mode** (default) – Used for navigation and command execution. 5 | - **Insert Mode** – Used for text editing (press `i` to enter, `Esc` to exit). 6 | - **Command Mode** – Used for saving, quitting, and searching (press `:` in Normal mode). 7 | 8 | --- 9 | 10 | ### Basic Navigation 11 | - `h` – Move **left** 12 | - `l` – Move **right** 13 | - `j` – Move **down** 14 | - `k` – Move **up** 15 | - `0` – Move to the **beginning** of the line 16 | - `^` – Move to the **first non-blank** character of the line 17 | - `$` – Move to the **end** of the line 18 | - `w` – Move to the **next word** 19 | - `b` – Move to the **previous word** 20 | - `gg` – Move to the **start** of the file 21 | - `G` – Move to the **end** of the file 22 | - `:n` – Move to **line number `n`** 23 | 24 | --- 25 | 26 | ### Insert Mode Shortcuts 27 | - `i` – Insert before cursor 28 | - `I` – Insert at the beginning of the line 29 | - `a` – Append after cursor 30 | - `A` – Append at the end of the line 31 | - `o` – Open a new line below 32 | - `O` – Open a new line above 33 | - `Esc` – Exit insert mode 34 | 35 | --- 36 | 37 | ### Editing Text 38 | - `x` – Delete a **character** 39 | - `X` – Delete a **character before cursor** 40 | - `dw` – Delete a **word** 41 | - `dd` – Delete a **line** 42 | - `d$` – Delete from **cursor to end of line** 43 | - `d0` – Delete from **cursor to beginning of line** 44 | - `D` – Delete from **cursor to end of line** 45 | - `u` – **Undo** last action 46 | - `Ctrl + r` – **Redo** an undone change 47 | - `yy` – Copy (yank) a **line** 48 | - `yw` – Copy (yank) a **word** 49 | - `p` – Paste **after** the cursor 50 | - `P` – Paste **before** the cursor 51 | 52 | --- 53 | 54 | ### Search and Replace 55 | - `/pattern` – Search **forward** for a pattern 56 | - `?pattern` – Search **backward** for a pattern 57 | - `n` – Repeat last search **forward** 58 | - `N` – Repeat last search **backward** 59 | - `:%s/old/new/g` – Replace **all occurrences** of "old" with "new" 60 | - `:s/old/new/g` – Replace **all occurrences** in the current line 61 | 62 | --- 63 | 64 | ### Working with Multiple Files 65 | - `:e filename` – Open a **new file** 66 | - `:w` – Save file 67 | - `:wq` – Save and exit 68 | - `:q!` – Quit **without saving** 69 | - `:split filename` – Split screen **horizontally** and open another file 70 | - `:vsplit filename` – Split screen **vertically** 71 | - `Ctrl + w + w` – Switch between split screens 72 | 73 | --- 74 | -------------------------------------------------------------------------------- /06-file-permissions/README.md: -------------------------------------------------------------------------------- 1 | # File Permissions Management in Linux 2 | 3 | ## Introduction to File Permissions 4 | Linux file permissions determine who can read, write, or execute files and directories. Each file and directory has three levels of permission: 5 | - **Owner (User)**: The creator of the file. 6 | - **Group**: Users belonging to the assigned group. 7 | - **Others**: All other users on the system. 8 | 9 | Permissions are represented as: 10 | - **Read (`r` or `4`)** – View file contents. 11 | - **Write (`w` or `2`)** – Modify file contents. 12 | - **Execute (`x` or `1`)** – Run scripts or programs. 13 | 14 | To check file permissions, use: 15 | ```bash 16 | ls -l filename 17 | ``` 18 | Output example: 19 | ```bash 20 | -rwxr--r-- 1 user group 1234 Mar 28 10:00 myfile.sh 21 | ``` 22 | 23 | ## Changing Permissions with `chmod` 24 | ### Using Symbolic Mode 25 | Modify permissions using symbols: 26 | - Add (`+`), remove (`-`), or set (`=`) permissions. 27 | 28 | Examples: 29 | ```bash 30 | chmod u+x filename # Add execute for user 31 | chmod g-w filename # Remove write for group 32 | chmod o=r filename # Set read-only for others 33 | chmod u=rwx,g=rx,o= filename # Set full access for user, read/execute for group, and no access for others 34 | ``` 35 | 36 | ### Using Numeric (Octal) Mode 37 | Each permission has a value: 38 | - Read (`4`), Write (`2`), Execute (`1`). 39 | 40 | Examples: 41 | ```bash 42 | chmod 755 filename # User (rwx), Group (r-x), Others (r-x) 43 | chmod 644 filename # User (rw-), Group (r--), Others (r--) 44 | chmod 700 filename # User (rwx), No access for others 45 | ``` 46 | 47 | ## Changing Ownership with `chown` 48 | Modify file owner and group: 49 | ```bash 50 | chown newuser filename # Change owner 51 | chown newuser:newgroup filename # Change owner and group 52 | chown :newgroup filename # Change only group 53 | ``` 54 | 55 | Recursively change ownership: 56 | ```bash 57 | chown -R newuser:newgroup directory/ 58 | ``` 59 | 60 | ## Changing Group Ownership with `chgrp` 61 | ```bash 62 | chgrp newgroup filename # Change group 63 | chgrp -R newgroup directory/ # Change group recursively 64 | ``` 65 | 66 | ## Special Permissions 67 | ### SetUID (`s` on user execute bit) 68 | Allows users to run a file with the file owner's permissions. 69 | ```bash 70 | chmod u+s filename 71 | ``` 72 | Example: `/usr/bin/passwd` allows users to change their passwords. 73 | 74 | ### SetGID (`s` on group execute bit) 75 | Files: Users run the file with the group's permissions. 76 | Directories: Files created inside inherit the group. 77 | ```bash 78 | chmod g+s filename # Set on file 79 | chmod g+s directory/ # Set on directory 80 | ``` 81 | 82 | ### Sticky Bit (`t` on others execute bit) 83 | Used on directories to allow only the owner to delete their files. 84 | ```bash 85 | chmod +t directory/ 86 | ``` 87 | Example: `/tmp` directory. 88 | 89 | ## Default Permissions: `umask` 90 | `umask` defines default permissions for new files and directories. 91 | Check current umask: 92 | ```bash 93 | umask 94 | ``` 95 | Set a new umask: 96 | ```bash 97 | umask 022 # Default: 755 for directories, 644 for files 98 | ``` 99 | 100 | ## Conclusion 101 | Understanding file permissions is essential for system security and proper file management. Using `chmod`, `chown`, and `chgrp`, you can control access to files and directories efficiently. 102 | -------------------------------------------------------------------------------- /07-process-management/README.md: -------------------------------------------------------------------------------- 1 | # Process Management in Linux 2 | 3 | ## Introduction to Process Management 4 | A process is an instance of a running program. Linux provides multiple utilities to monitor, manage, and control processes effectively. Each process has a unique **Process ID (PID)** and belongs to a parent process. 5 | 6 | ## Index of Commands Covered 7 | 8 | ### Viewing Processes 9 | - `ps aux` – View all running processes 10 | - `ps -u username` – View processes for a specific user 11 | - `ps -C processname` – Show a process by name 12 | - `pgrep processname` – Find a process by name and return its PID 13 | - `pidof processname` – Find the PID of a running program 14 | 15 | ### Managing Processes 16 | - `kill PID` – Terminate a process by PID 17 | - `pkill processname` – Terminate a process by name 18 | - `kill -9 PID` – Force kill a process 19 | - `pkill -9 processname` – Kill all instances of a process 20 | - `kill -STOP PID` – Stop a running process 21 | - `kill -CONT PID` – Resume a stopped process 22 | - `renice -n 10 -p PID` – Lower priority of a process 23 | - `renice -n -5 -p PID` – Increase priority of a process (requires root) 24 | 25 | ### Background & Foreground Processes 26 | - `command &` – Run a command in the background 27 | - `jobs` – List background jobs 28 | - `fg %jobnumber` – Bring a job to the foreground 29 | - `Ctrl + Z` – Suspend a running process 30 | - `bg %jobnumber` – Resume a suspended process in the background 31 | 32 | ### Monitoring System Processes 33 | - `top` – Interactive process viewer 34 | - `htop` – User-friendly process viewer (requires installation) 35 | - `nice -n 10 command` – Run a command with a specific priority 36 | - `renice -n -5 -p PID` – Change priority of an existing process 37 | 38 | ### Daemon Process Management 39 | - `systemctl list-units --type=service` – List all system daemons 40 | - `systemctl start service-name` – Start a daemon/service 41 | - `systemctl stop service-name` – Stop a daemon/service 42 | - `systemctl enable service-name` – Enable a service at startup 43 | 44 | ## Viewing Process Details 45 | ### Using `ps` 46 | Show processes for a specific user: 47 | ```bash 48 | ps -u username 49 | ``` 50 | Show a process by name: 51 | ```bash 52 | ps -C processname 53 | ``` 54 | 55 | ### Using `pgrep` 56 | Find a process by name and return its PID: 57 | ```bash 58 | pgrep processname 59 | ``` 60 | 61 | ### Using `pidof` 62 | Find the PID of a running program: 63 | ```bash 64 | pidof processname 65 | ``` 66 | 67 | ## Managing Processes 68 | ### Killing Processes 69 | To terminate a process by PID: 70 | ```bash 71 | kill PID 72 | ``` 73 | To terminate using process name: 74 | ```bash 75 | pkill processname 76 | ``` 77 | Force kill a process: 78 | ```bash 79 | kill -9 PID 80 | ``` 81 | Kill all instances of a process: 82 | ```bash 83 | pkill -9 processname 84 | ``` 85 | 86 | ### Stopping & Resuming Processes 87 | Stop a running process: 88 | ```bash 89 | kill -STOP PID 90 | ``` 91 | Resume a stopped process: 92 | ```bash 93 | kill -CONT PID 94 | ``` 95 | 96 | ### Changing Process Priority 97 | View process priorities: 98 | ```bash 99 | top # Look at the NI column 100 | ``` 101 | Change priority of a running process: 102 | ```bash 103 | renice -n 10 -p PID # Lower priority (positive values) 104 | renice -n -5 -p PID # Higher priority (negative values, root required) 105 | ``` 106 | 107 | ### Running Processes in the Background 108 | Run a command in the background: 109 | ```bash 110 | command & 111 | ``` 112 | List background jobs: 113 | ```bash 114 | jobs 115 | ``` 116 | Bring a job to the foreground: 117 | ```bash 118 | fg %jobnumber 119 | ``` 120 | Send a running process to the background: 121 | ```bash 122 | Ctrl + Z # Suspend process 123 | bg %jobnumber # Resume in background 124 | ``` 125 | 126 | ## Monitoring System Processes 127 | ### Using `top` 128 | Interactive process viewer: 129 | - Press `k` and enter a PID to kill a process. 130 | - Press `r` to renice a process. 131 | - Press `q` to quit. 132 | 133 | ### Using `htop` 134 | A user-friendly alternative to `top`: 135 | ```bash 136 | htop 137 | ``` 138 | Allows mouse-based interaction for process management. 139 | 140 | ### Using `nice` & `renice` 141 | Run a command with a specific priority: 142 | ```bash 143 | nice -n 10 command 144 | ``` 145 | Change the priority of an existing process: 146 | ```bash 147 | renice -n -5 -p PID 148 | ``` 149 | 150 | ## Daemon Processes 151 | Daemon processes run in the background without user intervention. 152 | List all system daemons: 153 | ```bash 154 | systemctl list-units --type=service 155 | ``` 156 | Start a daemon: 157 | ```bash 158 | systemctl start service-name 159 | ``` 160 | Stop a daemon: 161 | ```bash 162 | systemctl stop service-name 163 | ``` 164 | Enable a service at startup: 165 | ```bash 166 | systemctl enable service-name 167 | ``` 168 | 169 | ## Conclusion 170 | Process management is crucial for system performance and stability. By using tools like `ps`, `top`, `htop`, `kill`, and `nice`, you can efficiently control and monitor Linux processes. 171 | -------------------------------------------------------------------------------- /08-monitoring/README.md: -------------------------------------------------------------------------------- 1 | # Linux System Monitoring 2 | 3 | ## Introduction to System Monitoring 4 | Monitoring system resources is essential to ensure optimal performance, detect issues, and troubleshoot problems in Linux. Various tools allow us to monitor CPU, memory, disk usage, network activity, and running processes. 5 | 6 | ## Index of Commands Covered 7 | 8 | ### CPU and Memory Monitoring 9 | - `top` – Real-time system monitoring 10 | - `htop` – Interactive process viewer (requires installation) 11 | - `vmstat` – Report system performance statistics 12 | - `free -m` – Show memory usage 13 | 14 | ### Disk Monitoring 15 | - `df -h` – Check disk space usage 16 | - `du -sh /path` – Show disk usage of a specific directory 17 | - `iostat` – Display CPU and disk I/O statistics 18 | 19 | ### Network Monitoring 20 | - `ifconfig` – Show network interfaces (deprecated, use `ip a`) 21 | - `ip a` – Show network interface details 22 | - `netstat -tulnp` – Show active connections and listening ports 23 | - `ss -tulnp` – Alternative to `netstat` for socket statistics 24 | - `ping hostname` – Test network connectivity 25 | - `traceroute hostname` – Show network path to a host 26 | - `nslookup domain` – Get DNS resolution details 27 | 28 | ### Log Monitoring 29 | - `tail -f /var/log/syslog` – Live monitoring of system logs 30 | - `journalctl -f` – Live system logs for systemd-based distros 31 | - `dmesg | tail` – View kernel logs 32 | 33 | ## CPU and Memory Monitoring 34 | ### Using `top` 35 | To view real-time CPU and memory usage: 36 | ```bash 37 | top 38 | ``` 39 | Press `q` to quit. 40 | 41 | ### Using `htop` 42 | A user-friendly alternative: 43 | ```bash 44 | htop 45 | ``` 46 | Use arrow keys to navigate and `F9` to kill processes. 47 | 48 | ### Using `vmstat` 49 | To check CPU, memory, and I/O stats: 50 | ```bash 51 | vmstat 1 5 # Update every 1 sec, show 5 updates 52 | ``` 53 | 54 | ### Checking Memory Usage 55 | ```bash 56 | free -m 57 | ``` 58 | Shows free and used memory in megabytes. 59 | 60 | ## Disk Monitoring 61 | ### Using `df` 62 | Check available disk space: 63 | ```bash 64 | df -h 65 | ``` 66 | ### Using `du` 67 | Find the size of a directory: 68 | ```bash 69 | du -sh /var/log 70 | ``` 71 | ### Using `iostat` 72 | Check disk and CPU usage: 73 | ```bash 74 | iostat 75 | ``` 76 | 77 | ## Network Monitoring 78 | ### Checking Network Interfaces 79 | ```bash 80 | ip a # Show IP addresses and interfaces 81 | ``` 82 | ### Viewing Open Ports and Connections 83 | ```bash 84 | netstat -tulnp # Show listening ports 85 | ss -tulnp # Alternative to netstat 86 | ``` 87 | ### Testing Connectivity 88 | ```bash 89 | ping google.com # Test internet connection 90 | traceroute google.com # Trace the path to Google 91 | ``` 92 | ### Checking DNS Resolution 93 | ```bash 94 | nslookup example.com 95 | ``` 96 | 97 | ## Log Monitoring 98 | ### Live Monitoring of System Logs 99 | ```bash 100 | tail -f /var/log/syslog # Follow logs in real-time 101 | journalctl -f # Systemd logs 102 | ``` 103 | ### Checking Kernel Logs 104 | ```bash 105 | dmesg | tail 106 | ``` -------------------------------------------------------------------------------- /09-networking/README.md: -------------------------------------------------------------------------------- 1 | # Networking Commands 2 | 3 | 1. **`ping google.com`** – Checks connectivity to a remote server. 4 | 2. **`ifconfig`** – Displays network interfaces (deprecated, use `ip`). 5 | 3. **`ip a`** – Shows IP addresses of network interfaces. 6 | 4. **`netstat -tulnp`** – Displays open network connections. 7 | 5. **`curl https://example.com`** – Fetches a webpage's content. 8 | 6. **`wget https://example.com/file.zip`** – Downloads a file from the internet. -------------------------------------------------------------------------------- /10-disk-management/README.md: -------------------------------------------------------------------------------- 1 | # Disk and Storage Management in Linux 2 | 3 | ## Introduction to Disk and Storage Management 4 | Managing disks and storage efficiently is crucial for system performance and stability. Linux provides various commands to monitor, partition, format, mount, and manage disk storage. 5 | 6 | ## Index of Commands Covered 7 | 8 | ### Viewing Disk Information 9 | - `lsblk` – Display block devices 10 | - `fdisk -l` – List disk partitions 11 | - `blkid` – Show UUIDs of devices 12 | - `df -h` – Check disk space usage 13 | - `du -sh /path` – Show size of a directory 14 | 15 | ### Partition Management 16 | - `fdisk /dev/sdX` – Create and manage partitions 17 | - `parted /dev/sdX` – Alternative to `fdisk` for GPT disks 18 | - `mkfs.ext4 /dev/sdX1` – Format a partition as ext4 19 | - `mkfs.xfs /dev/sdX1` – Format a partition as XFS 20 | 21 | ### Mounting and Unmounting 22 | - `mount /dev/sdX1 /mnt` – Mount a partition 23 | - `umount /mnt` – Unmount a partition 24 | - `mount -o remount,rw /mnt` – Remount a partition as read-write 25 | 26 | ### Logical Volume Management (LVM) 27 | - `pvcreate /dev/sdX` – Create a physical volume 28 | - `vgcreate vg_name /dev/sdX` – Create a volume group 29 | - `lvcreate -L 10G -n lv_name vg_name` – Create a logical volume 30 | - `mkfs.ext4 /dev/vg_name/lv_name` – Format an LVM partition 31 | - `mount /dev/vg_name/lv_name /mnt` – Mount an LVM partition 32 | 33 | ### Swap Management 34 | - `mkswap /dev/sdX` – Create a swap partition 35 | - `swapon /dev/sdX` – Enable swap space 36 | - `swapoff /dev/sdX` – Disable swap space 37 | 38 | ## Viewing Disk Information 39 | ### Using `lsblk` 40 | List all block devices: 41 | ```bash 42 | lsblk 43 | ``` 44 | ### Using `fdisk` 45 | View partition details: 46 | ```bash 47 | fdisk -l 48 | ``` 49 | ### Using `df` 50 | Check available disk space: 51 | ```bash 52 | df -h 53 | ``` 54 | ### Using `du` 55 | Find the size of a directory: 56 | ```bash 57 | du -sh /var/log 58 | ``` 59 | 60 | ## Partition Management 61 | ### Creating a Partition with `fdisk` 62 | ```bash 63 | fdisk /dev/sdX 64 | ``` 65 | Follow the interactive prompts to create a partition. 66 | 67 | ### Formatting a Partition 68 | Format as ext4: 69 | ```bash 70 | mkfs.ext4 /dev/sdX1 71 | ``` 72 | Format as XFS: 73 | ```bash 74 | mkfs.xfs /dev/sdX1 75 | ``` 76 | 77 | ## Mounting and Unmounting 78 | ### Mount a Partition 79 | ```bash 80 | mount /dev/sdX1 /mnt 81 | ``` 82 | ### Unmount a Partition 83 | ```bash 84 | umount /mnt 85 | ``` 86 | ### Remount a Partition 87 | ```bash 88 | mount -o remount,rw /mnt 89 | ``` 90 | 91 | ## LVM Management 92 | ### Create a Physical Volume 93 | ```bash 94 | pvcreate /dev/sdX 95 | ``` 96 | ### Create a Volume Group 97 | ```bash 98 | vgcreate vg_name /dev/sdX 99 | ``` 100 | ### Create a Logical Volume 101 | ```bash 102 | lvcreate -L 10G -n lv_name vg_name 103 | ``` 104 | ### Format and Mount the Logical Volume 105 | ```bash 106 | mkfs.ext4 /dev/vg_name/lv_name 107 | mount /dev/vg_name/lv_name /mnt 108 | ``` 109 | 110 | ## Swap Management 111 | ### Create a Swap Partition 112 | ```bash 113 | mkswap /dev/sdX 114 | ``` 115 | ### Enable Swap 116 | ```bash 117 | swapon /dev/sdX 118 | ``` 119 | ### Disable Swap 120 | ```bash 121 | swapoff /dev/sdX 122 | ``` 123 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ultimate Linux Guide 2 | 3 | This repository is created to serve as a revision notes for the YouTube course created by **Abhishek Veeramalla**(`iam-veeramalla` on GitHub) on his youtube channel - `Abhishek.Veeramalla`. 4 | 5 | Following topics are covered as part of the course and documentation. 6 | 7 | - Fundamentals of Linux 8 | - Linux vs Windows 9 | - Core components of Linux 10 | - Setup Linux on Windows & MacOS 11 | - Linux folder structure 12 | - Linux user management 13 | - Linux file management 14 | - VI Editor shortcuts (commonly used) 15 | - File permissions 16 | - Process management 17 | - Linux system monitoring 18 | - Basic Networking in Linux 19 | - Disk and Storage management in Linux 20 | 21 | Please refer to the folders at the root level of this repository to go through the documentation. 22 | --------------------------------------------------------------------------------