Linux Core Concepts For DevOps & Cloud (Part-2)

Course Code- 1.2.3 & Creator- Saurav Chaudhary

Saurav chaudhary
9 min readJan 14, 2022

Blog Objective -:

  1. Introduction to the Linux Kernel
  2. Kernel Space and User Space
  3. SSH Commands
  4. File Types in Linux
  5. File System Hierarchy
  6. Users & Permissions

Introduction to the Linux Kernel

Kernel acts as an interface between the computer hardware like CPU, memory, devices, and the applications /processes. It works efficiently to manage some of the kernel properties.

What Functions Does Kernel Provide?

  1. Memory Management — Kernel takes care of which process has taken how much of memory and where and in this way it helps in managing the memory.
  2. Process Management — It determines which process can use the CPU and for how long it can use it?
  3. Device Drivers — It acts as an interpreter or a mediator between the hardware and the processes.
  4. System Calls and Security — It receives requests from the processes known as a system call and completes the security processes to clarify there is no such vulnerates in-between.

Some of the main features of Kernel are -

  1. Monolithic — Monolithic simply means, the kernel manages memory management, CPU scheduling, process management of their own.
  2. Modular — Modular simply means it can extend its capacities by dynamically loaded of their kernel and using that to work as per requirement in a more efficient manner.

Checking the kernel version

4 = Kernel Version

15 = Major version

0 = Minor Version

72 = patch release

Generic = Distro Specific Info

Kernel & User Space

The kernel is divided into two Spaces for performing any functions.

  1. Kernel Space
  2. User Space

Kernel Space is the space where all the kernel code executes along with all the kernel extensions with the help of the device drivers that act as a mediator between them. This kernel space is unrestricted with the hardware management uses as the CPU as such it is restricted with

Kernel Code

Kernel Extensions

Device Drivers

Think this kernel space is the private space where the librarian manages all the records to handle all the tasks.

UserSpace

It is the space where all the processes or the applications perform their actions. All the Linux kernel comes pre-build with a user space in any of the programming languages Like C, java, python, Ruby, docker containers and this comes with a GUI. In order to perform certain operations, user space is meant to send a request to the kernel space in the form of a system call. These system calls started from the user space pass through the kernel spaces executers all the actions that are needed to perform then it goes to the hardware and finally the action has been performed. System calls are done in order to open a file, write to a file, list processes, define a variable, and much more.

SSH Commands in Linux

The SSH protocol (also referred to as Secure Shell) is a method for securing remote login from one computer to another. ssh is secure in the sense that it transfers the data in encrypted form between the host and the client. It provides several alternative options for strong authentication, and it protects the communication's security and integrity with strong encryption.

There are lots of SSH clients that are available for both commercial and free. The OpenSSH is its most widely used client. It is available for all the most used platforms such as Windows, Linux, macOS, OpenBSD, and more.

There are 3 different types in an ssh component -

  • ssh command instructs the Machine to create a reliable and encrypted secure connection with the host machine.
  • user_name is the name of that particular Linux user which is being accessed by the host machine.
  • host refers to the machine which can be a computer or a router that is being accessed. It can be an IP address or domain name.

Ssh is extensively used in Corporate networks for -

  1. Providing secure access for users & and the processes in-between.

2. File transfer

3. Remote Access & managing a network infrastructure and other mission-critical system components.

Working of SSH Protocol

The protocol works in the client-server model, which means that the connection is established by the SSH client connecting to the SSH server. The SSH client drives the connection setup process and uses public-key cryptography to verify the identity of the SSH server. After the setup phase, the SSH protocol uses strong symmetric encryption and hashing algorithms to ensure the privacy and integrity of the data that is exchanged between the client and server.

File Types in Linux

“ Everything in Linux is a file even a directory is a type of file ”

On a General Basic, Linux Files are divided into three types -

  1. Regular File
  2. Directory
  3. Special Files
  1. Regular files are those types of files that contain normal data, texts, images, and some of the configurations.
  2. The directory is a special type of file. it contains a directory and under the directory some files. example- your home dir.
  3. Special files are further divided into 5 types
  • Character Files- Character files are those types of files that help the OS to communicate with IO and it is located under the dev. example — your mouse, keyboard.
  • Block Files- We have discussed BLOCK DEVICE files in very detail. watch part-1 eg- ram, hard-disk.
  • Links- Links are the way to connect two files together

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

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

  • Socket files- socket files are special types of files that enable communication between processes.
  • Named pipes- Named files are those files that connect one process as an input of other. the flow of the data in this type of file is unidirectional. we will learn named pipes in detail, so don’t worry about it.

How to Check a File Type?

Run these Commands

Here is the File Type & Identifier Table from which you can know about the file type, just match the first letter of the output to Identifier.

File System Hierarchy

  • Home- It is the home directory where all data resides except 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 download the webserver so /opt will be the right choice
  • Bin- It is the directory where the basic Linux commands like mkdir, mv, and all those commands reside.
  • Dev- It is the directory where all the block device files and character files reside
  • 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 a USB drive
  • Var- In case you get into an error, this directory contains Logs that will help you out
  • Tmp- It is the temporary file where all the temporary data resides.
  • Mnt- let's suppose we have downloaded 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 where all the userland data resides like Firefox.

File Permissions

On the Basic of Ownership & Permissions, We Divide the Linux File System into three types-

  1. User- Owner of the file who has Created that Particular File.
  2. Group- A Group is a collection of multiple Users in which all the users are having the same permissions.
  3. Other- Neither the creator of the file nor any Group member still accesses files.

User Accounts

  • Create a user
sudo useradd testuser
  • To create a new user with its directories
sudo useradd -m -s /bin/bash testuser
  • Delete a user
sudo userdel testuser
  • Create a Group
sudo groupadd Front-end
  • Add User to Group
sudo usermod -aG section testuser
  • Delete User From a Group
sudo gpasswd -d testuser section
  • Delete a Group
sudo groupdel section

File Operations

  • Create operation: This operation is used to create a file in the file system. It is the most widely used operation performed on the file system. To create a new file of a particular type the associated application program calls the file system. This file system allocates space to the file.
  • Open operation: Once the file is created, it must be opened before performing the file processing operations. When the user wants to open a file, it provides a file name to open the particular file in the file system. It tells the operating system to invoke the open system call and passes the file name to the file system.
  • Write operation: This operation is used to write the information into a file. A system call write is issued that specifies the name of the file and the length of the data that has to be written to the file. Whenever the file length is increased by a specified value and the file pointer is repositioned after the last byte is written.
  • Read operation: This operation reads the contents from a file. A Read pointer is maintained by theOS, pointing to the position up to which the data has been read.

To Sum up

These Core Concepts will help you to use Linux & DevOps Tools more proficiently and These commands will help you to create different types of users and groups with different types of permissions. It might take a while to remember some of the basic commands, but nothing is impossible with lots of practice.

Good luck!

About The Series

This Blog is a part of The Ultimate Guide to DevOps & Cloud Course Series.

Course Code — 1.2.3

If you want to Get started with DevOps & Cloud Then make sure to check out our course on Twitter The Ultimate Guide to DevOps & Cloud.

Master DevOps with our online community and join us in the initiative of learning DevOps & Cloud in Public.

Follow the creators:

Divyam Sharma 🔥 on Twitter

Saurav Chaudhary ⚡on Twitter

If you feel we should change any of our approaches in order to make this course the Best course, please comment down with your ideas. we would love to hear that from you.

And if you feel that this energy & effort, we are putting down in this is worth every penny then please share out with other folks who are struggling to break down into Cloud-Computing World.

Best of luck With a new journey & Happy Learning From the Team :)

About The Author

Saurav Chaudhary- Saurav is an experienced Technical Content Writer. Bringing in a lot of knowledge about DevOps & Cloud, Blockchain, Web Development & Security. He strives to write pristine content about any IT-related subject.

Follow Saurav on Twitter

--

--