Published on

👨‍💻Linux Essentials A Crash Course for New Users🎯 Part-2

Authors

Boot Processes :-

Booting is a startup sequence that starts the operating system of a computer when it is turned on.

STEP 1: BIOS (Basic Input-Output System)

BIOS (basic input/output system) is the program a personal computer's microprocessor uses to get the computer system started after you turn it on. It also manages data flow between the computer's operating system and attached devices such as the hard disk, video adapter, keyboard, mouse and printer.

STEP 2: MBR (Master Boot Record)

The Master Boot Record (MBR) is the information in the first sector of any hard disk or diskette that identifies how and where an operating system is located so that it can be boot (loaded) into the computer's main storage or random access memory.

STEP 3: GRUB (Grand Unified Boot Loader)

Basically, GRUB bootloader is the software that loads the Linux kernel. (It has other uses as well). It is the first software that starts at a system boot. When the computer starts, BIOS first run a Power-on self-test (POST) to check hardware like memory, disk drives and that it works properly.

STEP 4: KERNEL

Kernel is the core part of Linux. It is responsible for all major activities of this operating system. It consists of various modules and it interacts directly with the underlying hardware. Kernel provides the required abstraction to hide low level hardware details to system or application programs.

STEP 5: INIT

Init is the parent of all Linux processes. It is the first process to start when a computer boots up, and it runs until the system shuts down. It is the ancestor of all other processes. Its primary role is to create processes from a script stored in the file /etc/init.d .

STEP 6 : RUNLEVEL

Run-levelsUse
init 0Shutdown
init 1Single user mode
init 2Multi-tasking without network without GUI
init 3Multi-tasking with network without GUI
init 4Reserved
init 5Multi-tasking with network with GUI
init 6Restart

Thus , this complete booting process takes place when the Computer system is TURNED ON till the operation mode/UI .

Types of Process States in Linux :-

  • Running(R): This is a state where a process is either in running or ready to run.

  • Interruptible(D): This state is a blocked state of a process which awaits for an event or a signal from another process

  • Uninterruptible(S): It is also a blocked state. The process is forced to halt for certain condition that a hardware status is waited and a signal could not be handled.

  • Stopped(T): Once the process is completed, this state occurs. This process can be restarted

  • Zombie(Z): In this state, the process will be terminated and the information will still be available in the process table.

What is a File systems and its types ??

Filesystem is the way in which files are named and where they are placed logically for storage and retrieval.

Types of File system are :-

Ext2

  • Ext2 stands for second extended file system.
  • This was developed to overcome the limitation of the original ext file system.
  • Ext2 does not have journaling feature.
  • On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do the over head of journaling.
  • Maximum individual file size can be from 16 GB to 2 TB
  • Overall ext2 file system size can be from 2 TB to 32 TB

Ext3

  • Ext3 stands for third extended file system.
  • The main benefit of ext3 is that it allows journaling.
  • Journaling has a dedicated area in the file system, where all the changes are tracked. When the system crashes, the possibility of file system corruption is less because of journaling.
  • Maximum individual file size can be from 16 GB to 2 TB
  • Overall ext3 file system size can be from 2 TB to 32 TB
  • You can convert a ext2 file system to ext3 file system directly (without backup/restore).

Ext4

  • Ext4 stands for fourth extended file system.
  • Supports huge individual file size and overall file system size.
  • Maximum individual file size can be from 16 GB to 16 TB
  • Several other new features are introduced in ext4: multiblock allocation, delayed allocation, journal checksum. fast fsck, etc.
  • All you need to know is that these new features have improved the performance and reliability of the filesystem when compared to ext3.
  • In ext4, you also have the option of turning the journaling feature “off”.

XFS

  • XFS is a high-performance file system which was designed by SGI for their IRIX platform. Since XFS was ported to the Linux kernel in 2001, XFS has remained a preferred choice for many enterprise systems especially with massive amount of data, due to its high performance, architectural scalability and robustness.

File Hierarchy :-

  • /bin: Where Linux core commands reside like ls, mv.
  • /boot: Where boot loader and boot files are located.
  • /dev: Where all physical drives are mounted like USBs DVDs.
  • /etc: Contains configurations for the installed packages.
  • /home: Where every user will have a personal folder to put his folders with his name like /home/like geeks.
  • /lib: Where the libraries of the installed packages located since libraries shared among all packages unlike windows, you may find duplicates in different folders.
  • /media: Here is the external devices like DVDs and USB sticks are mounted and you can access their files from here. /mnt: Where you mount other things Network locations and some distros you may find your mounted USB or DVD.
  • /opt: Some optional packages are located here and this is managed by the package manager.
  • /proc: Because everything on Linux is a file, this folder for processes running on the system, and you can access them and see much info about the current processes.
  • /root: The home folder for the root user.
  • /sbin: Like /bin, but binaries here are for root user only.
  • /tmp: Contains the temporary files.
  • /usr: Where the utilities and files shared between users on Linux.
  • /var: Contains system logs and other variable data.

Hard Link :
A hard link acts as a copy (mirrored) of the selected file. It accesses the data available in the original file.
If the earlier selected file is deleted, the hard link to the file will still contain the data of that file.

Soft Link :
A soft link (also known as Symbolic link) acts as a pointer or a reference to the file name. It does not access the data available in the original file. If the earlier file is deleted, the soft link will be pointing to a file that does not exist anymore.

Soft link

  • syntax : $ ln -s "link file name" "main file"

Hard link

  • syntax : $ ln "link file name" "main file"

###CRONTAB: Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times. crontab if your name does not appear in the file /usr/lib/cron/cron.deny. If only cron.deny exists and is empty, all users can use crontab.

The crontab is a list of commands that you want to run on a regular schedule, and also the name of the command used to manage that list.

Example:

  • To edit the jobs: crontab –e

  • To list the scheduled jobs: crontab –l

  • To see particular user jobs: crontab –c –u <user name>

  • To remove crontab file: crontab –r

crontab format

Load Monitroing and Analysis

  1. top PID: A process’s process ID number.
  • USER: The process’s owner.
  • PR: The process’s priority. The lower the number, the higher the priority.
  • NI: The nice value of the process, which affects its priority. The Linux niceness scale goes from -20 to 19. The lower the number the more priority that task gets. If the niceness value is high number like 19 the task will be set to the lowest priority and the CPU will process it whenever it gets a chance. The default nice value is zero.
  • VIRT: How much virtual memory the process is using.
  • RES: How much physical RAM the process is using, measured in kilobytes.
  • SHR: How much shared memory the process is using.
  • S: The current status of the process (zombied, sleeping, running, uninterruptedly sleeping, or traced).
  • %CPU: The percentage of the processor time used by the process.
  • %MEM: The percentage of physical RAM used by the process.
  • TIME+: How much processor time the process has used.
  • COMMAND: The name of the command that started the process.
  1. htop - gives us dynamic output

  2. uptime - it gives amount of time system is in running state, number of users currently logged into, and the load time for the past 1, 5 and 15 minutes respectively.

  3. vmstat In the above output, under the CPU column, “us” means resources used by the user, “sy” means resources used by the system, and “id” means the percentage of idle resources. You can also run vmstat in a specific interval of time to see the loads in real-time.
    vmstat 2 5 This command will call vmstat 5 times with an interval of 2 seconds between each call.