# Introduction to Linux - Basic commands part 1

## What is Linux?

Linux is an open-source operating system known for its stability, security, and flexibility. It provides a foundation for running software applications on various devices, from servers to smartphones.

Here are a few key points about Linux:

* Linux is a free and open-source operating system.
    
* It offers stability, security, and flexibility.
    
* Linux is highly customizable and supports a wide range of programming languages.
    
* It has a large and active community of developers and users.
    
* Linux is widely used in various devices and environments.
    

---

## Importance of Linux in DevOps:

🔐 <mark>Security Shield</mark>: Linux is the fortress for DevOps professionals, offering robust security features and a solid defense against cyber threats.

⚙️ <mark>Reliability Gears</mark>: With its rock-solid stability, Linux provides a reliable foundation for deploying and managing applications, ensuring smooth operations in DevOps workflows.

🐳 <mark>Container Ship</mark>: Linux's support for containerization technologies like Docker and Kubernetes acts as a powerful vessel, enabling seamless application deployment, scalability, and efficient resource utilization.

💻 <mark>Command-line Toolbox</mark>: Linux empowers DevOps teams with an extensive array of command-line tools and automation capabilities, enabling streamlined scripting, system administration, and configuration management.

🌐 <mark>Community Network</mark>: Linux's open-source nature fosters a vibrant community, connecting DevOps professionals to a vast network of resources, documentation, and enthusiastic support from fellow enthusiasts.

☁️ <mark>Cloud Compatibility</mark>: Linux seamlessly integrates with various cloud platforms, serving as a perfect match for building and managing cloud infrastructure in DevOps environments, ensuring scalability and flexibility.

---

## Basic Linux Commands :

| **Command** | **Description** | **Example** |
| --- | --- | --- |
| ls | Lists files and directories | ls or ls -l |
| cd | Changes the current directory | cd Documents |
| pwd | Prints the current working directory | pwd |
| mkdir | Creates a new directory | mkdir new\_folder |
| rm | Removes files and directories | rm file.txt |
| cp | Copies files and directories | cp file.txt backup/ |
| mv | Moves or renames files and directories | mv file.txt new\_folder/ |
| cat | Displays the contents of a file | cat file.txt |
| head | Displays the beginning of a file | head file.txt |
| tail | Displays the end of a file | tail file.txt |
| touch | Creates an empty file or updates file timestamp | touch new\_file.txt |
| grep | Searches for a specific pattern in files | grep "error" log.txt |

## Text editors in Linux :

Text editors in Linux play a crucial role in manipulating and modifying text-based files, making them essential tools for DevOps professionals. They allow you to create, edit, and manage various configuration files, scripts, code, and documentation.

### Vim (Vi Improved):

Vim (Vi Improved) is a highly configurable and powerful text editor that runs in the command-line interface. It offers a modal editing approach, meaning it has different modes for navigation, insertion, and command execution. Vim provides numerous advanced features, including syntax highlighting, code folding, macros, and extensive customization options. It is known for its efficiency and speed, making it popular among experienced users who prefer keyboard-centric editing workflows.

1. Opening a file with Vim: `vim filename.txt`
    
2. Navigating within Vim:
    
    * Use the arrow keys or `h`, `j`, `k`, `l` to move the cursor.
        
    * Press `i` to enter the insert mode and start editing.
        
    * Press `Esc` to exit insert mode and return to command mode.
        
3. Saving and exiting Vim:
    
    * While in command mode, type `:w` to save the changes.
        
    * To exit Vim, type `:q`. If there are unsaved changes, use `:q!` to force exit without saving.
        

### Nano:

Nano is a straightforward and user-friendly text editor designed to be easy to use for both beginners and casual users. It offers a simple and intuitive interface with basic editing functionalities. Nano provides common features such as syntax highlighting, search and replace, and file navigation. It is often preferred for quick editing tasks or when a simpler and less overwhelming editor is required.

1. Opening a file with Nano: `nano filename.txt`
    
2. Editing text in Nano:
    
    * Nano provides on-screen instructions for various commands at the bottom of the editor.
        
    * Use the arrow keys to navigate through the file.
        
    * Press `Ctrl + O` to save the changes.
        
    * Press `Ctrl + X` to exit Nano.
        
3. Using search and replace in Nano:
    
    * Press `Ctrl + W` to search for a specific term in the file.
        
    * Press `Ctrl + \` to enable search and replace mode.
        
    * Follow the prompts to replace specific occurrences of a term in the file.
