#90DaysOfDevOps - Day 2: Linux and its basic commands
π DevOps Enthusiast | Continuous Learner | Bridging Development & Operations | Automating for Efficiency ππ€π | Exploring the Ever-Evolving Tech Landscape | Passionate about Collaboration & Innovation | Let's Build, Deploy, and Soar Together! π»π οΈπ
Welcome to Day 2 of #90DaysOfDevOps! Today, we embark on a journey to explore the Linux operating system, delving into its intricacies and mastering a few fundamental commands. ππ§
Linux
Linux π§ is an open-source operating system created by Linus Torvalds in 1991. π It boasts a flexible, customizable, and powerful π οΈ platform that empowers users to access, modify, and distribute its source code freely. With its strong community support π€ and a vast array of software packages, Linux has become a dominant force in web servers, supercomputers, cloud infrastructure, smartphones, and IoT devices. π»π± Its reputation for security, stability, and innovation π‘οΈπ§ has won the trust of businesses and individuals alike. Linux represents the spirit of collaboration and democratization of technology ππ, symbolizing the power of collective efforts in reshaping the digital landscape. π
Architecture
Linux architecture serves as the foundation for various Linux-based operating systems and is designed with flexibility and modularity in mind. ποΈ
At its core, the Linux architecture consists of the following components:
π Kernel: The heart of Linux, responsible for core functions, memory management, processes, and device drivers. It acts as an interface between software and hardware.
π¦ File System: Organizes data and programs into files and directories, using a hierarchical structure for efficient storage and retrieval.
π Device Drivers: Facilitate communication between the kernel and hardware devices, ensuring compatibility with diverse hardware.
π System Calls: Enable programs to request services from the kernel, such as file operations or process management.
ποΈ Libraries: Provide precompiled functions that applications can use, simplifying access to system functions.
π» Shell and Command-Line Interface: The shell, or command-line interpreter, allows users to execute commands, manage files, and run programs efficiently.
π₯οΈ Processes and Threads: Processes represent running programs, while threads enable multitasking and parallel execution within processes.
π Networking Stack: Manages networking operations, including TCP/IP protocols and socket communication, facilitating network connectivity for applications.
π Security Modules: Implement security features like access control, encryption, and authentication, enhancing the overall system security.
Linux in DevOps
Linux π§ plays a pivotal role in DevOps practices, acting as a backbone for seamless collaboration, automation, and scalability. As an open-source operating system, Linux enables developers and operations teams to customize and automate processes, reducing manual intervention and minimizing errors. It serves as the preferred platform for various DevOps tools, such as Ansible, Docker, and Kubernetes, facilitating efficient configuration management, containerization, and orchestration. Linux's stability, security features, and vast community support contribute to creating reliable and secure development and deployment environments. Overall, Linux empowers DevOps teams to streamline workflows, accelerate continuous integration and continuous deployment (CI/CD) pipelines, and drive innovation in software development. ππ»π§
Linux directory structure under root (/)
In Linux, the root directory (/) contains various standard directories that serve specific purposes and store essential files and subdirectories. Some of these directories are:
ποΈ /bin: Contains essential binary executables and commands. Example: /bin/ls - This command lists the contents of the current directory. ππ
π /boot: Stores files related to the boot process. Example: /boot/vmlinuz-5.4.0-86-generic - The Linux kernel file used during the boot process. π§π
π /dev: Represents device files for accessing connected devices. Example: /dev/sda - Represents the first hard disk drive in the system. π½π»
π§ /etc: Holds system-wide configuration files. Example: /etc/resolv.conf - Contains DNS server configuration for the system. βοΈπ
π /home: Contains user home directories. Example: /home/john - Home directory for the user "john." π¨βπ»π‘
π /lib and /lib64: Contain essential system libraries. Example: /lib/x86_64-linux-gnu/libc.so.6 - C library used by many programs. ππ§
πΏ /media: Used for temporarily mounting external media. Example: /media/usb-drive - A mount point for a USB drive. ππ
π /mnt: Used for temporarily mounting other file systems or network shares. Example: /mnt/network-share - A mount point for a network shared folder. ππ
π¬ /opt: Used for installing additional software from third-party vendors. Example: /opt/google/chrome - The installation directory for Google Chrome browser. π¬π
π /proc: A virtual file system providing information about system processes. Example: /proc/cpuinfo - Contains information about the CPU and its features. ππ
π /root: The home directory for the root user. Example: /root/.bashrc - The bash configuration file for the root user. π§ββοΈπ°
β³ /run: Contains temporary runtime files created by services. Example: /run/utmp - Keeps track of current login sessions. β³π
βοΈ /sbin: Contains system administration binaries. Example: /sbin/ifconfig - A command to configure network interfaces. βοΈπ§
π’ /srv: Intended to hold site-specific data served by the system. Example: /srv/www - Holds website data served by the web server. π’π
ποΈ /tmp: Used for temporary files. Example: /tmp/tempfile.txt - A temporary file created by an application. ποΈπ₯
π¦ /usr: Contains user-related files and applications. Example: /usr/bin/gcc - The GCC compiler binary. π¦π¨βπ»
π /var: Holds variable data, such as log files and temporary data. Example: /var/log/syslog - Contains system log messages. ππ
These directories form the essential structure of the Linux file system, each serving specific purposes and contributing to the overall functionality and organization of the operating system. ππ§
Now, let's get started with some hands-on tasks that cover basic Linux commands. πππ¦π»"
Tasks
Check your present working directory.

Use pwd (present working directory) to display the current directory of the present directory of user i.e. /home/ubuntu
Create a new directory called "practice_folder."

Use mkdir command to create a new directory practise_folder. Use ls command to display the contents of the current directory to verify that practise_folder directory is created.
Create three directories named "dir1," "dir2," and "dir3" in one go.

Use mkdir to create multiple directories dir1 dir2 and dir3 in one command by separating them with space.
Create a nested directory structure with directories A, B, C, D, and E inside each other.

Use the -p option with mkdir to create nested directory A/B/C/D/E. Use the tree command to display the directory structure of the current directory to verify the nested directory.
Enter the "practice_folder" directory you created earlier.

Use the ls command to check where is the practise_folder. Use the cd command to move into the practise_folder.
Move back to the parent directory from "practice_folder."

Use cd with .. to move to the parent directory of practise_folder.
Move to your home directory from anywhere in the file system.

Use cd with ~ or just enter cd to move to your home directory /home/ubuntu from anywhere in the file system (here it's moving from practise_folder).
List all the files and directories in your current working directory.

Use the ls command to list all the files and directories in the current working directory.
List all files and directories, including hidden files (files/folders whose names start with a dot).

Use the -a option with ls command to display all the files and directories along with hidden files. The hidden files start with a dot . like .bash_history shown in the output.
List files and directories in the current working directory with detailed information, including permissions, owner, group, size, and modification date.

Use the -l option with the ls command to list files and directories in the current working directory with detailed information, including permissions, owner, group, size, modification date, and name.
List files and directories in a specific directory.

Use the ls command along with the specific directory path i.e. /home/ubuntu to list files and directories of /home/ubuntu.
List files and directories in the current directory, sorted by size (largest to smallest).

Use the -S option with ls command to list files and directories in the current directory, sorted by size (largest to smallest). We can combine two options of the same command. Here we have combined -l and -S option.
List files and directories in the current directory, sorted by modification time (most recent first).

Use the -t option with ls command to list files and directories in the current directory, sorted by modification time (most recent first).
Conclusion
π Today, we have delved into the fascinating world of the Linux operating system! π§ We explored its architecture and discovered its pivotal role in the DevOps ecosystem. π» To add some excitement, we wrapped up with hands-on experience using basic commands: pwd, mkdir, cd, and ls. πββοΈ I hope this journey was a great start to your Linux learning adventure! ππ
"π± Keep learning, and spread the knowledge to inspire others. ππ‘"