#90DaysOfDevOps - Day 2: Linux and its basic commands
Table of contents
- Linux
- Architecture
- Linux in DevOps
- Linux directory structure under root (/)
- Tasks
- Check your present working directory.
- Create a new directory called "practice_folder."
- Create three directories named "dir1," "dir2," and "dir3" in one go.
- Create a nested directory structure with directories A, B, C, D, and E inside each other.
- Enter the "practice_folder" directory you created earlier.
- Move back to the parent directory from "practice_folder."
- Move to your home directory from anywhere in the file system.
- List all the files and directories in your current working directory.
- List all files and directories, including hidden files (files/folders whose names start with a dot).
- List files and directories in the current working directory with detailed information, including permissions, owner, group, size, and modification date.
- List files and directories in a specific directory.
- List files and directories in the current directory, sorted by size (largest to smallest).
- List files and directories in the current directory, sorted by modification time (most recent first).
- Conclusion
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. ๐๐ก"