<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Linux Fundamental]]></title><description><![CDATA[Linux Fundamental]]></description><link>https://linuxbasic.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 13 Oct 2026 17:36:39 GMT</lastBuildDate><atom:link href="https://linuxbasic.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Linux Basics]]></title><description><![CDATA[History of Linux:
Linux came from a Unix family, Linux is a free and open-source software operating system, which Linus Torvalds developed in September 1991.
In 1991, Linus Torvalds was a student at the University of Helsinki, Finland, USA. He develo...]]></description><link>https://linuxbasic.hashnode.dev/linux-basics</link><guid isPermaLink="true">https://linuxbasic.hashnode.dev/linux-basics</guid><category><![CDATA[Linux]]></category><category><![CDATA[linux for beginners]]></category><category><![CDATA[linux-commands]]></category><category><![CDATA[linux-basics]]></category><category><![CDATA[linux kernel]]></category><dc:creator><![CDATA[Neha Sawant]]></dc:creator><pubDate>Tue, 13 May 2025 11:54:17 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-history-of-linux">History of Linux:</h2>
<p>Linux came from a Unix family, Linux is a free and open-source software operating system, which Linus Torvalds developed in September 1991.</p>
<p>In 1991, Linus Torvalds was a student at the University of Helsinki, Finland, USA. He developed the first code of Linux 0.01 and post it on the Minix newsgroup on 17 Sep 1991, his code become so popular people encouraged him to develop new code and he was led to develop new code and release the first “official” version of Linux, version 0.02 on October 5, 1991.</p>
<p>Today many year pass and Linux become one of the most popular operating systems. Today 90% fastest Supercomputers out of 500 run on Linux variants including the top 10.</p>
<h2 id="heading-some-ways-to-install-linux">Some ways to install linux:</h2>
<p>Here are several ways to install Linux on a system, depending on your preferences, hardware setup, and the distribution (distro) you want to use. Here are some common methods:</p>
<h3 id="heading-1-installation-via-bootable-usb-drive-recommended-for-beginners">1. <strong>Installation via Bootable USB Drive (Recommended for Beginners)</strong></h3>
<ul>
<li><p><strong>Create a bootable USB</strong>:</p>
<p>  Download the ISO file of the Linux distribution you want (e.g., Ubuntu, Fedora, Debian).</p>
</li>
<li><p><strong>Install Linux</strong>: Once the system boots from the USB, follow the on-screen prompts to install Linux. You’ll be able to set up partitions, choose your timezone, and create a user account.</p>
</li>
</ul>
<h3 id="heading-2-installation-via-dvd-older-method">2. <strong>Installation via DVD (Older Method)</strong></h3>
<ul>
<li><p><strong>Burn the ISO</strong>: Burn the Linux distribution ISO to a DVD.</p>
</li>
<li><p><strong>Boot from the DVD</strong>: Insert the DVD into your system and restart it.</p>
</li>
<li><p><strong>Follow the Installation Steps</strong>: Similar to the USB method, boot from the DVD and follow the installation instructions.</p>
</li>
</ul>
<h3 id="heading-3-using-virtual-machines">3. <strong>Using Virtual Machines</strong></h3>
<ul>
<li><p><strong>Install a Virtual Machine (VM)</strong>: Use software like <strong>VirtualBox</strong>, <strong>VMware</strong>, or <strong>Hyper-V</strong> to create a virtual machine on your existing OS (Windows, macOS, or Linux).</p>
</li>
<li><p><strong>Install Linux on the VM</strong>: Mount the Linux ISO in the VM and follow the installation steps. This method doesn’t affect your primary OS and is useful for trying out Linux without making changes to your system.</p>
</li>
</ul>
<h3 id="heading-4-installing-via-linux-container-wsl-for-windows-1011">4. <strong>Installing via Linux Container (WSL for Windows 10/11)</strong></h3>
<ul>
<li><strong>Windows Subsystem for Linux (WSL)</strong>: If you’re on Windows 10 or 11, you can install a Linux distribution through WSL. This lets you run a Linux environment directly inside Windows without the need for dual-booting or a VM.</li>
</ul>
<h3 id="heading-5-installing-linux-using-cloud-or-remote-server">5. <strong>Installing Linux Using Cloud or Remote Server</strong></h3>
<ul>
<li>If you're looking to install Linux on a server or cloud platform, most cloud providers (like AWS, Google Cloud, or Azure) offer one-click Linux installations for a variety of distros.</li>
</ul>
<p>Each method has its pros and cons, depending on your use case and experience level. For beginners, using a USB installation with the option to dual boot with Windows is usually the best way to get started. If you're just experimenting or want to try Linux without making changes to your system, a virtual machine or remote server.</p>
<h2 id="heading-linux-file-system-hierarchy">Linux File System Hierarchy:</h2>
<p>In Linux everything is represented as a file including a hardware program, the files are stored in a directory, and every directory contains a file with a tree structure.</p>
<p>That is called File System Hierarchy. Linux uses single rooted, inverted tree-like structure. Root Directory represents with / (forward slash) It is a top-level directory in Linux.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743677932223/88e927dc-527f-4d9c-b198-3cfc369cd803.png" alt class="image--center mx-auto" /></p>
<p><strong>/</strong></p>
<p>The base of the Linux directory is the root. This is the starting point of FSH. Every directory arises from the root directory. It is represented by a forward slash (/). If someone says to look into the slash directory, they refer to the root directory.</p>
<p><strong>/root</strong></p>
<p>It is the home directory for the root user (superuser).</p>
<p><strong>/bin</strong></p>
<p>User Binaries Contains binary executable. Common Linux commands you need to use in single-user modes are located under this directory. Commands used by all the users of the system are located here.</p>
<p><strong>/sbin</strong></p>
<p>SystemBinaries Just like /bin, /sbin also contains binary executables. But, the linux commands located under this directory are used typically by system aministrator, for system maintenance purpose. For example: iptables, reboot, fdisk, ifconfig, swapon</p>
<p><strong>/dev</strong></p>
<p>Device Files it contains hardware device files, Contains device files. These include terminal devices, usb, or any device attached to the system. For example: /dev/tty1, /dev/usbmon0</p>
<p><strong>/var</strong></p>
<p>Variable Files The variable data files such as log files are located in the /var directory. File contents that tend to grow are located in this directory. &gt; This includes</p>
<p>/var/log: System log files generated by OS and other applications.</p>
<p>/var/lib: Contains database and package files.</p>
<p>/var/mail: Contains Emails.</p>
<p>/var/tmp: Contains Temporary files needed for reboot.</p>
<p><strong>/mnt</strong></p>
<p>Mount Directory This directory is used to mount a file system temporarily.</p>
<p><strong>/media</strong></p>
<p>Removable Media Devices The /media directory contains subdirectories where removable media devices inserted into the computer are mounted.</p>
<p><strong>/usr</strong></p>
<p>User Binaries The /usr directory contains applications and files used by users, as opposed to applications and files used by the system.</p>
<p><strong>/etc</strong></p>
<p>Configuration files It contains all configuration files of server The core configuration files are stored in the /etc directory. It controls the behavior of an operating system or application. This directory also contains startup and shutdown program scripts that are used to start or stop individual programs.</p>
<p><strong>/boot</strong></p>
<p>Boot Loader Files The /boot directory contains the files needed to boot the system the GRUB boot loader's files and your Linux kernels are stored here.</p>
<p><strong>/opt</strong></p>
<p>Optional Applications The opt directory is used for installing the application software from third party vendors that are not available in the Linux distribution. Usually, the software code is stored in the opt directory and the binary code is linked to the bin directory so that all users can run that software.</p>
<p><strong>/home</strong></p>
<p>Home Directory It contains secondary users home directory.</p>
<p><strong>/tmp</strong></p>
<p>Temporary Files Directory that contains temporary files created by system and users.</p>
<p>Files under this directory are deleted when system is rebooted.</p>
<h2 id="heading-difference-between-linux-and-windows">Difference between Linux and windows:</h2>
<h3 id="heading-1-kernel">1. <strong>Kernel</strong></h3>
<ul>
<li><p><strong>Linux</strong>: Linux uses the Linux kernel, which is open-source and freely available. It allows users to modify and distribute the OS as they see fit.</p>
</li>
<li><p><strong>Windows</strong>: Windows uses a proprietary kernel developed by Microsoft. It is not open-source, and users cannot modify it.</p>
</li>
</ul>
<h3 id="heading-2-security">2. <strong>Security</strong></h3>
<ul>
<li><p><strong>Linux</strong>: Linux is generally considered more secure out-of-the-box due to its strict user permission model and lower rate of being targeted by malware. It’s also less susceptible to viruses and other forms of malware.</p>
</li>
<li><p><strong>Windows</strong>: Windows has historically been a bigger target for malware and viruses due to its larger user base. However, Microsoft has significantly improved security in recent years with features like Windows Defender and frequent security patches</p>
</li>
</ul>
<h3 id="heading-3-cost"><strong>3. Cost</strong></h3>
<ul>
<li><p><strong>Linux</strong>: Free and open-source. You can download, install, and distribute it without any cost.</p>
</li>
<li><p><strong>Windows</strong>: Typically requires purchasing a license, though it may come pre-installed with a computer.</p>
</li>
</ul>
<h3 id="heading-4software-updates"><strong>4.Software Updates</strong></h3>
<ul>
<li><p><strong>Linux</strong>: Software updates in Linux are often managed through the system's package manager, and updates can be installed more easily without restarting the system.</p>
</li>
<li><p><strong>Windows</strong>: Windows has its update system, and while updates are automatic, they can be intrusive and sometimes require restarting the computer.</p>
</li>
</ul>
<h3 id="heading-architecture-of-linux"><strong>Architecture of Linux:</strong></h3>
<h3 id="heading-1-hardware-layer">1. <strong>Hardware Layer</strong></h3>
<ul>
<li>This is the physical hardware of the system, including components like the CPU, RAM, hard drives, network interfaces, and more. Linux interacts with this layer through drivers and other kernel components.</li>
</ul>
<h3 id="heading-2-kernel">2. <strong>Kernel</strong></h3>
<ul>
<li><strong>The core component</strong> of Linux is the <strong>kernel</strong>, which is responsible for managing system resources, hardware communication, process management, memory management, file systems, and device drivers. The kernel acts as a bridge between the hardware and software applications.</li>
</ul>
<h3 id="heading-3shell">3.<strong>Shell</strong></h3>
<ul>
<li><strong>The Shell</strong> is a command-line interface (CLI) that allows users to interact with the Linux system. The shell interprets user commands and passes them to the kernel for execution. It is the intermediary between the user and the operating system.</li>
</ul>
<h3 id="heading-4application">4.Application</h3>
<ul>
<li><strong>User Applications</strong> run on top of the Linux operating system, utilizing the system resources managed by the kernel. These are the programs that users interact with directly, such as web browsers, text editors, media players, office suites, etc.</li>
</ul>
<h1 id="heading-linux-practicals">Linux Practicals:</h1>
<p>You can connect linux instance by using ‘Ec2 Instance connect‘ and ‘SSH Client‘</p>
<h2 id="heading-practical-1-connect-linux-instance-on-aws-through-ec2-instance-connect">Practical 1: Connect Linux Instance on AWS through EC2 Instance connect.</h2>
<ol>
<li><p>Go to <a target="_blank" href="https://aws.amazon.com/console/">Manage AWS Resources - AWS Management Console - AWS</a></p>
</li>
<li><p>Create AWS Account.</p>
</li>
<li><p>Login your newly created AWS account.</p>
</li>
<li><p>Once you login you will see the home page as below:</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743679029543/da92c7c0-6b5c-4a76-a449-228ae3deb028.png" alt class="image--center mx-auto" /></p>
<p> Search EC2. Click on ‘Launch Instance’ button.</p>
</li>
<li><p>Enter details:</p>
<p> <strong>Name:</strong> Enter any name</p>
<p> <strong>Select Application and OS image:</strong> Ubuntu</p>
<p> <strong>Instance type:</strong> t2.micro (free tier)</p>
<p> <strong>Key pair:</strong> create any key pair for security purpose. Once you create the key it will get download on system.</p>
<p> <strong>Launch the instance.</strong></p>
</li>
<li><p>I have created this instance. <strong>(linuxfordevops)</strong></p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743679337024/3dc0fb81-541c-49ab-a15f-ef61492248d7.png" alt class="image--center mx-auto" /></p>
<p> Select the instance. and click on connect.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743679400157/e5d180d4-ef63-4186-bf33-f951cc559449.png" alt class="image--center mx-auto" /></p>
<p> 9. You will see this window:</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743679468465/947fce9f-1437-40be-8b2f-1d1b9b811ca4.png" alt class="image--center mx-auto" /></p>
<p>Now you are ready to practice.</p>
<h2 id="heading-practical-2-connect-linux-instance-on-aws-through-ssh-client">Practical 2: Connect Linux Instance on AWS through SSH Client.</h2>
<ol>
<li>select instance click on connect. select SSH. DO all this on local cmd.</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743871694421/fda7fe21-6922-42b6-ac63-a79bca766bc9.png" alt class="image--center mx-auto" /></p>
<ol start="2">
<li><p><strong>Check if SSH is available locally or not using ssh command. Check if the SSH key is downloaded locally.</strong> SSH keys are typically stored in the downloads. <strong>List the contents of the</strong> downloads using ls command.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745054052309/81123d31-0689-4c18-9b7b-d9eb66f44591.png" alt class="image--center mx-auto" /></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745054157582/8f1b7da1-116f-4823-89e2-b949f7981d5e.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>enter this command:</p>
<p> <strong>chmod 400 "linux.pem"</strong></p>
<p> linux.pem: is a key of instance</p>
</li>
<li><p>Enter this command cmd:</p>
<p> <strong>ssh -i "linux.pem"</strong> <a target="_blank" href="mailto:ubuntu@ec2-3-137-185-213.us-east-2.compute.amazonaws.com"><strong>ubuntu@ec2-3-137-185-213.us-east-2.compute.amazonaws.com</strong></a> type yes.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745054176402/750722b1-91ab-47b5-a5eb-9a93eaea565f.png" alt class="image--center mx-auto" /></p>
<p> It will connect to remote</p>
</li>
</ol>
<p>This is how from your linux local machine you can connect to instance which is aws/remote.</p>
<p><strong>Note:</strong> If you want to connect Windows to any other remote server, you can use Putty</p>
<h2 id="heading-practical-3-practice-basic-commands">Practical 3: Practice Basic Commands</h2>
<p><strong>Note:</strong> I have used EC2 console for practice.</p>
<p><strong>#pwd</strong> → stands for <strong>Print Working Directory</strong>. It is used to display the current directory you are in.</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743681399611/d5f403e7-77a9-438a-8e9b-3a36665e18a8.png" alt class="image--center mx-auto" /></p>
<p><strong>#ls</strong> → is used to <strong>list directory contents</strong>. It’s one of the most commonly used commands for navigating and managing files and directories</p>
<p><strong>#ls -a</strong> → to find all details</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743681423869/7a41e393-e1ab-4b4f-887c-363b037d55f3.png" alt class="image--center mx-auto" /></p>
<p><strong>#uname</strong> → It provides details about the operating system, kernel, and hardware.</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743681440129/b3d610bc-b4fc-4a1a-98b2-ae4ec6ce8798.png" alt class="image--center mx-auto" /></p>
<p><strong>#uname -r</strong> → it shows version of the kernel</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743681458844/5d6c0bc9-b89c-46d1-af1b-d7ca5a76de96.png" alt class="image--center mx-auto" /></p>
<p><strong>#mkdir</strong> → to create directory</p>
<p><strong>#mkdir dir1 dir2 dir3</strong> → Can create multiple directories.</p>
<p><strong>#touch /dir{1..10}</strong> → Can create number of files.</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743681544340/be9a2fd9-236a-4385-aef7-b739b99d4311.png" alt class="image--center mx-auto" /></p>
<p><strong>#cd</strong> → stands for <strong>Change Directory</strong>. It is used to navigate between directories in the filesystem.</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743681581826/5641bdc9-8f17-4f94-bcca-738427487d59.png" alt class="image--center mx-auto" /></p>
<p><strong>#clear</strong> → used to clear the terminal screen</p>
<p><strong>#history</strong> → used to display the list of commands that have been entered in the terminal. This can be very useful for reviewing past commands</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743681633730/10cf2e40-12ce-4d7f-8c58-00eb3d3f4e81.png" alt class="image--center mx-auto" /></p>
<p><strong>#date</strong> → it shows time and date</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743681656111/b2cdbd73-583b-44ce-963d-ec47017791f7.png" alt class="image--center mx-auto" /></p>
<p><strong>#cd ..</strong> → is used to move up one directory level from your current location</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743681743925/7b73ce28-2138-4bf5-9aa3-5e34b08c16fb.png" alt class="image--center mx-auto" /></p>
<p><strong>#touch</strong> → to create empty file.</p>
<p><strong>#touch file1 file2 file3</strong> →Can create multiple files.</p>
<p><strong>#touch files{1..10}</strong> → Can create number of files.</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743681821658/2fae142a-9132-4ca3-864c-8b885549f470.png" alt class="image--center mx-auto" /></p>
<p><strong>#echo</strong> → to print data</p>
<p><strong>#cat</strong> → used to display the contents of files.</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743682022098/acc5c505-8c1a-47c7-a29a-1104e18e50e1.png" alt class="image--center mx-auto" /></p>
<p><strong>#echo</strong> “Linux practise” &gt; file1.txt → we print data in file1.txt file</p>
<p><strong>#rm</strong> → to remove file</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743682189449/2bb42d1d-571d-4bfd-8a65-5a4f8dead452.png" alt class="image--center mx-auto" /></p>
<p><strong>#rmdir</strong> → to remove directory</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743682227555/a6927f5f-29f7-4949-a0df-9777417de121.png" alt class="image--center mx-auto" /></p>
<p><strong>#head</strong> → it shows the first 10 lines of a file.</p>
<p><strong>#tail</strong> → it shows the last 10 lines of a file</p>
<p><strong>#tail -f</strong> → used to follow the contents of a file in real-time. This is particularly useful for monitoring log files as they are being updated.</p>
<p><strong>Ctrl + c</strong> → to exit from file.</p>
<h3 id="heading-cut-command">#Cut Command:</h3>
<ul>
<li>used to extract sections from each line of input, typically from files.</li>
</ul>
<p><strong>Syntax:</strong> cut [OPTION]... [FILE]...</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-b</code> : Selects bytes.</p>
</li>
<li><p><code>-c</code> : Selects characters.</p>
</li>
<li><p><code>-f</code> : Selects fields, separated by a delimiter.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743869000108/9e5b2872-a9c6-4ffe-8540-e8755497cea1.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-tee-command">#Tee command:</h3>
<ul>
<li>It is useful for logging or saving command outputs while still displaying them on the terminal.</li>
</ul>
<p><strong>Syntax:</strong> command | tee [OPTION][FILE]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743869381185/08d5326a-8737-42bd-8dcf-45546b7d71e5.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-diff">#diff:</h3>
<ul>
<li>It outputs the differences between the files, which is useful for identifying changes or discrepancies.</li>
</ul>
<p><strong>Syntax:</strong> diff [OPTION] FILES1 FILE2</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743870346180/dede1493-798e-444b-8ed1-66dba54ccbba.png" alt class="image--center mx-auto" /></p>
<p><strong>#wc</strong> → count the words from file.</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743691414938/45b70998-ed12-4636-8baf-2216944c5b44.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-vi-editor">#vi editor:</h3>
<ul>
<li>to edit file.</li>
</ul>
<p><strong>Syntax</strong>: vi file.txt</p>
<p>Note: create file using vi command. To enter data follow below commands:</p>
<p><strong>i - insert, esc - escape from insert operation, :wq - to come out from file</strong></p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743870632038/75005433-eb25-4dea-a017-f9b3d9ca3a94.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-sort">#sort</h3>
<ul>
<li>is used to sort lines of text files</li>
</ul>
<p>Syntax: is used to sort lines of text files</p>
<h3 id="heading-options"><strong>Options</strong></h3>
<ul>
<li><p><code>-n</code> : Sort numerically.</p>
</li>
<li><p><code>-r</code> : Reverse the order of the sort.</p>
</li>
<li><p><code>-k</code> : Sort based on a specific key (column).</p>
</li>
<li><p><code>-t</code> : Specify a delimiter.</p>
</li>
<li><p><code>-u</code> : Output only unique lines.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743870778108/706ef76e-6755-4d2c-a687-e2345ea51193.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-practical-4-copy-command-create-copythisfiletxt-and-paste-in-cloud-and-devops-directory">Practical 4: Copy Command: Create copythisfile.txt and paste in cloud and devops directory.</h2>
<h3 id="heading-cp">Cp</h3>
<ul>
<li>cp command is used for copy and paste file or directory</li>
</ul>
<p><strong>Syntax:</strong> #cp &lt;options&gt; &lt;source&gt; &lt;destination&gt;</p>
<ol>
<li><p>create <strong>copythisfile.txt</strong> using touch command</p>
</li>
<li><p>check all files using <strong>ls</strong></p>
</li>
<li><p>copy <strong>copythifile.txt</strong> paste in <strong>devops</strong> directory</p>
</li>
<li><p>go to <strong>devops</strong> directory and check using <strong>ls</strong> command, file is copied or not. after checking come back in root folder using <strong>cd ..</strong> command.</p>
</li>
<li><p>copy <strong>copythifile.txt</strong> paste in <strong>cloud</strong> directory</p>
</li>
<li><p>go to <strong>cloud</strong> directory and check using <strong>ls</strong> command, file is copied or not. after checking come back in root folder using <strong>cd ..</strong> command.</p>
<p> <strong>Example:</strong></p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743689642685/569a5d57-0588-40b9-ad14-59ca8cb7a98e.png" alt class="image--center mx-auto" /></p>
<p>When you are out of the directory still you can copy the file from directory and paste in another directory by using path.</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743690037945/56dfd9a8-23bf-47f6-a85d-49ed72f74d4b.png" alt class="image--center mx-auto" /></p>
<p>Copied <strong>cloud</strong> directory to <strong>devops</strong> directory</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743690603741/1cccb3b9-0608-4999-b35b-179f1e6a35c0.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-practical-5-move-command-create-file1txt-inside-devops-directory-and-move-that-text-file-to-cloud-directory">Practical 5: Move command- Create file1.txt inside devops directory and move that text file to cloud directory.</h2>
<ul>
<li>to transfer file from source to destination.</li>
</ul>
<p>1. We have files and folders. We created <strong>file1.txt</strong> file in <strong>devops directory</strong> using <strong>touch</strong> command.</p>
<p>2.Then we move file from <strong>devops</strong> folder to cloud folder using <strong>mv</strong> command.</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745825808622/13c82419-3914-4a7f-b059-09dc2c31b439.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-practical-6-rename-file-devops-to-linuxfordev-using-mv-command">Practical 6: Rename file- devops to Linux_for_dev using mv command</h2>
<p><strong>Syntax:</strong> mv existing_folder new_name</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743691203100/7ce42e29-51ee-41b8-a669-2826a592695d.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-practical-7-softlink-amp-hardlink-create-softlink-for-soflinkpractisetxt-file-which-is-in-linuxfordev-directory">Practical 7: Softlink &amp; Hardlink- Create softlink for Soflinkpractise.txt file which is in linux_for_dev directory.</h2>
<ol>
<li><p>Create SoftLink for <strong>soflinkpractise.txt</strong> and this file is placed inside <strong>linux_for_dev</strong> folder.</p>
<p> <strong>Example:</strong></p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743776695513/05da0fd6-d0ad-4075-94c9-c5acdef31b2d.png" alt class="image--center mx-auto" /></p>
<p> Check softlink path using <strong>pwd</strong> command. and create softLink</p>
<p> <strong>syntax:</strong> ln -s location_of <em>file give</em>_name_to_softlink</p>
<p> <strong>Example:</strong></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743777171460/d6cf6997-1f82-42ea-89c1-2bc4416ffc94.png" alt class="image--center mx-auto" /></p>
<p> <strong>Note:</strong> don’t make SoftLink inside location create softlink at root directory.</p>
</li>
<li><p>Now you can change content into file by using SoftLink directly.</p>
<p> <strong>Example:</strong></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743777287247/953ad360-2bf0-4f06-99a0-2f36f8873c8e.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>SoftLink will be deleted if source location is deleted. It will be in <strong>red</strong> color.</p>
<p> <strong>Example:</strong></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743777424368/50b740ae-0fd3-4286-ae0f-f0c22429197c.png" alt class="image--center mx-auto" /></p>
</li>
</ol>
<h3 id="heading-hardlink">Hardlink:</h3>
<p><strong>Note:</strong> HardLink will be not deleted if source location is deleted.</p>
<ol>
<li>In this example me made <strong>demo.txt</strong> as HardLink.</li>
</ol>
<p><strong>syntax:</strong> ln location_of_<em>file give</em>_name_to_hardlink</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743779979832/5bffea01-9293-4b44-b5b9-25bf580711a7.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-practical-8-disk-usage-commands">Practical 8: Disk Usage Commands</h2>
<h3 id="heading-df-and-df-h">#df and df -h</h3>
<ul>
<li>This command shows the amount of disk space used and available on the mounted filesystems.</li>
</ul>
<p><strong>Syntax:</strong> df [OPTION]... [FILE]...</p>
<p><strong>Options:</strong></p>
<ul>
<li><code>-h</code>: Print sizes in human-readable format (e.g., 1K, 234M, 2G).</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743882153910/70b29b85-719b-4c6c-8674-63c9098ad2cf.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-du-disk-utility">du: disk utility</h3>
<ul>
<li>to know about specific folder</li>
</ul>
<p><strong>Syntax:</strong> du [OPTION] [FILE]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-h</code>: Print sizes in human-readable format.</p>
</li>
<li><p><code>-s</code>: Display only a total for each argument.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743882252687/e64c226e-5292-4b37-8137-b1217baa73e2.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-ps">ps:</h3>
<ul>
<li>Reports a snapshot of current processes.</li>
</ul>
<p><strong>Syntax</strong>: ps [OPTIONS]</p>
<p><strong>Options</strong>:</p>
<p><code>-f</code>: Full-format listing</p>
<p><code>-u</code>: User-oriented format</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743882991504/c5ca97be-5262-4607-9619-ff11b55aa336.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-top">top:</h3>
<ul>
<li><p>Displays Linux tasks.</p>
<p>  <strong>Syntax</strong>: <code>top [OPTIONS]</code></p>
<p>  <strong>Options</strong>:</p>
<ul>
<li><p><code>-d</code>: Delay time interval</p>
</li>
<li><p><code>-n</code>: Number of iterations</p>
</li>
</ul>
</li>
</ul>
<p>    <strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743883005656/52ab724b-3b27-4b58-ada7-b3bbeb8053f1.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-fuser">fuser</h3>
<ul>
<li>Identifies processes using files or sockets.</li>
</ul>
<p><strong>Syntax:</strong> fuser [OPTIONS] FILE</p>
<p><strong>Options</strong>:</p>
<p><code>-k</code>: Kill processes accessing the file</p>
<p><code>-m</code>: Name specifies a file on a mounted file system</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743883036995/d1cd1027-120c-47ec-887a-d5fdedec731d.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-kill">kill:</h3>
<ul>
<li>Sends a signal to a process.</li>
</ul>
<p><strong>Syntax:</strong> kill [options] pid</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-9</code>: Forcefully kill the process</p>
</li>
<li><p><code>-15</code>: Gracefully terminate the process</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743883098794/0b65970a-6a66-4e17-8769-2d5847860b3d.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-free-and-free-h">free and free -h:</h3>
<ul>
<li>Displays the amount of free and used memory in the system.</li>
</ul>
<p><strong>Syntax:</strong> free [OPTIONS]</p>
<p><strong>Options</strong>:</p>
<p><code>-h</code>: Human-readable format (e.g., 1K, 234M, 2G)</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743883192163/929f86f0-839b-4d63-ac3f-ba8054859967.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-nohup">nohup:</h3>
<ul>
<li>Runs a command immune to hangups, with output to a non-tty.</li>
</ul>
<p><strong>Syntax:</strong> nohup COMMAND [ARG]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743883371865/5a806f7d-b107-44b7-af43-75132c1da89a.png" alt class="image--center mx-auto" /></p>
<p>also you can use</p>
<p><strong>#head -n 5 nohup</strong> - to print top 5 lines</p>
<p><strong>#tail -n 5 nohup</strong> - to print last 5 lines</p>
<h3 id="heading-vmstat-and-vmstat-a">vmstat and vmstat -a:</h3>
<ul>
<li><p>Reports virtual memory statistics.</p>
<p>  <strong>Syntax:</strong> vmstat [OPTIONS] [DELAY [COUNT]]</p>
<p>  <strong>Options</strong>:</p>
<p>  <code>-a</code>: Displays active and inactive memory</p>
<p>  <strong>Example:</strong></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743883544408/fd713c32-9792-40cb-b3de-2be281f79e86.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-practical-9-user-and-file-management">Practical 9: User and File Management:</h2>
<h2 id="heading-system-level-command">System Level Command:</h2>
<h3 id="heading-uptime">uptime:</h3>
<ul>
<li>Tells how long the system has been running.</li>
</ul>
<p><strong>Syntax:</strong> uptime</p>
<h3 id="heading-who">who:</h3>
<ul>
<li>Shows who is logged on.</li>
</ul>
<p><strong>Syntax:</strong> who [OPTIONS]</p>
<p><code>-b</code>: Time of last system boot</p>
<p><code>-u</code>: Display idle time</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743884058965/92744c24-f08e-422c-8a33-33adc03746e9.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-whoami">whoami:</h3>
<ul>
<li><p>Prints the current user ID.</p>
<p>  <strong>Example:</strong></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743884086327/7dadc854-cc87-4d0a-bfa6-6540f5d11f09.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-which">Which:</h3>
<ul>
<li>Locates the executable file associated with a given command.</li>
</ul>
<p><strong>Syntax:</strong> which COMMAND</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743932330079/8d199def-86c3-4c8f-a50c-8c76d58c9414.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-id">id:</h3>
<ul>
<li><p>id of user or groups</p>
<p>  <strong>Example:</strong></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743884354338/b677779f-f1a3-4332-b170-4e800e90741b.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-etcpasswd">/etc/passwd:</h3>
<ul>
<li><p>This is a file that contains user account information.</p>
<p>  <strong>Example:</strong></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743884707820/55dc67c3-ecd2-49f6-85e2-63f091e9a9a5.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-sudo">sudo:</h3>
<ul>
<li>Executes a command as another user, typically the superuser.</li>
</ul>
<p><strong>Syntax:</strong> sudo COMMAND</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743884757911/36f10060-2995-4aa1-a130-a4c78a91417e.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-apt">apt:</h3>
<ul>
<li>A command-line interface for package management.</li>
</ul>
<p><strong>syntax:</strong> apt [OPTIONS] COMMAND</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743930058717/48e7b45b-8a85-4d7f-802d-10dfec17ba54.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743930187952/ebf16af7-3420-4c9d-a086-0cf5efaa35b4.png" alt class="image--center mx-auto" /></p>
<p>if you not able to download it you have to take it from web browser. so for that use below command:</p>
<h3 id="heading-sudo-apt-get"><strong>sudo apt-get:</strong></h3>
<ul>
<li>A command-line tool for handling packages.</li>
</ul>
<p><strong>Syntax:</strong> apt-get [OPTIONS] COMMAND</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743930327025/7ad94feb-636c-4ac1-a649-62367bf17af1.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-sudo-apt-get-update"><strong>sudo apt-get update</strong></h3>
<ul>
<li><p>and your system will be up to date.</p>
</li>
<li><p>and then you can proceed further to install application.</p>
</li>
</ul>
<h3 id="heading-sudo-apt-remove-dockerio"><strong>sudo apt remove docker.io</strong></h3>
<ul>
<li>is used to uninstall packages from your system</li>
</ul>
<p><strong>Syntax:</strong> sudo apt remove [PACKAGE_NAME]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743932406702/ab7e7426-4ea9-44a3-85ea-233686ee4e0c.png" alt class="image--center mx-auto" /></p>
<p><strong>Note:</strong> command for different linux versions:</p>
<p><strong>yum - centos</strong></p>
<p><strong>dnf- fedora</strong></p>
<p><strong>rpm- redhat</strong></p>
<h3 id="heading-man">Man:</h3>
<ul>
<li>Displays the manual pages for commands.</li>
</ul>
<p><strong>Syntax:</strong> man COMMAND</p>
<h2 id="heading-practical-10-user-and-group-management-commands">Practical 10: User and Group Management commands</h2>
<h3 id="heading-useradd">useradd:</h3>
<ul>
<li>Creates a new user and a home directory for them.</li>
</ul>
<p><strong>Syntax:</strong> sudo useradd -m [USERNAME]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744036121876/79c322be-46d2-4321-87e0-df1e2a42a1fe.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-passwd">passwd:</h3>
<ul>
<li>Sets or changes the password for a user.</li>
</ul>
<p><strong>Syntax:</strong> sudo passwd [USERNAME]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744036218902/5a35c8fc-0656-4b75-aadd-2d30adc31375.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-su">su:</h3>
<ul>
<li><p>to switch user. and to exit from secondary user to primary enter exit.</p>
<p>  <strong>Example:</strong></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744036484177/97d47bdb-b1be-4022-bbad-d40adbcb95cf.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-userdel">userdel:</h3>
<ul>
<li>is used to delete a user account.</li>
</ul>
<p><strong>syntax:</strong> sudo userdel username</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744036875817/df78d73e-8694-4048-ab16-cc02aa89a8b5.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-cat-etcgroup">cat /etc/group</h3>
<ul>
<li>to check list of all users.It is used to define the groups to which users belong</li>
</ul>
<h3 id="heading-groupadd">groupadd</h3>
<ul>
<li>Creates a new group.</li>
</ul>
<p><strong>Syntax:</strong> sudo groupadd [GROUPNAME]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744050087976/4930f2a9-0e86-46ce-899b-73b330b02cb3.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-gpasswd">gpasswd:</h3>
<ul>
<li>Adds a user to a group.</li>
</ul>
<p><strong>Syntax:</strong> sudo gpasswd -a [USERNAME] [GROUPNAME]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744050147285/8bf2b4d6-d1ba-4a30-ae44-8f720ceaecc3.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744050189990/17625743-1511-4cf7-ae01-5a4b6f91b63a.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-groupdel">groupdel:</h3>
<ul>
<li>Deletes a group.</li>
</ul>
<p><strong>Syntax:</strong> sudo groupdel [GROUPNAME]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744050317128/bc49c169-7b84-4418-a9f7-ccfcd6761c5f.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-practical-11-file-permissions-commands">Practical 11: File Permissions Commands</h2>
<h3 id="heading-ls-l">ls -l</h3>
<ul>
<li>Lists files and directories in long format, showing detailed information.</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744107888658/b4975e77-0450-4f7b-993e-a01f687af945.png" alt class="image--center mx-auto" /></p>
<p><strong>Note:</strong> at starting d is mentioned. it means directory</p>
<p>and in second line - is mentioned means it can’t be directory.</p>
<p><img src="https://crunchify.com/wp-content/uploads/2021/06/Linux-file-permission-Details-and-Explaination-Crunchify-Tips-768x619.jpg" alt="CS configuration in Linux kernel driver | Download Table" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744099585791/b5274bbc-41dd-4515-a41a-2e68118d56e0.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-chmod">chmod:</h3>
<ul>
<li>Changes file permissions.</li>
</ul>
<p><strong>Syntax:</strong> chmod [options] mode file</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-R</code>: Recursively change permissions.</p>
</li>
<li><p><code>u</code>, <code>g</code>, <code>o</code>: User, group, others.</p>
</li>
<li><p><code>+</code>, <code>-</code>, <code>=</code>: Add, remove, set permissions.</p>
</li>
</ul>
<p><strong>Note:</strong> to change permission for directory. eg. chmod 770 cloud</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744108027975/16a2c575-8fe5-4f52-a26a-e58d95ce9850.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-umask">umask</h3>
<ul>
<li>Sets default file creation permissions.</li>
</ul>
<p><strong>Syntax:</strong> umask [options] [mask]</p>
<p><strong>Note:</strong> every system has default file permissions. If you create new file and check umask you will see some permission given.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744108461752/397eefcf-d3cb-4f06-b251-f970c7b1b950.png" alt class="image--center mx-auto" /></p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744108536110/b5d16a04-06b1-4708-9979-fca1fcfa5da7.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744108614036/633d0159-1438-4deb-8b92-c7a9bfcabf70.png" alt class="image--center mx-auto" /></p>
<p>0002: rw-rw-r—</p>
<h3 id="heading-chown">chown:</h3>
<ul>
<li>Changes file owner and group.</li>
</ul>
<p><strong>Syntax:</strong> chown [options] owner[:group] file</p>
<p><strong>Options:</strong></p>
<ul>
<li><code>-R</code>: Recursively change ownership.</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744109005173/3cda0c61-0f53-4004-9a28-ae9d26207863.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-chgrp">chgrp</h3>
<ul>
<li>Changes group ownership of a file.</li>
</ul>
<p><strong>Syntax:</strong> chgrp [options] group file</p>
<p><strong>Options:</strong></p>
<p><code>-R</code>: Recursively change group ownership.</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744109166825/e38f7c39-7998-42ea-9dd0-fc1d3aea335c.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-zip">zip:</h3>
<ul>
<li>Compresses files into a ZIP archive.</li>
</ul>
<p><strong>Syntax:</strong> zip [options] <a target="_blank" href="http://archive.zip">archive.zip</a> file</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-r</code>: Recursively add files.</p>
</li>
<li><p><code>-e</code>: Encrypt the archive.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744109648590/639caad7-00dc-4b9a-b645-58fb7a9ded00.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-unzip">unzip:</h3>
<ul>
<li>Extracts files from a ZIP archive.</li>
</ul>
<p><strong>Syntax:</strong> unzip [options] <a target="_blank" href="http://archive.zip">archive.zip</a></p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-l</code>: List contents of the archive.</p>
</li>
<li><p><code>-d</code>: Specify directory to extract to.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<ol>
<li><p>Create folder inside cloud folder</p>
</li>
<li><p>created zip file at root location.</p>
</li>
<li><p>copy that zip file to new location</p>
</li>
<li><p>unzip that file.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744191888134/77dee23a-166c-4c0d-aac5-07f375d74f26.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-tar">tar:</h3>
<ul>
<li>Archives files into a tarball.</li>
</ul>
<p><strong>Syntax:</strong> tar [options] -f archive.tar file</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-c</code>: Create a new archive.</p>
</li>
<li><p><code>-x</code>: Extract files from an archive.</p>
</li>
<li><p><code>-v</code>: Verbose output.</p>
</li>
<li><p><code>-z</code>: Compress with gzip.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744192922393/9da5f5c3-c79b-4779-9891-59f831d3df5c.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-tar-xvzf-filetargz">tar -xvzf file.tar.gz</h3>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744193005767/2be48c26-f704-4439-9cd8-26001c4572a1.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-practical-12-transfer-commands">Practical 12: Transfer Commands</h2>
<h3 id="heading-scp">Scp:</h3>
<p>To copy files from your local machine to a remote server using <code>scp</code> (secure copy),</p>
<h3 id="heading-a-from-local-to-server">a. From local to server</h3>
<ol>
<li><p>First create file eg secret_file.txt, enter data and then use scp command.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745483925025/2a214383-c325-4202-8082-706792ad72b6.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Enter content in file.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745484283641/2f9d1f93-9ae9-4c9a-8c8c-503b5c5aca22.png" alt class="image--center mx-auto" /></p>
<p> <strong>Data: File from local.</strong></p>
</li>
<li><p>Do <strong>ssh</strong> on local(windows cmd).</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744194464713/66bfab6c-a830-4316-973b-38c26e9e6e5e.png" alt class="image--center mx-auto" /></p>
<ol start="4">
<li><p>Do <strong>scp</strong> on local.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745484380290/7875afd4-8eca-467c-bb29-7ec4dc52da40.png" alt class="image--center mx-auto" /></p>
<p> <strong>Syntax: scp [options] “key_location”  source_file “username@remote_host:remote_directory”</strong></p>
<p> <strong>Explanation:</strong></p>
<p> I am using windows command promt.</p>
<p> <strong>key_location</strong> → whenever we create instance on aws, key will get download on local that key location</p>
<p> <strong>source_file</strong> → we have created file which is secret_file.txt</p>
<p> <strong>username@remote_host:remote_directory</strong> → destination path/server location</p>
<p> <strong>Key_location will be: “\users\archana\downloads\linux2.pem"</strong></p>
<p> <strong>destination path / server location will be</strong>: <a target="_blank" href="mailto:ubuntu@ec2-3-133-124-129.us-east-2.compute.amazonaws.com">ubuntu@ec2-3-133-124-129.us-east-2.compute.amazonaws.com</a>:/home/ubuntu</p>
</li>
<li><p>Go to aws. connect the instance. list out all file using <strong>ls</strong> command. You will see file is present on server just because we used scp on local.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745484638648/8d395d2c-a4c6-418b-bb5c-79bf36e549e3.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>And you can view the file on server.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745484730393/bcbafb1d-2c4e-4cf1-9ad1-6718a355839e.png" alt class="image--center mx-auto" /></p>
</li>
</ol>
<h2 id="heading-server-to-local">Server to local</h2>
<ol>
<li><p>Now we want to copy folder from server to local. First we will make one folder on server. i.e. Devops.</p>
<p> and we will copy this folder to local.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745485197116/9b75c5dc-16a9-488c-becd-66145b6baf38.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Do <strong>scp</strong> on local.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745485273898/7d4ec2c2-ad17-4774-ac0c-c77476ad3373.png" alt class="image--center mx-auto" /></p>
</li>
</ol>
<p><strong>Syntax:</strong> <strong>scp [options] “key_location”  -r username@remote_host:remote_directory .</strong></p>
<p><strong>Explanation:</strong></p>
<p><strong>Key_location</strong> → whenever we create instance on aws, key will get download on local that key location</p>
<p><strong>source_file</strong> → we have created folder on server which is Devops</p>
<p><strong>username@remote_host:remote_directory</strong> → destination path/server location/file location</p>
<p><strong>-r</strong> → Because we are copying folder.</p>
<p><strong>.</strong> → copy to present location in local.</p>
<p><strong>Key_location will be:</strong> <strong>“\users\archana\downloads\linux2.pem"</strong></p>
<p><strong>destination path / server location will be:</strong> <a target="_blank" href="mailto:ubuntu@ec2-3-133-124-129.us-east-2.compute.amazonaws.com">ubuntu@ec2-3-133-124-129.us-east-2.compute.amazonaws.com</a>:/home/ubuntu/Devops</p>
<ol start="3">
<li><p>Check folder is copied to local or not.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1745485535683/a1378bd6-876d-4345-ab1a-b1d15e041fff.png" alt class="image--center mx-auto" /></p>
</li>
</ol>
<h3 id="heading-rsync">rsync:</h3>
<ul>
<li>for synchronizing files and directories between two locations over a network or locally. It is commonly used for backups and mirroring.</li>
</ul>
<ol>
<li>On local. Do ssh. I used Linux shell.</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744195629194/3dfdbb0a-55f1-4ded-8f6b-e9da038e3168.png" alt class="image--center mx-auto" /></p>
<p><strong>Syntax: rsync -e "ssh -i \Users\Archana\Downloads\linux2.pem" -avz Devops</strong> <a target="_blank" href="mailto:ubuntu@ec2-3-133-124-129.us-east-2.compute.amazonaws.com"><strong>ubuntu@ec2-3-133-124-129.us-east-2.compute.amazonaws.com</strong></a><strong>:/home/ubuntu/Devops</strong></p>
<p><strong>Explanation:</strong></p>
<p><strong>rsync -e →</strong> to sync</p>
<p><strong>ssh i</strong> <strong>/users/shubham/downloads/linux-for-devops-key.pem → do ssh</strong></p>
<p><strong>-avz</strong> → archieve, compress,zip</p>
<p><a target="_blank" href="mailto:ubuntu@ec2-3-148-172-197.us-east-2.compute.amazonaws.com"><strong>ubuntu@ec2-3-148-172-197.us-east-2.compute.amazonaws.com</strong></a><strong>:/home/ubuntu/linux_for_devops</strong> → path to local folder</p>
<p>check both side.</p>
<h2 id="heading-practical-13-networking-commands">Practical 13: Networking Commands</h2>
<h3 id="heading-ping">ping</h3>
<ul>
<li>Used to check the connectivity to a host.</li>
</ul>
<p><strong>Syntax:</strong> ping [options]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-c &lt;count&gt;</code>: Number of packets to send.</p>
</li>
<li><p><code>-i &lt;interval&gt;</code>: Interval between packets.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744356427425/7ae6790b-3f37-492a-9ec5-281933e5f2e3.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-netstat">netstat</h3>
<ul>
<li>useful command for displaying network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.</li>
</ul>
<p><strong>Synatx:</strong> netstat [options]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-a</code>: Show all connections (listening and non-listening).</p>
</li>
<li><p><code>-t</code>: Display TCP connections.</p>
</li>
<li><p><code>-u</code>: Display UDP connections.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744356468103/e411ef59-c2e5-4d09-86dc-97b324107cf8.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-net-tools">net-tools</h3>
<ul>
<li><strong>Net-tools</strong> is a collection of programs for controlling and monitoring network settings in Unix-like operating systems.</li>
</ul>
<p><strong>Syntax:</strong> sudo apt install net-tools</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744356450977/8bb8b4d5-b4a4-41a5-a53d-93d1e82d8312.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-ifconfig">ifconfig</h3>
<ul>
<li>Displays or configures network interfaces.</li>
</ul>
<p><strong>Syntax:</strong> ifconfig [interface] [options]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>up</code>: Activate an interface.</p>
</li>
<li><p><code>down</code>: Deactivate an interface.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744356724119/5af0afde-d636-458b-a847-70ee49f0d8d5.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-traceroute">traceroute</h3>
<ul>
<li>Traces the route packets take to a network host.</li>
</ul>
<p><strong>Syntax:</strong> traceroute [options]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-m &lt;max_ttl&gt;</code>: Maximum number of hops.</p>
</li>
<li><p><code>-n</code>: Do not resolve hostnames.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744358072582/f37f5e71-b708-4315-b214-f34accbaab0f.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-tracepath">tracepath</h3>
<ul>
<li>Similar to <code>traceroute</code>, but does not require superuser privileges.</li>
</ul>
<p><strong>Syntax:</strong> tracepath hostname/ip</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744358118076/0cdc17fa-8cb9-45b4-a632-b427d2f19bd6.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-mtr">mtr</h3>
<ul>
<li>Combines ping and traceroute functionalities.</li>
</ul>
<p><strong>Syntax:</strong> mtr [options]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-r</code>: Generate report.</p>
</li>
<li><p><code>-c &lt;count&gt;</code>: Number of pings.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744358332899/9b90ce2c-077a-4273-81ea-2d7e2841c868.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-nslookup">nslookup:</h3>
<ul>
<li>Queries DNS to obtain domain name or IP address mapping.</li>
</ul>
<p><strong>syntax:</strong> nslookup [options]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744358445964/3eb074f9-dad0-40d3-b7d5-e2710a7c57eb.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-telnet-googlecom-80">Telnet google.com 80</h3>
<ul>
<li>to connect with port, Used for remote login.</li>
</ul>
<p><strong>Syntax:</strong> telnet hostname/ip [port]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744358600815/ba605446-c0dd-40e2-8678-8c9413cf4d99.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-hostname">hostname:</h3>
<ul>
<li>Displays or sets the system's hostname.</li>
</ul>
<p><strong>Syntax:</strong> hostname [new_hostname]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744358683344/86522fa5-0631-42e0-9ff3-d11a0fa05078.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-cat-etchosts">cat /etc/hosts</h3>
<ul>
<li>to check all host names</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744358711294/5d922979-e39f-432e-8b0d-54fac0844a13.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-ip-address-show">ip address show</h3>
<ul>
<li>Displays IP addresses assigned to all network interfaces.</li>
</ul>
<p><strong>Syntax:</strong> ip address show [interface]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744358827960/bf037bae-d7f3-40e0-97a1-3a55c2d93485.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-iwconfig">iwconfig</h3>
<ul>
<li>Configures wireless network interfaces.</li>
</ul>
<p><strong>Syntax:</strong> iwconfig [interface] [options]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>essid &lt;SSID&gt;</code>: Set network name.</p>
</li>
<li><p><code>key &lt;key&gt;</code>: Set WEP key</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744358988686/ec1400df-50aa-4bfa-ae8d-702b3f9ba2e9.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-sudo-apt-install-wireless-tools">sudo apt install wireless-tools</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744358952518/bf747903-c87a-443c-a31b-f7073ff414fb.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-ss">ss</h3>
<ul>
<li>same as netstat</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744359070651/2848be73-2ae6-4413-bd8e-5129c379b95b.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-dig-googlecom">dig google.com</h3>
<ul>
<li>Queries DNS servers.</li>
</ul>
<p><strong>Syntax:</strong> dig [options] hostname/ip</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>@&lt;server&gt;</code>: Specify DNS server.</p>
</li>
<li><p><code>+short</code>: Short output.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744359149566/1ee96747-887a-45fa-ba42-7df056ce5e59.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-whois-googlecom">whois google.com</h3>
<ul>
<li>Retrieves information about domain registration.</li>
</ul>
<p><strong>Syntax:</strong> whois domain_name</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744359353699/24fbe755-0325-484c-bff3-ae3a44e22bc3.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-arp">arp</h3>
<ul>
<li>Displays or modifies the ARP table.</li>
</ul>
<p><strong>Syntax:</strong> arp [options]arp [options]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-a</code>: Display all entries.</p>
</li>
<li><p><code>-d &lt;hostname&gt;</code>: Delete an entry.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744359542846/49ba9d53-b22f-4ed8-9bca-32ee98f06eb5.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-ifplugstatus">ifplugstatus:</h3>
<ul>
<li>Checks the link status of network interfaces.</li>
</ul>
<p><strong>Syntax:</strong> ifplugstatus [interface]</p>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744359641837/c0ed44bd-37ca-4f4e-9daf-1aa6345473cc.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-curl">curl:</h3>
<ul>
<li>to call api endpoints, jq is for design purpose, Transfers data from or to a server.</li>
</ul>
<p><strong>Syntax:</strong> curl [options]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-O</code>: Save to file.</p>
</li>
<li><p><code>-d &lt;data&gt;</code>: Send data.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744360334966/f642e74f-7f77-4b1b-8298-e29faed51b84.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-wget-link">wget link</h3>
<ul>
<li>Downloads files from the web.</li>
</ul>
<p><strong>Syntax:</strong> wget [options] url</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-O &lt;file&gt;</code>: Save as file.</p>
</li>
<li><p><code>-q</code>: Quiet mode.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744360574239/3abf3f4d-3027-4770-8157-caeeed2fb899.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-watch">watch</h3>
<ul>
<li>Runs a command repeatedly, displaying its output.</li>
</ul>
<p><strong>Syntax:</strong> watch [options] command</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-n &lt;interval&gt;</code>: Interval between executions.</p>
</li>
<li><p><code>-d</code>: Highlight changes.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><strong>watch mtr google.com</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744360808243/1b07ab51-092f-46a7-9e5c-efe37b53fbb1.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-nmap">nmap</h3>
<ul>
<li>Network exploration tool and security scanner.</li>
</ul>
<p><strong>Syntax:</strong> nmap [options]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>-sS</code>: TCP SYN scan.</p>
</li>
<li><p><code>-O</code>: OS detection.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744557536117/8e7f0a85-0826-4142-839f-4e3ce799a23c.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-route">route</h3>
<ul>
<li>It will show ip address and their gateway, Displays or modifies the IP routing table.</li>
</ul>
<p><strong>Syntax:</strong> route [options]</p>
<p><strong>Options:</strong></p>
<ul>
<li><p><code>add</code>: Add a route.</p>
</li>
<li><p><code>del</code>: Delete a route.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744557657734/1f1da0a6-5ae6-4e1e-9006-ff31201891a9.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-practical-14-advanced-linux-commands-awk-sed-grep">Practical 14: Advanced linux commands: awk, sed, grep</h2>
<h2 id="heading-1awk">1.<strong>awk</strong></h2>
<ul>
<li><p>Used to manipulate and analyze text, typically in columnar data. It allows you to select specific columns, modify data, perform calculations, and much more.</p>
<ol>
<li>Create a directory, create a text file (app.log) and add content.</li>
</ol>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744566117190/2dc6cacb-866f-48a8-a372-bfe0d36a77ec.png" alt class="image--center mx-auto" /></p>
<ol start="2">
<li>You can see content of file using head command.</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744566152711/dfa60904-a537-4a03-be0c-82e8b126ae53.png" alt class="image--center mx-auto" /></p>
<p><strong>a. To print anything you can use ‘{print}‘</strong></p>
<p><strong>Syntax:</strong> awk 'pattern {action}' input_file</p>
<ul>
<li><p><strong>pattern</strong>: The condition (pattern) to match (optional). If not specified, awk processes all lines.</p>
</li>
<li><p><strong>action</strong>: What to do when a line matches the pattern. The action is written in curly braces <code>{}</code>.</p>
</li>
<li><p><strong>input_file</strong>: The file to process (optional if using input from a pipe). eg. app.log</p>
</li>
</ul>
<p><strong>Example:</strong> awk ‘{print}‘ app.log</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744566194569/cdcb2e88-97dc-43c1-856e-eef22bd168ca.png" alt class="image--center mx-auto" /></p>
<p><strong>b. Print Specific Columns. Here you can use $ to specify column</strong></p>
<p><strong>Example:</strong> awk '{print $1, $2}' input_file</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744566221053/97b438b4-c853-4761-afa8-1bc46b19c7fe.png" alt class="image--center mx-auto" /></p>
<p><strong>c. You can find particular word from file.</strong></p>
<p><strong>Syntax: /word/</strong></p>
<p>eg. In this snip, I am finding total reg_process word in column1 and 2 from entire file.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744566406078/e794bf6a-8a40-4df3-9c11-a4cd318dbcec.png" alt class="image--center mx-auto" /></p>
<p>and now I am storing output different file which is new.txt.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744572265161/07b42684-69ec-465f-a688-d3678b2249d0.png" alt class="image--center mx-auto" /></p>
<p>In this snip, you can print total count of how many times reg_process occurs.</p>
<p>Here I used {count++}: It is <strong>action</strong> — increments the variable count for each match</p>
<p>END {print count}': After processing all lines, print the final value of count.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744572568020/24736281-bb17-4399-85b2-332860538439.png" alt class="image--center mx-auto" /></p>
<p><strong>d. Print column in mention range.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744572676531/a9db94b5-3840-4b17-9b89-0f2e19ee80c2.png" alt class="image--center mx-auto" /></p>
<p><strong>Explanation:</strong></p>
<p>Checks if the second column ($2) is a time between “08:51:01" and $2 &lt;= "08:51:03”</p>
<p>If yes, it prints the 2nd, 3rd, and 4th columns from those lines.</p>
<ol start="2">
<li><h3 id="heading-sed"><strong>sed</strong></h3>
</li>
</ol>
<ul>
<li>super useful for <strong>finding, replacing, deleting, and transforming</strong> text in files or input streams, -n used for exact match.</li>
</ul>
<p><strong>Syntax:</strong> sed [OPTIONS] 'command' input_file</p>
<p><strong>Options:</strong></p>
<p><code>-e</code>– Add multiple commands</p>
<p><code>-f</code> – Read sed commands from a file</p>
<p><code>-i</code> – Edit file <strong>in-place</strong></p>
<p><code>-n</code> – Only print what's explicitly told to</p>
<p><strong>a. we print reg_process from app.log file</strong></p>
<p><code>p</code>: This means <strong>"print the line"</strong> when the pattern reg_process is found.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744575626803/921ba223-97a5-4a9b-a03d-0112e3e349bf.png" alt class="image--center mx-auto" /></p>
<p><strong>b. we need to replace “reg_process” with “Info” word.</strong></p>
<p>Explanation:</p>
<p><code>'s/reg_process/Info/g'</code>:</p>
<ul>
<li><p><code>s</code>: Stands for <strong>substitute</strong>.</p>
</li>
<li><p><code>reg_process</code>: The <strong>pattern</strong> (or word) you're looking for.</p>
</li>
<li><p><code>Info</code>: The <strong>replacement string</strong>. This will replace reg_process wherever it appears in the text.</p>
</li>
<li><p><code>g</code>: This stands for <strong>global</strong>. It means <strong>replace all occurrences</strong> of reg_process in each line. Without g, only the <strong>first occurrence</strong> on each line would be replaced.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744575773583/b5b114ee-9062-41e3-b5b4-6d6a28dc61ac.png" alt class="image--center mx-auto" /></p>
<p><strong>c. We need to change reg_process to log from line 1 to 12</strong></p>
<p><strong>Explanation:</strong></p>
<p><code>'1,12 s/reg_process/log/g'</code>:</p>
<ul>
<li><p><code>1,12</code>: This specifies the <strong>range of lines</strong> to apply the substitution to.</p>
</li>
<li><p><code>s</code>: Stands for <strong>substitute</strong></p>
</li>
<li><p><code>reg_process</code>: The <strong>pattern</strong> (or word) you're searching for.</p>
</li>
<li><p><code>log</code>: The <strong>replacement string</strong>. Wherever <code>reg_process</code> is found, it will be replaced by <code>log</code>.</p>
</li>
<li><p><code>g</code>: This stands for <strong>global</strong>. It ensures that <strong>all occurrences</strong> of <code>reg_process</code> in each of those lines will be replaced (not just the first occurrence).</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744576393500/b53849b9-9a22-4d64-9736-6dd2a5af353a.png" alt class="image--center mx-auto" /></p>
<ol start="3">
<li><h3 id="heading-grep"><strong>grep</strong></h3>
<ul>
<li>It stands for <strong>Global Regular Expression Print,</strong> It searches for <strong>lines that match a pattern</strong> and prints them</li>
</ul>
</li>
</ol>
<p>    <strong>Syntax:</strong> grep [OPTIONS] PATTERN [FILE]</p>
<p>    <strong>Options:</strong></p>
<p>    <code>-i</code> case sentitive</p>
<p>    <code>-n</code> Show line numbers with matching lines</p>
<p>    <strong>a. To find word “address “</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744576561119/2a34d977-9209-4879-8f9d-fe6705c04fbe.png" alt class="image--center mx-auto" /></p>
<p><strong>b. Total count for address word.</strong></p>
<p>-c: It returns the number of lines that contain the pattern/word.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744576611715/a8381a65-0b31-4c49-9522-a9147a85f5d3.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-linux-volume-management">Linux Volume Management</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744711490655/9781a8a4-9efd-4bc8-aaea-98c652688d27.png" alt class="image--center mx-auto" /></p>
<p><strong>Logical Volume Management (LVM)</strong> is a system for managing disk storage in a flexible and efficient way. Here’s a simple breakdown:</p>
<h3 id="heading-key-components">Key Components</h3>
<ol>
<li><p><strong>Physical Volumes (PVs)</strong>: These are the actual hard drives or partitions.</p>
</li>
<li><p><strong>Volume Groups (VGs)</strong>: Collections of physical volumes combined into one large storage pool.</p>
</li>
<li><p><strong>Logical Volumes (LVs)</strong>: Virtual partitions created from the volume group, which can be resized and managed easily.</p>
</li>
</ol>
<h3 id="heading-how-it-works">How It Works</h3>
<ol>
<li><p><strong>Create Physical Volumes</strong>: Convert hard drives or partitions into physical volumes.</p>
</li>
<li><p><strong>Create Volume Groups</strong>: Combine these physical volumes into a volume group.</p>
</li>
<li><p><strong>Create Logical Volumes</strong>: Make flexible storage spaces from the volume group.</p>
</li>
</ol>
<h3 id="heading-aws-elastic-block-store-ebs">AWS Elastic Block Store (EBS)</h3>
<p>Amazon EBS provides scalable, high-performance block storage for use with Amazon EC2 instances. Key features include:</p>
<ul>
<li><strong>EBS Volumes</strong>: Attach these to EC2 instances to store data, similar to a local hard drive.</li>
</ul>
<p>when any volumn means xvda is get attached to ec2 or system it becomes /dev/xvda. And we get starting point that is mount “/“.</p>
<p><strong>mounting</strong> refers to the process of making a filesystem accessible at a certain point in the directory tree. When you mount a storage device (like a hard drive or USB stick), you attach its filesystem to a directory (known as a <strong>mount point</strong>) so that you can access its contents.</p>
<p>It looks like as below:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744709697425/c2bbf325-2582-4351-bdcb-502174ddf0e8.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744709609837/af1126ee-2bec-44b9-9e99-a695cf2cfed4.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-practical-15-to-check-disk-space-create-ebs-volumn-and-attach-to-instance">Practical 15: To check disk space, create EBS volumn and attach to instance</h3>
<p>1. create ec2 instance with 8gb storage. connect it via console or via ssh.</p>
<p>Try this command and check disk space details.</p>
<h3 id="heading-a-check-disk-space">a. check disk space.</h3>
<p><strong>1.lsblk</strong></p>
<p>In Linux, <code>/dev/xvda</code> refers to a <strong>Xen Virtual Block Device</strong>. This naming convention is used for storage devices in virtualized environments. xvda1, xvda14, xvda15 these are partition of disk</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744709437003/db7b18c8-a35f-4806-bb05-b822773b6af9.png" alt class="image--center mx-auto" /></p>
<p><strong>2.df -h</strong></p>
<p>How much disk space is left.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744709548857/40b9377d-8ba8-4848-8557-023cb6fd7ed4.png" alt class="image--center mx-auto" /></p>
<p><strong>b. create EBS volumes</strong></p>
<p>EC2→ volumes → create volume for **10,12,14gb. (8gb is original when we created ec2 instance.)**You You can see in below image:</p>
<ul>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744710022999/8014816b-4bab-420b-ae85-85bbfb00919b.png" alt class="image--center mx-auto" /></p>
<p>  While creating volume select /dev/sdf. Do not select /dev/sda because it is already in use.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744710218487/ed001e51-20ec-4d7d-8fa2-f66dbc1280e6.png" alt class="image--center mx-auto" /></p>
<p>12gb volume-/dev/sdg</p>
<p>14gb volume-/dev/sdh</p>
<p>10gb volume - /dev/sdf</p>
<p>check if its attached or not through lsblk command.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744710474339/cf33ad7a-0ad4-4cfb-8d7d-0b6f3411459f.png" alt class="image--center mx-auto" /></p>
<p>You can see xvdf, xvdg, xvdh are disk and attached.</p>
<h3 id="heading-practical-16-lvm-create-physical-volume-volume-group-logical-volumn">Practical 16: LVM, Create physical volume, volume group, logical volumn</h3>
<ol>
<li><p>If you want to do anything in LVM you have to be root user.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744710929966/aa74ed49-75b6-402e-88dc-dc30b64e9a06.png" alt class="image--center mx-auto" /></p>
<p> We have created 3 volumes xvdf, xvdg, xvdh in last practical. Now we will make them as physical volume.</p>
<p> <strong>Syntax:</strong> pvcreate [options] devices</p>
<p> <strong>Options:</strong></p>
<p> <code>--force</code>: Forces the creation of a physical volume</p>
<p> <code>--verbose</code>: Show detailed output while creating the VG.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744710991241/0cf563e8-6776-4358-abaa-557b077e49da.png" alt class="image--center mx-auto" /></p>
<p> check physical volume using pvs command.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744711013676/42b63099-9ac5-425a-bd72-ea84f2eb6ccd.png" alt class="image--center mx-auto" /></p>
<p> <strong>Create volume groups.</strong></p>
<p> <strong>Syntax:</strong> vgcreate [OPTIONS] &lt;volume_group_name&gt; &lt;physical_volume_path&gt; [additional_PVs]</p>
<p> <strong>Options:</strong></p>
<p> <code>--force</code>: Forces the creation of a physical volume</p>
<p> <code>--verbose</code>: Show detailed output while creating the VG.</p>
<p> To check newly created volume groups enter <strong>vgs</strong> command</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744711583805/5f3bbe2e-1e68-45da-9c86-f0c78be8bd27.png" alt class="image--center mx-auto" /></p>
<p> <strong>Create logical volume.</strong></p>
<p> <strong>Syntax:</strong> lvcreate [OPTIONS] -l -n &lt;lv_name&gt; &lt;vg_name&gt;</p>
<p> <strong>Options:</strong></p>
<p> <code>-L &lt;size&gt;</code>: Specifies the <strong>size</strong> of the logical volume (e.g., <code>10G</code>, <code>500M</code>)</p>
<p> <code>-l &lt;extents&gt;</code>: Specifies the size in <strong>extents</strong> (e.g., <code>100%FREE</code>, <code>50%VG</code>)</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744711709714/9906aeb2-dc76-4f26-a805-61b17ade9dda.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>to check physical volume details, use <strong>pvdisplay lvdisplay vgdisplay.</strong></p>
</li>
<li><p>to come out from lvm enter exit.</p>
</li>
</ul>
</li>
</ol>
<p>    <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744711812933/189dcb8b-4224-4067-8e46-ef82a4cf6278.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-practical-17-how-to-do-mounting-of-newly-created-volumes-and-groups-and-logical-volume">Practical 17: How to do mounting of newly created volumes and groups and logical volume.</h3>
<ol>
<li><p>Create a Mount Point Directory</p>
<p> <strong>Syntax:</strong> mkdir -p /mnt/lvmount</p>
</li>
<li><p>Format the Logical Volume with a Filesystem</p>
<p> <strong>Syntax:</strong> mkfs.ext4 /dev/vgnew/lvnew</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744712418115/13626ddd-28f9-4ce1-87bf-fd6d2b7452f6.png" alt class="image--center mx-auto" /></p>
<p> Mount the Logical Volume.</p>
<p> <strong>Syntax:</strong> mount /dev/my_vg/my_lv /mnt/lvmount</p>
<p> your logical volume is accessible at /mnt/lvmount.</p>
</li>
<li><p>Verify the Mount using df -h</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744712578464/ffb14024-0eb7-49d3-8ab1-47f1eb279eea.png" alt class="image--center mx-auto" /></p>
<ol start="5">
<li>Now you can go to mount location and you can make directories and files. and you can access from root directory by entering path of text file.</li>
</ol>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744712666346/d675de7b-7226-414a-95be-ecf14250d967.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744712799010/39773a66-02a9-459f-bee4-096ef3f14479.png" alt class="image--center mx-auto" /></p>
<ol start="6">
<li><p>You can unmount the directory.</p>
<p> <strong>Syntax:</strong> umount /mnt/lvmount</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744713010355/a3e83710-9109-4448-8a51-9f64274d0599.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-practical-18-how-to-mount-directly-made-ebs-volume">Practical 18: How to mount directly made ebs volume.</h3>
<ol>
<li><p>Identify the EBS volume</p>
<p> <strong>lsblk</strong></p>
</li>
<li><p>Check if it’s formatted.</p>
<p> sudo file -s /dev/xvdh (we already made extra volumn in practical 17)</p>
<p> If it says: /dev/xvdh: data That means the disk is <strong>not formatted yet</strong>.</p>
</li>
<li><p>Create directory disk_mount</p>
<p> mkdir /mnt/disk_mount</p>
</li>
<li><p>Format the EBS Volume</p>
<p> sudo mkfs.ext4 /dev/xvdh</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744713326585/06cf7d22-31b9-4a66-8024-a844b633c42c.png" alt class="image--center mx-auto" /></p>
<ol start="4">
<li><p>Mount the EBS Volume.</p>
<p> <strong>Syntax:</strong> sudo mount /dev/xvdh /mnt/disk_mount/</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744713472178/5c7c079f-32c3-4da8-8dad-ddd751bf13cf.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-practical-19-if-we-create-logical-volumn-of-10gb-we-can-expand-it-to-15gb">Practical 19: If we create logical volumn of 10gb we can expand it to 15gb.</h3>
<ol>
<li><p>Check Current Size</p>
<p> <strong>Syntax:</strong> lvdisplay /dev/my_vg/my_lv or df -h /mnt/mydata</p>
</li>
<li><p>Resize the Logical Volume to 15G</p>
<p> <strong>Syntax:</strong> sudo lvextend -L 15G /dev/vgnew/lvnew</p>
<p> Exit from lvm</p>
</li>
<li><p>Verify the New Size using lsblk.</p>
<p> You can see xvdh is now 14gb.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744714365146/0807740e-2f52-466d-b192-718229ef02a5.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item></channel></rss>