Linux Core Concepts -2

Saurav chaudhary
8 min readSep 1, 2021

--

Welcome to the world of Linux

What are we going to learn in this Blog?

  1. Introduction to the Linux Kernel (Part-1)
  2. Kernel Space and User Space (Part-1)
  3. Working with Hardware (Part-1)
  4. Linux Boot Sequence (Part-2)
  5. SYSTEMD TARGETS (RUNLEVELS) (Part-2)
  6. Filesystems and Hierarchy (Part-2)

Linux Boot Sequence

The Linux boot sequence process comprises of 4 simple steps —

  1. BIOS POST
  2. Boot Loader (GRUB2)
  3. Kernel Initialization
  4. INIT Process (systemd)

when Linux boot sequence should get started?

whenever your system is the halt mode or stop or whenever you just reboots your system , this Linux boot sequence will take place .

Now let’s deep dive into each of them and see how they contribute to the Linux boot sequence .

1 . BIOS POST — This test has actually nothing to do with the Linux. This post test i.e. power on self test starts as the first step. This test checks out all the hardware configuration so that they are ready to launch or not . If there will be any problem in the initial process then it will not go to the second sequence.

2. Boot Loader (GRUB2) — GRand Unified Bootloader (GRUB2) this the most advanced boot loader and comes pre-build in most of the Linux distros. This sequence takes over after the BIOS POST. Basically this will give you options to choose your configurations. Its function is to take over from BIOS at boot time, load itself, load the Linux kernel into memory, and then turn over execution to the kernel. It passes the parameters needed for the kernel initialization and loads up into the kernel memory for the next step i.e. Kernel Initialization.

3. Kernel Initialization — This process initialize the kernel loads up the memory, checks the parameters , assign the memory. Do all memory management , starts the process management i.e. needed for the services processes to get started in the next step.

4. INIT Process (systemd) — And here is the last process of the Linux boot sequence, where we will start the services along with some GUI/CLI contents . systemd is responsible for setting the files sequence and much more . we will learn systemd in much more detail . before systemd , there was systerm5 which does the same work . but the main advantage of using systemd over system5 (sis5) as is it takes so much less time as it starts the service boots in a parallel mode so it is quite faster than the sysstem5.

To check what are you using system5 or systemd run the following command.

SYSTEMD TARGETS (RUNLEVELS)

After the boot sequences of Linux most of you will see a screen a like this which has a graphical user interface while most of the working professionals have a Command line screen instead of GUI screen. so why is this happening lets see and fix this to make you a CLI Linux developer.

Default GUI screen
My default CLI screen

Let me tell you why this is happening 😅

If you will run this command , you will get this output while I run the same command I will get that output

Yep, you guys have got it right. This is all the game that has been played by the run level.

wanna deep dive to feel the vibe lets go then 😝

Whenever your system boots in , the init process that has systemd which initialize or enable the display manger service by which the runlvel changes from 5 and as a result you will get a GUI screen .

The function which Boots into a Graphical Interface is known as run level 5 and has a value of systemd.target = graphical.target

while

The function which Boots into a Multi-user Interface is known as run level 3and has a value of systemd.target = multi-user.target

So here is your answer of how to change your default GUI screen into default CLI screen.

Default screen
File DIR /lib/systemd/system/graphical.target
Change by this command

So finally you are a CLI dev ,congrats 😚 welcome to the team Homey!

So many changes I have done in my initial config to show you examples , now i have to revert back 😝. so much of efforts i am putting in , so please like share this blog to your friends

File Types in Linux

Every thing in Linux is a file even a directory is a type a file.

Generally Linux files are divided into 3 types —

  1. Regular File — Regular files are those types of files which contain normal data , texts, images and some of the configuration.
  2. Directory — It is a special type of file. it contains directory and under the directory some files. example- your home dir.
  3. Special Files- special files are further divided into 5 types

a) Character Files — Character files are those types of files which help the OS to communicate with IO and it is locate under the dev. example — your mouse, keyboard.

b) Block Files — We have discussed BLOCK DEVICE files in very detail . watch part-1 eg- ram, hard-disk

c)Links- Links are the way to connect two files together

hard link- in this type two files shares the same data and by deleting the one file result in deleting the other .

soft link-in this type one file points to other as a pointer and by deleting one file data would not result in deleting other.

d) socket files- socket files are specials types of files that enables communication between processes.

e) Named pipes- Named files are those files which connects one process as an input of other . the flow of the data in this type of files are unidirectional . we will learn named pipes in detail , so don't worry about it 😃

How to check a particular file is of which type?

Run File command and use file name , file dir. as an arguments.

you can use an alternative command too i.e.

Here the first letter of the output will determine the file type. check the first letter with the fig below and boom 😅

File Hierarchy

So here is the main file directory that you will encounter while working with Linux. so lets learn line by line

/home — it is the home directory where all data resides expect the root one.

/root — it is the main and the root of all the directories.

/opt — it is the directory where you can download the 3rd party .lets suppose we have to downlead the web server so /opt will be the right choice

/bin -it is the directory where the basic Linux commands like mkdir, mv and all those commands resides.

/dev — it is the directory where all the block device files and character files resides

/etc — it is used to store most of the configuration files of the Linux

/lib — it is the directory where all the shared libs like lib_64 by the program resides

/media — it is the directory where all media resides like the content of usb drive which we have inserted in last blog 😅

/var — in case you get into an error , this directory contains Logs which will help you out.

/tmp — it is the temporary file where all the temporary data resides.

/mnt — lets suppose we have download some 3rd party app, and due to some vulnerabilities issues we have to mount those files so we will mount those files here

/usr- it is the where all the user land data resides like Firefox.

Hands-on experience exercises

There are some sets of questions based on the Linux core concepts those you have learned above, now its time to test yourself . so make sure to test yourself before moving to the next blog .Comment on the blog and let me know how much marks you have achieved. In case of any doubts/questions/suggestions feel free to Dm me on Twitter.

  1. What is the init process used by this system?
  2. What is the default systemd target set in this system?
  3. Change that default to multi-user target.
  4. You are asked to install a new Third-party IDE in the system. Which directory is the recommended choice for the installation?
  5. Which directory contains the files related to the block devices that can be seen when running the lsblk command?
  6. What is the name of the vendor for the ethernet controller used in this system?

Try this all questions to test yourself and let me know

Happy learning 😃

Follow us on Twitter To join us in the initiative of learning Devops in 60 days.

see you in next blog, stay happy 😄

--

--