"Day 2 in DevOps: Understanding of Linux and its basic commands"

Β·

9 min read

"Day 2 in DevOps: Understanding of Linux and its basic commands"

Here's a basic understanding of Linux in simple language with some fun emojis! πŸ§πŸ’»

  1. What is Linux?
    Linux is an operating system (OS) like Windows or macOS. It's what helps your computer run and manage all the programs. Think of it like the brain of your computer! 🧠

  2. Why use Linux?
    Linux is popular because it's free, open-source, and customizable! You can change almost anything about it. Plus, it's super secure πŸ›‘οΈ and great for programming πŸ–₯️.

  3. Files & Directories
    In Linux, everything is organized in files and folders (also called directories). You navigate through them using the command line, which is like talking directly to your computer.
    Example: /home/user/documents πŸ—‚οΈ

  4. Terminal & Commands
    Linux often uses a terminal (a black window where you type commands). Instead of clicking around, you tell Linux what to do with text commands.
    Common commands:

    • ls – shows the files in a folder πŸ“‚

    • cd – changes the current folder 🚢

    • mkdir – makes a new folder πŸ› οΈ

    • rm – removes (deletes) files or folders πŸ—‘οΈ

  5. Permissions
    Linux has strict permissions for files. It controls who can read, write, or execute a file:

    • r (read) πŸ‘€

    • w (write) ✍️

    • x (execute) πŸš€

  6. Package Manager
    In Linux, you use a package manager to install software. Instead of downloading apps from websites, you type commands to install, update, or remove software.
    Example: sudo apt install vlc πŸ“¦

  7. Why do techies ❀️ Linux?
    It's great for developers and system admins because it's lightweight, flexible, and secure. Also, Linux is everywhereβ€”from servers to smartphones! 🌍

Here’s a list of essential Linux commands, with descriptions and examples to help you understand how they work:

1. ls – List Directory Contents

  • Description: Displays the files and directories in the current folder.

  • Example:

      bashCopy codels
    

    Output: Lists all files and folders in the current directory.

2. cd – Change Directory

  • Description: Moves between directories.

  • Example:

      bashCopy codecd /home/user/documents
    

    Moves you to the "documents" folder inside the "user" directory.

3. pwd – Print Working Directory

  • Description: Shows the full path of the current directory you're in.

  • Example:

      bashCopy codepwd
    

    Output: /home/user

4. mkdir – Make Directory

  • Description: Creates a new directory (folder).

  • Example:

      bashCopy codemkdir myfolder
    

    Creates a directory named "myfolder" in the current location.

5. rm – Remove Files or Directories

  • Description: Deletes files or directories.

  • Example:

      bashCopy coderm myfile.txt
    

    Deletes the file "myfile.txt".
    To remove a folder and its contents:

      bashCopy coderm -r myfolder
    

6. cp – Copy Files or Directories

  • Description: Copies files or folders from one location to another.

  • Example:

      bashCopy codecp file.txt /home/user/backup/
    

    Copies "file.txt" to the "backup" folder.

7. mv – Move or Rename Files

  • Description: Moves files or folders to another location or renames them.

  • Example:

      bashCopy codemv file.txt /home/user/backup/
    

    Moves "file.txt" to the "backup" folder.
    To rename a file:

      bashCopy codemv oldname.txt newname.txt
    

8. cat – Concatenate and Display File Contents

  • Description: Displays the contents of a file.

  • Example:

      bashCopy codecat file.txt
    

    Outputs the content of "file.txt" to the terminal.

9. touch – Create an Empty File

  • Description: Creates a new empty file.

  • Example:

      bashCopy codetouch newfile.txt
    

    Creates a blank file named "newfile.txt".

10. chmod – Change File Permissions

  • Description: Changes the read, write, and execute permissions of a file or directory.

  • Example:

      bashCopy codechmod 755 script.sh
    

    Sets the permissions of "script.sh" to allow the owner to read, write, and execute, while others can only read and execute.

11. chown – Change File Ownership

  • Description: Changes the owner and group of a file or directory.

  • Example:

      bashCopy codechown user:group file.txt
    

    Changes the owner of "file.txt" to "user" and the group to "group".

12. ps – Display Running Processes

  • Description: Shows currently running processes on the system.

  • Example:

      bashCopy codeps aux
    

    Outputs a list of all running processes and their details.

13. kill – Terminate a Process

  • Description: Ends a running process by its ID.

  • Example:

      bashCopy codekill 1234
    

    Terminates the process with ID 1234.

14. df – Display Disk Space Usage

  • Description: Shows how much disk space is used and available.

  • Example:

      bashCopy codedf -h
    

    Displays disk usage in human-readable format (with MB/GB).

15. du – Display File Space Usage

  • Description: Shows the space used by files and directories.

  • Example:

      bashCopy codedu -sh /home/user/
    

    Displays the total size of the "user" directory in a human-readable format.

16. man – Manual Pages for Commands

  • Description: Displays the manual (help) for a command.

  • Example:

      bashCopy codeman ls
    

    Shows the manual page for the ls command.

17. sudo – Run a Command as Superuser

  • Description: Allows you to run commands with superuser (root) privileges.

  • Example:

      bashCopy codesudo apt update
    

    Runs the apt update command with root permissions.

18. apt or yum – Install/Update Packages

  • Description: Used for installing, updating, and removing software packages.

  • Example (Debian/Ubuntu):

      bashCopy codesudo apt install package-name
    

    Installs a software package.
    Example (CentOS/RedHat):

      bashCopy codesudo yum install package-name
    

Here are some common examples of Linux servers, each tailored for different use cases:

1. Web Server

  • Example: Apache HTTP Server or Nginx

  • Description: These servers host websites and serve web pages to users. They can handle multiple requests and serve static and dynamic content.

  • Common Use: Hosting websites, applications, and APIs.

2. File Server

  • Example: Samba or NFS (Network File System)

  • Description: Allows users to store and share files over a network. Samba enables file sharing between Linux and Windows systems, while NFS is primarily for Unix/Linux systems.

  • Common Use: Centralized file storage for organizations, backup solutions.

3. Database Server

  • Example: MySQL, PostgreSQL, or MongoDB

  • Description: These servers manage databases and provide data storage and retrieval services for applications.

  • Common Use: Storing data for websites, applications, and services.

4. Mail Server

  • Example: Postfix or Dovecot

  • Description: Handles sending, receiving, and storing email. Mail servers can include various components such as SMTP for sending mail and IMAP/POP3 for retrieving mail.

  • Common Use: Managing corporate email, newsletters, and personal email services.

5. Application Server

  • Example: Tomcat, WildFly, or Node.js

  • Description: Runs applications and processes requests from clients. It may serve dynamic web content and handle business logic.

  • Common Use: Hosting enterprise applications, RESTful APIs, and microservices.

6. DNS Server

  • Example: BIND (Berkeley Internet Name Domain) or Unbound

  • Description: Translates domain names into IP addresses, enabling users to access websites using human-readable addresses instead of numerical IPs.

  • Common Use: Providing DNS services for domains and subdomains.

7. Proxy Server

  • Example: Squid or HAProxy

  • Description: Acts as an intermediary between clients and servers, providing anonymity, load balancing, and caching services.

  • Common Use: Improving web performance, filtering content, and controlling access.

8. Virtualization Server

  • Example: KVM (Kernel-based Virtual Machine) or VMware

  • Description: Allows multiple virtual machines to run on a single physical server, enabling efficient resource usage.

  • Common Use: Running multiple OS environments, testing, and development.

9. Containerization Server

  • Example: Docker or Kubernetes

  • Description: Manages containers, which are lightweight, portable applications that run consistently across different computing environments.

  • Common Use: Microservices architecture, DevOps workflows, and application deployment.

10. Backup Server

  • Example: Bacula or rsync

  • Description: Manages data backups for systems and applications, ensuring data recovery in case of loss.

  • Common Use: Protecting critical data, disaster recovery solutions.

11. Streaming Server

  • Example: Icecast or Wowza

  • Description: Delivers audio and video content over the internet in real-time.

  • Common Use: Streaming music, video on demand, and live broadcasts.

Linux has a wide variety of distributions (often referred to as "distros"), each tailored for specific use cases, preferences, and audiences. Here’s a breakdown of some of the most popular Linux distributions:

1. Ubuntu

  • Description: One of the most popular and user-friendly Linux distributions, great for beginners.

  • Use Cases: Desktop, server, and cloud environments.

  • Key Features: Easy installation, large community support, and regular updates.

2. Debian

  • Description: Known for its stability and extensive package repository.

  • Use Cases: Desktop, servers, and development.

  • Key Features: Excellent package management with apt, and a strong focus on free software.

3. Fedora

  • Description: A cutting-edge distribution sponsored by Red Hat that features the latest technologies.

  • Use Cases: Desktop and development environments.

  • Key Features: Frequent updates, strong support for developers, and a commitment to open-source principles.

4. CentOS (Community ENTerprise Operating System)

  • Description: A free and open-source version of Red Hat Enterprise Linux (RHEL), designed for stability and long-term support.

  • Use Cases: Servers and enterprise environments.

  • Key Features: Reliable, secure, and suitable for production environments.

5. Arch Linux

  • Description: A lightweight and flexible distribution aimed at advanced users who want to customize their OS.

  • Use Cases: Desktop and development environments.

  • Key Features: Rolling release model, simple package management with pacman, and extensive customization options.

6. Manjaro

  • Description: Based on Arch Linux but more user-friendly and accessible to beginners.

  • Use Cases: Desktop environments.

  • Key Features: Easy installation, pre-configured desktops, and access to Arch repositories.

7. openSUSE

  • Description: A versatile and stable distribution, available in two versions: Leap (stable) and Tumbleweed (rolling release).

  • Use Cases: Desktop and server environments.

  • Key Features: YaST (Yet another Setup Tool) for easy configuration, strong community support.

8. Linux Mint

  • Description: Based on Ubuntu, Linux Mint is designed to be easy to use and provide a familiar interface for newcomers.

  • Use Cases: Desktop environments.

  • Key Features: User-friendly interface, multimedia support out of the box, and strong community support.

9. Slackware

  • Description: One of the oldest distributions, focusing on simplicity and minimalism.

  • Use Cases: Advanced users and system administrators.

  • Key Features: Stability, configurability, and a classic Unix-like environment.

10. Kali Linux

  • Description: A Debian-based distribution designed for penetration testing and ethical hacking.

  • Use Cases: Security professionals and ethical hackers.

  • Key Features: Pre-installed security tools and a focus on security research.

11. Zorin OS

  • Description: A distribution that aims to provide a familiar experience for users transitioning from Windows or macOS.

  • Use Cases: Desktop environments for beginners.

  • Key Features: User-friendly interface, pre-installed applications, and customization options.

12. Alpine Linux

  • Description: A lightweight and security-oriented distribution designed for power users and developers.

  • Use Cases: Containers, servers, and embedded systems.

  • Key Features: Minimalistic design, fast boot time, and uses musl libc instead of glibc.

13. Elementary OS

  • Description: A visually appealing distribution focused on simplicity and usability.

  • Use Cases: Desktop environments.

  • Key Features: Custom desktop environment (Pantheon), beautiful design, and user-friendly experience.

In conclusion, exploring the various Linux distributions offers a gateway to an open-source ecosystem that empowers users with flexibility, security, and community support. Whether you're a beginner looking for user-friendly options or an advanced user seeking customization, there's a Linux distro that can meet your needs. Embracing Linux not only enhances your technical skills but also connects you to a vibrant community dedicated to innovation and collaboration. Dive in, experiment, and discover the endless possibilities that Linux has to offer!

Here are some official and reputable resources where you can learn about Linux:

http://www.tldp.org/

https://help.ubuntu.com/

Β