Get Started With Different Linux Distribution

Ayush Bhat
9 min readSep 12, 2021

In this blog we will be exploring why Filesystem Hierarchy Standard is necessary. We will also see what are different Package Management Systems on various Linux Distros like RHEL , Ubuntu and OpenSUSE.

Source Internet

The term Linux refers to operating system kernel , it is the one that provides the process a way to interact with the hardware. The system hardware is managed by kernel. As process can’t directly access the resources. The process makes system calls to kernel and kernel provides the resources(RAM/CPU/Hard Disk).

The main responsibilities of the kernel include:

  • System initialization and boot up
  • Process scheduling
  • Memory management
  • Controlling access to hardware
  • I/O between applications and storage devices
  • Implementation of local and network filesystems
  • Security control, both locally (such as filesystem permissions) and over the network
  • Networking control.

Data Distinctions

When we are organizing data in one big directory tree, we need to understand the property of our data and files. There are two ways to distinct data.

Shareable vs Non-Shareable : Shareable data is that which can be shared among different hosts. Non-Shareable data is that which is meant for a particular host.

Static vs Variable : Static data includes documentation, binaries that most probably don’t change. Variable data is that which may change in some time.

Need for FHS

Filesystem Hierarchy Standard (FHS) : It specifies the main directories on the system and defines their purpose. Let’s now understand the purpose of some directory.

  1. Root(/) : It contain files that are required to boot the system and mount to all other filesystem.
  2. /bin : Contains executable program and scripts that are required when no other filesystem has been mounted. For example, in recovery mode. Some programs that can be find in it are :
Taken From RHEL 8 System

Note : The recent distributions are not separating /bin and /usr/bin , they are using one directory with symbolic links. Same goes with /sbin and /usr/sbin, /lib and /usr/lib

3. /boot : Has the files essential for booting the system.

Two files that are absolutely essential are vmlinuz and initramfs as you can see them from the above screenshots.

Brief about files

vmlinuz : contains compressed Linux kernel.

initramfs : Initial ram filesystem.

How to configure the kernel compilation and how to debug if error comes?

To configure the kernel compilation, config file do this.

For debugging, kernel system tables are used which can be found in System.map

Inside System.map

4. /dev : contains device nodes that represents devices that are built-in or connected to the system.

Udev system creates nodes in /dev only when new devices are found.

5. /etc : It contains machine-local configuration files and some startup scripts.

6. /lib and /lib 64 : Contains only those libraries that are needed to execute binaries in /bin and /sbin. These are important for booting the system and executing commands within the root filesystem.

If you want to find out where are kernel modules in the system ?

You can check it out here.

/lib, /lib64 are symbolically linked to directory /usr/lib and /usr/lib64 respectively

7. /opt : Designed for software packages that want to keep all their files in one isolated place.

Benefits:

Makes installing and uninstalling software easy.

Helps to determine nature of each file

8. /proc : It is a mount point for pseudo-filesystem

Pseudo Filesystem : Where all information resides only in memory

Note : /proc, /dev , /sys are empty on non-running system

Each process has it’s own subdirectory and that gives detailed information about the resources it is using and it’s history

Going inside process and checking details

Virtual Files : All the entries inside /proc are called virtual files. Why are they called so? Because they have an interesting property. When these files are listed most of the files show that they have size of 0 bytes, but when opened they contain a lot information. Now let us check the size of /proc/1 whose detail we have seen in the above screenshots.

Virtual File

Important Pseudo-Files are: /proc/interrupts, /proc/meminfo, /proc/mounts, /proc/partitions,/proc/filesystems and the /proc/sys/

9. /sys : mount point for the sysfs pseudo-filesystem. Contains information about devices and drivers, kernel modules, system configuration structures, etc.

10 . /root : It is home directory for root user.

11. /sbin : Contains binaries that are essential for recovery, restoring and booting.

12. /tmp : Used to store temporary files that can be accessed by any user or applications. Avoid creating large files on /tmp as it occupy space in memory rather than the disk.

13. /var : Contains volatile data files that changes during system operation. These includes log files, Spool directories and files(Purpose. /var/spool contains data which is awaiting some kind of later processing), temporary files(such as cache content).

In this section we will see how we can use nice and renice to set and modify priorities. But before jumping to that let us understand some basics.

Process

In simple words, when a program loads on ram and CPU gives it time; it becomes process.

Process Attributes

  1. The Program being executed
  2. Context : When a process is being executed, at any moment the process can take a snapshot of itself to remember the state of it’s CPU registers , what is in the process’ memory and more things. This is the Context of the process.

Context Switch : a context switch is the process of storing the state of a process or thread, so that it can be restored and resume execution at a later point.

3. Permission: Every process has permission based on which user has called it.

4. Associated Resources : Every process has resources associated with it such as allocated memory and file handles.

Process Resource Isolation : When a process starts , it is isolated in it’s own user space to protect it from other resources by this means it aims to provide security and greater stability.

Ulimit

If you are interested in knowing how much resource limit has been associated with the process running under the shell. Then ulimit bash command will help us.

  • ulimit is admin access required Linux shell command which is used to see, set, or limit the resource usage of the current user.
  • -a : all current limits are reported

In ulimit, there are two kinds of limit Hard and Soft

Hard : maximum value set by the root user that a user can raise to resource limit.

Soft : It is the current value which the user can modify but can’t exceed the hard limit.

Process State

  • Running : In modern computers many processes run at once. Active processes are placed in an array called a run queue. Here process is either currently executing on CPU or sitting in the run queue waiting for CPU to give it time slice.
  • Sleeping (i.e., Waiting) : The process is waiting for the completion of it’s request.
  • Stopped : Process is currently in stopped condition.
  • Zombie : When a process enters this state and gets terminated and parent process has not inquired about it’s state.

Using Nice and Renice

Nice : Higher the niceness is the lower the priority.

Note : The processes with higher niceness will also be run if there are not other process with higher priorities.

Nice Range lies b/w -20 to 19. If you do not give a nice value, the default is to increase the niceness by 10.

nice command

Renice : Lets you change the nice value on the fly

renice command

Using gnome-system-monitor : Graphical utility to renice

Package Management Systems

Why to use Package, this a common question which arises?

Package Features will all tell us about this question. Features are as follows:

  1. Automation : No need to manually install
  2. Security
  3. Scalability

Available Package Management Systems

  1. RPM : Used in RHEL, CentOS , SUSE

2. DPKG : Ubuntu, Linux Mint, Debian

Packaging Tools levels and varieties

Low Level

  • Installs or removes a single package
  • Package dependency is not handled well
  • Eg. RPM and DPKG

High Level

  • Solves dependency issues
  • dnf and zypper utilities take care of the dependency resolution for rpm systems, and apt-get and apt-cache take care of it for dpkg systems.

Let’s start with RPM

RPM is a package management utility developed by Red Hat.

Let’s see what are the commands and how to use it ?

  • To see which version of the package is being installed.
  • Can you tell me from which package this file come from?
  • Can you list all the files that were installed by this package?
  • Hey RPM can you list all the packages that are installed on this system.
--requires : returns a list of prerequisites of a package
  • We can use — test along with to test whether the uninstallation would succeed or fail without doing the uninstall.

If operation is successful rpm does not print the output.

Now Let’s see some commands related to DPKG

-L : list files installed in nginx package
Debian Based, Ubuntu
Purge : get rid,  remove all of an installed package, including its configuration files.command 
dpkg -P package

Moving to DNF

Dnf : It has the capabilities to retrieve packages from one or more remote repositories.

  • Search for packages with Python
  • Displays information about firefox
  • Shows information about package groups installed, available and updates
  • Show the dependencies of the bash package

Time to switch to Zypper

Zypper : Installing and Managing packages in SUSE Linux and openSUSE

  • Same role as dnf or yum

Command:

  • Repos : lists available repos
openSUSE

About APT

APT(Advanced Packaging Tool ) : main utilities are apt-get, apt-cache. It works with Debian Package.

  • apt, apt-get, apt-cache : These are APT command line tools for package management.
  • dnf, zypper, apt : These utilities can work with multiple remote repositories.

Command

  • apt-cache search metapackage : Shows us the available metapackages
  • Bacula : set of open source programs, computer programs that permit you to manage backup, recovery.
Installing bacula-client

That’s all for now.

Thank you for reading.

--

--

Ayush Bhat

AWS SAA-C02 | Certified Kubernetes Administrator | Linux Foundation Certified Sysadmin | Ex294 RedHat Certified Engineer