Linux UNIT 2 Automatting Task
Linux UNIT 2 Automatting Task
1
BSC CS TY LINUX ADMINSTRATION
1. BIOS
• BIOS stands for Basic Input/Output System. In simple terms, the BIOS loads and
executes the Master Boot Record (MBR) boot loader.
• When you first turn on your computer, the BIOS first performs some integrity checks of
the HDD or SSD.
• Then, the BIOS searches for, loads, and executes the boot loader program, which can be
found in the Master Boot Record (MBR).
• The MBR is sometimes on a USB stick or CD-ROM such as with a live installation of
Linux.
• Once the boot loader program is detected, it's then loaded into memory and the BIOS
gives control of the system to it.
2. MBR
• MBR stands for Master Boot Record, and is responsible for loading and
executing the GRUB boot loader.
• The MBR is located in the 1st sector of the bootable disk, which is
typically /dev/hda or /dev/sda depending on your hardware.
• The MBR also contains information about GRUB, or LILO in very old
systems.
• The Master Boot Record (MBR) is the information in the first sector of a
hard disk or a removable drive.
• It identifies how and where the system's operating system (OS) is located
in order to be booted (loaded) into the computer's main storage or random
access memory (RAM).
2
BSC CS TY LINUX ADMINSTRATION
3
BSC CS TY LINUX ADMINSTRATION
3. GRUB
• Sometimes called GNU GRUB, which is short for GNU Grand Unified
Bootloader, is the typical boot loader for most modern Linux systems.
• The GRUB splash screen is often the first thing you see when you boot your
computer.
• It has a simple menu where you can select some options.
• If you have multiple kernel images installed, you can use your keyboard to select
the one you want your system to boot with.
• By default, the latest kernel image is selected.
• The splash screen will wait a few seconds for you to select and option.
• If you don't, it will load the default kernel image.
• In many systems you can find the GRUB configuration file at
/boot/grub/grub.conf or /etc/grub.conf.
4. Kernel
• The kernel is often referred to as the core of any operating system, Linux
included. It has complete control over everything in your system.
• In this stage of the boot process, the kernel that was selected by GRUB first
mounts the root file system that's specified in the grub.conf file.
• Then it executes the /sbin/init program, which is always the first program to be
executed. You can confirm this with its process/program id (PID), which should
always be 1.
• The kernel then establishes a temporary root file system using Initial RAM Disk
until the real file system is mounted.
4
BSC CS TY LINUX ADMINSTRATION
5. Init
5
BSC CS TY LINUX ADMINSTRATION
6. Runlevel programs
• Depending on which Linux distribution you have installed, you may be able to
see different services getting started.
• These are known as runlevel programs, and are executed from different
directories depending on your run level.
• Each of the 6 runlevels described above has its own directory:
6
BSC CS TY LINUX ADMINSTRATION
• The sysinit.target starts up all of the low-level services and units required for the
system to be marginally functional and that are required to enable moving on to the
basic.target
• After the sysinit.target is fulfilled, systemd next starts the basic.target, starting all
of the units required to fulfil it.
• The basic target provides some additional functionality by starting units that are
required for the next target.
• Finally, the user-level targets, multiuser.target or graphical.target can be
initialized.
7
BSC CS TY LINUX ADMINSTRATION
• The chkconfig tool is used in RedHat based systems (like CentOS) to control
what services are started at which runlevels.
• Running the command chkconfig –list will display a list of services whether they
are enabled or disabled for each runlevel.
8
BSC CS TY LINUX ADMINSTRATION
• Single User mode is a mode that a multi-user system (like a Linux server) can
be booted into the operating system as a superuser.
• Booting a system into this mode does not start networking, but can be used to
make changes to any configuration files on the server.
• One of the most common usages for single-user mode is to change the root
password for a server on which the current password is unknown.
• Runlevels are an important part of the core of the Linux operating system.
init
• It is the first process executed by the kernel during the booting of a system.
• It is a daemon process which runs till the system is shutdown. That is why, it is
the parent of all the processes.
• First of all, init reads the script stored in the file /etc/inittab.
• Command init reads the initial configuration script which basically take care of
everything that a system do at the time of system initialization like setting the
clock and so on.
• By reading this file, init determines how the system should be set up in each
runlevel and sets default run level.
• After determining default runlevel for the system, init starts all background
processes required to run the system.
• First it runs each of the kill script (their file name starts with a K) with a stop
parameter.
• Then it runs all start scripts (their file name starts with an S) to start all services
and applications.
9
BSC CS TY LINUX ADMINSTRATION
• The chkconfig is an effective, text based command line tool,which can be used
to display, diagnose, or change the starting & stopping of system services
available under /etc/rc.d/init.d in each runlevel.
Example: To list all services installed use the following command
10
BSC CS TY LINUX ADMINSTRATION
• Using --list with the chkconfig command displays the status of all available
services in all runlevels.
List All Enabled Services
• To find all enabled services (in one or multiple runlevels), execute combine
chkconfig --list with the grep command:
chkconfig --list | grep on
11
BSC CS TY LINUX ADMINSTRATION
• start the ntpd service on the third runlevel and verify the service’s configuration
with:
• chkconfig --level 3 ntpd on chkconfig --list ntpd
• If the user would like to configure other runlevels, those levels can be specified
on the command line by listing the levels after --level, without any spaces.
12
BSC CS TY LINUX ADMINSTRATION
3) Using system-config-srvices
• Linux provides its own service Configuration tool for the control and
administration of services.
• We can access this tool from the GUI System Settings, and then select Services
option, or with command-line using system-config-services command.
• The "Service Configuration" dialog is available from the menu
(System > Administration > Services) or directly from the command line by
running the system-config-services command.
• The "Enable" and "Disable" buttons are used to toggle the auto-start on reboot
for each service. The "Start", "Stop" and "Restart" buttons affect the current
state of the service.
13
BSC CS TY LINUX ADMINSTRATION
14
BSC CS TY LINUX ADMINSTRATION
15
BSC CS TY LINUX ADMINSTRATION
6. Scheduling Tasks :
1. at 5 pm
2. warning: commands will be executed using /bin/sh
3. at> echo “hello”
4. at> ^d
the example above, we scheduled a job for 5 PM, which opens the interactive
prompt.
The scheduled job is to execute the echo command.
Use the cat command to check if the file exists to make sure the job was executed:
cat example.txt
17
BSC CS TY LINUX ADMINSTRATION
18
BSC CS TY LINUX ADMINSTRATION
Cron job :
What is crontab?
Cron is named after Greek word “Chronos” that is used for time.
It is a system process that will automatically perform tasks as per the specific
schedule.
It is a set of commands that are used for running regular scheduling tasks.
Crontab stands for “cron table”.
It allows to use job scheduler, which is known as cron to execute tasks.
Crontab is also the name of the program, which is used to edit that schedule. It
is driven by a crontab file, a config file that indicates shell commands to run
periodically for the specific schedule.
In this Operating system tutorial, you will learn:
Crontab syntax:
[Minute] [hour]
[Day_of_the_Month]
[Month_of_the_Year]
[Day_of_the_Week]
[command]
20
BSC CS TY LINUX ADMINSTRATION
21