Step into a World of Discovery: Unveiling the Wonders of Linux System Management. Delve into the Secrets of Linux File Management during my exhilarating #120daysofdevops adventure. Come along as we navigate the vast realms of the filesystem and storage, honing our skills in efficient system control. Together, let's dive into the captivating world of Linux file management
Introduction
So far, we have gained valuable insights into Linux and DevOps. We began by providing a concise introduction to Linux and DevOps, and subsequently delved into the fundamental concepts of Linux Architecture on Day 4. In addition, we explored a subset of essential commands that form the foundation of your everyday toolkit in the terminal for efficient task completion on Day 3.
Now, let's delve into three pivotal aspects of managing your Linux systems effectively: system updates, software installation, and comprehending the purpose of system folders. Furthermore, we will explore the topic of storage, enabling you to develop a comprehensive understanding of its significance in Linux system administration.
Ubuntu Software Management Decoded: Best Approaches and Techniques
The first thing we are going to look at is how we update our operating system. Most of you will be familiar with this process in a Windows OS and macOS, this looks slightly different on a Linux desktop and server.
We are going to be looking at the apt package manager, this is what we are going to use on our Ubuntu VM for updates and software installation.
Generally, at least on dev workstations, I run this command to make sure that I have the latest available updates from the central repositories, before any software installation.
sudo apt-get update
We have successfully updated our Ubuntu VM, ensuring that it is equipped with the latest operating system updates. Now, our next objective is to install additional software on the system.
For this demonstration, let's install a program called "figlet
," which generates text banners.
Upon entering the command "figlet
" in the terminal, you will notice that it is not currently installed on our system.
As you can see from the previous output, there are several apt
install options available for us to consider. This is because the default repositories contain a program called figlet. To proceed with the installation, let's execute the following command:
sudo apt install figlet
We can now use our figlet
app as you can see below.
File System Explained
Linux systems consist of various configuration files that govern the behavior and settings of the operating system and applications. If you wish to modify any aspect of the system, these configuration files are where you make the necessary changes.
In contrast to Windows, which has the C: drive as its root, Linux employs the symbol "/" to represent the root directory. This is the starting point from which we navigate the Linux file system. The root directory encompasses essential folders that play crucial roles in the Linux system's functioning.
- The
/bin directory
, derived from the term "binary," serves as a location for storing essential binaries, executables, and tools that are crucial for your system's operation. It houses a variety of executables and commands that enable various functions and operations within your Linux system.
-
The /boot
directory holds all the critical files required for booting up your system. It contains essential components that determine how the system boots and which drive or partition it boots from. Within the /boot directory, you will find configuration files, such as bootloader configurations (e.g., GRUB or LILO), kernel images, initial RAM disk (initrd) files, and other necessary files related to the boot process. These files are responsible for initiating the system startup, loading the kernel, and establishing the initial environment required for the operating system to begin functioning.
In summary, the /boot directory contains the necessary files and configurations that facilitate the booting process and dictate the boot device or partition used by your Linux system.
-
The /dev
directory serves as a repository for device-related information in Linux. It contains special files known as device nodes that act as interfaces to physical and virtual devices connected to the system.
Within the /dev directory, you can access and manage various devices, including disk drives, through the device nodes. For instance, your primary operating system disk is typically represented as "sda" in the /dev directory. Other devices, such as external storage drives, input/output devices, and network interfaces, also have corresponding device nodes in this directory.
By interacting with the device nodes in /dev, you can access and manipulate the connected hardware devices, enabling tasks such as reading from or writing to disks, managing input/output operations, and configuring device-specific settings.
-
/etc
Likely the most important folder on your Linux system, this is where the majority of your configuration files are.
-
/home
- this is where you will find your user folders and files. We have our vagrant user folder. This is where you will find your Documents and Desktop folders that we worked in for the commands section.
-
The /lib
directory plays a crucial role in the Linux system by housing shared libraries that are essential for the proper functioning of the binaries and executables located in the /bin directory. Shared libraries, often denoted by file extensions like .so (shared object), contain code and resources that are shared across multiple programs. These libraries provide common functionality, such as system calls, input/output operations, and other essential functionalities that programs rely on.
In/lib
, you will find a collection of these shared libraries, which are dynamically linked to the binaries residing in /bin and other directories. When a program is executed, it dynamically links to the required shared libraries from /lib to access the necessary functions and resources.
Therefore, the /lib
directory serves as a vital repository for shared libraries, enabling efficient resource sharing and reducing redundancy across the Linux system's executables and binaries.
-
/media
- This is where we will find removable devices.
-
The /mnt
directory serves as a temporary mount point in Linux. It is specifically designed to be a location for manually mounting external or temporary file systems.
When you need to access or work with external storage devices, such as USB drives, external hard disks, or network shares, you can mount them to specific directories under /mnt. By doing so, you make the contents of the mounted file system accessible within that directory.
In the upcoming storage section, we will explore this concept further and discuss various aspects related to mounting, managing, and working with storage devices in Linux. Stay tuned for more detailed information on utilizing the /mnt directory as a temporary mount point.
-
/opt
- Optional software packages. You will notice here that we have some vagrant and virtual box software stored here.
-
The /proc
directory serves as a virtual file system that provides kernel and process-related information in Linux. It offers a structured interface for accessing real-time data about the system's running processes and the kernel itself.
Within the /proc directory, you can find a collection of numbered directories, each representing a running process on the system. These directories contain detailed information about each process, including its ID (PID), memory usage, CPU utilization, file descriptors, and more.
Additionally, the /proc directory contains various system-related files and directories that offer insights into the kernel's configuration, hardware devices, and system statistics. You can access information about CPU, memory, network interfaces, interrupts, and other kernel-related details through these files.
Similar to the /dev directory, which provides access to device information, the /proc directory acts as an interface to kernel and process information, offering a dynamic and informative view of the system's inner workings.
-
/root
- To gain access you will need to sudo into this folder. The home folder for root.
The /run
directory serves as a placeholder for application states in Linux. It provides a location where applications can store temporary files, runtime data, and other information related to their current state.
This directory is particularly useful for applications that require a location to store data that needs to persist across reboots but should be cleaned up during each system start up. It allows applications to store runtime files and information without relying on specific storage locations that may vary between different systems or configurations.
The /run
directory is typically used by daemons, services, and other background processes to store their runtime files, such as process IDs (PIDs), socket files, lock files, and other temporary data. By utilizing the /run
directory, applications can maintain their state across system reboots and ensure proper initialization and coordination with other components.
In summary, the /run
directory acts as a convenient location for applications to store temporary files and runtime data, facilitating proper handling of application states in a consistent and system-independent manner.
-
/sbin
- Sudo bin, similar to the bin folder but these tools are intended for elevated superuser privileges on the system.
-
/tmp
- temporary files.
-
The /usr
directory plays a significant role in Linux as it houses user-specific files and resources. When standard users install software packages on their systems, these packages are typically installed in the/usr/bin
location.
Within /usr/bin
, you will find executable files for various user-installed software applications. These binaries are readily accessible to users, allowing them to execute the installed programs conveniently.
Moreover, the /usr
directory encompasses additional subdirectories such as /usr/lib
, which contains libraries specific to user-installed software, and /usr/share
, which holds architecture-independent data shared among applications. These subdirectories provide a structured organization for user-specific resources and ensure compatibility and consistency across installed software packages.
By separating user-installed software into the /usr
directory, the Linux system maintains a clear distinction between system-wide files and user-specific files, promoting better management and control over installed software packages.
-
/var
- Our applications get installed in a bin folder. We need somewhere to store all of the log files this is/var
Storage
When working with a Linux system or any other system, it is essential to identify the available disks and understand the amount of free space on those disks. The following commands will assist us in recognizing, utilizing, and managing storage effectively.
The first command, "lsblk,
" allows us to list the block devices on our system. By executing this command, we can obtain information about the available disks and their associated partitions. For instance, the disk labelled "sda
" represents our physical disk, while "sda1," "sda2," and "sda3
" denote the partitions on that particular disk.
Using the output of the "lsblk
" command, we can gather a clear overview of the disks and partitions present in our system, which is crucial for storage management and allocation.
-
df
gives us a little more detail about those partitions, total, used and available. You can parse other flags here I generally usedf -h
to give us a human output of the data.
If you are adding a new disk to your Linux system, the process is similar to how it is done in Windows. In Linux, you can format the disk in the terminal using the command "sudo mkfs -t ext4 /dev/sdb," where "sdb" corresponds to the newly added disk. This command will format the disk with the ext4 file system, but you can choose a different file system if desired.
After formatting, the next step is to mount the newly formatted disk to make it usable. You can achieve this by creating a directory in the /mnt
folder, such as "sudo mkdir NewDisk
," and then using the command "sudo mount /dev/sdb newdisk
" to mount the disk to that location.
When it comes to removing storage from your system safely, it is important to unmount it first rather than simply pulling it from the configuration. You can unmount the disk using the command "sudo unmount /dev/sdb
."
If you intend to use the disk persistently, such as for a database or other long-term use cases, you will want the disk to be automatically mounted upon system reboot. To accomplish this, you need to add the disk to the /etc/fstab
configuration file. Without adding the disk to this file, it won't be automatically mounted upon system restart, and you would need to manually go through the above process again. The data will still remain on the disk, but it won't be accessible unless the configuration is added.
After editing the fstab
configuration file, you can validate your changes by using the command "sudo mount -a
." If there are no errors, your changes will persist across restarts.
In my tomorrow session, I will cover how to edit files using a text editor.
Thanks for Reading, hope to see you tomorrow.
Top comments (1)
I can't wait to learn something new tomorrow