Linux Training for Beginners | Linux Tutorial For Beginners | Intellipaat

Linux Training for Beginners | Linux Tutorial For Beginners | Intellipaat


Hey guys, welcome to this session on
Linux by Intellipaat. So, Linux is like air; you don’t see it or know it ever exists,
yet it makes your devices extremely powerful. From your Android smartphones,
to all the apps you will have in it, to air traffic control stations, and even the
Large Hadron Collider, everything runs on Linux. So, keeping in mind how powerful it
is, we have come up with a comprehensive tutorial on Linux. So, before we start, do
like this video and subscribe to our channel so that you never miss out on
any of the upcoming videos. So, let’s go through the agenda. We would start off by
learning how to install Linux, then we’d be learning how to install virtual
machine, thereafter you’d be learning the basics of VM, then we’d be discussing how
to set up the kernel and manage system services in Linux, and finally there
would be a quiz to recap whatever you have learnt today. So, put down your
answers in the chat box to know if you have answered correctly. Also, you can put
down all your queries in the comment box. We’d love to help you out. So, without any
further delay, let’s start with the session. Before we get started to the
Linux installation, we will first know how to set up the virtual machine and
then once the virtual machine is set up, we’ll follow the steps to download the
media. Then see how to boot the media and then start the installation wizard. So,
first of all, let’s see how we can install the virtual machine. You might be
using Windows as the operating system, I am using Mac, but the steps are the same,
no matter. So first of all, let’s download the virtual machine. Let’s go onto a
browser and then see how it works, like how we can install the virtual machine
software first. So, we are using the virtual machine called Oracle
VirtualBox. This is an open-source virtual machine, so you can directly go to
the download section. From there, we have various virtual box versions such as OS X, Linux, and Solaris. So, if you are using Windows,
you can click on this and download the VirtualBox, and there would be a binary
file, the installer. If you double click on it, the installation will be done for
your system. Just accept the default options, and don’t make any changes and it
would be installed for you. You will get icon on your Start menu or on your
desktop. So, this is the option. Go to the virtualbox.org, and
then you need to download this, so then you are done. Install whatever
installer you have downloaded and download the correct version based on
the operating system you are using. So what does this mean? No matter
whether you use Windows or Mac or Linux or Solaris, you can install a virtual
machine and inside it you will install the Linux which we are going to do today.
So, this is one path and if you have a spare bare metal system, spare desktop
where you want to try to install Linux, then you will not need to do these
steps. This is only for those who want to try it in a virtual machine. First
of all, we have downloaded this and I have installed it also. So once the
installation is done, I get this icon, the VirtualBox icon on my system. You might
get it on your desktop. So, this is the Oracle VirtualBox manager. These are the
various virtual machines I have created to try out various labs, so that doesn’t
matter. We will create a new one so that you can see from the beginning. So,
first of all, we open the virtual machine VirtualBox manager. When does this come
up? After installing the binary which we downloaded and installed, ok. So you click
on the ‘new.’ So, it asks for the name and the operating system. So, let’s name it LInux-Installation-Lab. So once this is
up, then we can install the Linux on it. The second is the type. Here, you
can mention what kind of Linux you are going to install. So, these are the various
types of operating systems. So, we are using Linux. The type of Linux you are using, you can choose this one. This is actually the kernel version.
Nowadays, all kernels have 3.0 or 4.0 options, 2.6 is passed now, but still
if you want to be more specific on the version, and there are various
flavors of Linux here, we are going to install CentOS, but as I said, CentOS is a
clone of Red Hat, that means, we are installing Red Hat. CentOS option is not
there, so we can choose Red Hat 64-bit. So this is done. If you do continue, it
will ask that the virtual machine you are going to make, how much RAM would it
allocate to that virtual machine. So, let’s make it, say 2 GB. I’ll give it 2 GB RAM, but remember you can give anything from 256 MB to whatever value
you want on the upper end, but to be on the safe side to have things running
pretty fast, you have to allocate at least 1 GB RAM. So, I am giving it 2
GB because I have enough RAM on my laptop.
I have setup the RAM, the memory, and then we have to create a hard disk to install
Linux. So, create a virtual hard disk now. So, I’ll create a new one, then it asks
for the format VDI is the default format for the VirtualBox. So, let’s keep it at
that and then continue. Then we are asked that whether the
hard disk size would be dynamically allocated or it would be a fixed size.
What does this mean? This means you can set up a hard disk with, say 15 GB of
size, but it will not allocate the entire space immediately. Once the hard disk
gets used and slowly its space increases that it would expand with the
upper limit of 15 GB. It would not cross that limit. So, that is quite convenient.
Otherwise, if we give a fixed size, it straight away takes 15 GB from
your laptop or system’s hard disk and then it just reserves it, and we don’t
need that. So we just need dynamically allocated because it is for just this
lab that we are going to use this virtual machine. Then we
get Linux installation lab. This is the system name. Here, it is asking
that what should be the virtual hard disk size, so as I told, I want 15 gigs, so
I write this. Then I ask it to create the virtual machine and it’s done. So this is
the Linux installation lab, the virtual machine we are talking about. We want to
install CentOS 7 Linux over here. So now what do we do? We have to do certain
changes like we have to first set up a network for that. So in the network
section, there are various options but you will get to know all the details of
these options when you do the video on virtual machines. We have a separate section for that, but for now, you just remember that
you can choose NAT as well, host only, or you can use bridged. Bridged suits most
for me because I use a broadband router. So the Wi-Fi router is directly
connected via bridged adapter. You can also use that. Bridged helps you
to connect to the outer Internet as well as your own LAN. So you can
choose this option and then it saves the option that it’s a bridged
adapter. So how is this panel similar to a bare metal. In bare
metal we manually have a network adapter, we have a storage adapter, hard-disk, but
here you can just click on the storage and see that this is the hard disk 15 GB
size. You can add more hard disks here. So these are the kind of options. We will do
that in a session dedicated to the virtual machine. So now let’s first
of all see where we can enter the CentOS installation CD. In
a bare metal system when you want to install something, you have to take the
installation CD or DVD for that operating system and insert it into the
CD tray or DVD tray and then boot the system from the CD by
setting it in the BIOS. Similarly, in this virtual machine, we have to enter the ISO
file and map it to the CD-ROM drive or DVD ROM Drive. So, in order to do that, first of all, we need the installation media, like we have
said here, first thing we have to do before installing Linux is downloading
the media, and if we are using the bare metal, you have to write the media
to a DVD and if you are using a virtual machine, you just have to map the .iso
file to the DVD ROM interface in the VirtualBox and then we have to boot it.
So let’s do the first step now. For that, we have to again go back
to the Internet and then from here we can go and get the
installation media. So what we want to install? We want CentOS 7 download.
So here it comes the CentOS page. So once we open this, we
see that there are three options available. DVD ISO, everything ISO, and Minimal ISO. So the DVD ISO is pretty much which has most of the things we need. It has
the command line installation option, it has the graphical installation option, it
allows you to give install server based operating system. So in the same CD,
you have multiple options like which kind of version of centers you
want to use. if you want to install a server you have the option to choose it
during the installation process. If you want to install a desktop with GUI, so
that also you can do, and you can even install a command line or a minimal
install. Everything ISO, it’s around 7.5 gigs in size. DVD ISO is around 4.5 gigs, and Minimal is very small, it’s around 700 MB
or even less. So inside this you get everything hat is applicable
to a particular CentOS Linux version. What is the difference
between these two? This has a pretty much set of packages which are
normally required. So, it’s kind of a standard package, and Everything ISO has
everything in it. If you want to create a repository with all the RPMs for CentOS
7 Linux, you will get all the RPM packages in this ISO. So not needed
for us right now. We want to do a simple installation in the command line as well
as the GUI mode, and we want to know how it works and then we can move on to
Everything. Even you can download and try this. Installation process is the same.
If you do Minimal, then you don’t get to see all the aspects of the
installation but minimal is important if you are running a server and you don’t
want to run unnecessary services on that
server. So, in that case, you use the Minimal ISO. So that just installs a
graphical mode and you have to then do post-installation and install whatever
you want to add to it. So, it does just runs a base operating system with the
minimum commands that are required that the system cannot do without, and it
just provides a command-line interface. So it is a minimalist operating system,
takes a very low consumption of resource, and but that is for experts,
those who know what they are doing and what they are installing. So first of all,
we begin with downloading this DVD ISO because that would allow us to
install everything and see all the options that are available. So, that would
be very good learning curve for us. So you need to download this. I have already
downloaded this ISO to save time and kept it in one of the
locations in my hard disk. So, I’ll show you how to browse that. So,
here it’s empty, our cd/dvd controller. So this is similar
to the tray which we use in bare metal. Now we have to map the optical disk file
ISO. So here I have downloaded and kept the ISO. So, if you download it you
can also choose the virtual disk file and you can browse it wherever you have
kept it you can browse and then you can install it. So I have already
browsed and kept it available in this list. So this is that DVD file which we
were talking about. This one.
So, this file is this one DVD ISO. We choose this so it shows the location
where the DVD file is kept and then this this file is mapped so let’s click on OK
so that file is mapped here now we boot this system like in bare-metal we press
the power button the system starts booting up similarly here you just need
to right-click and click on start normal start so let’s enlarge this screen and
we can go on with the installation so what do we see here we see three options
install sent to s7 this is booting from the ISO so this boot screen first and
torez comes up first and there are three options installed test media
troubleshooting we don’t need troubleshooting right now this is when
the system gets corrupted or you have to rescue it from some failures you can use
the CD and there is various options to rescue we can do this part on a future
lab once you’re done with understanding what Linux is and how you need to
troubleshoot that we’ll come to this part then we have this one to test the
media if your CD drive or DVD is corrupted or you feel there is some
problem with the drive you can test it and it will give you a report on whether
some files are missing or corrupted so that you can get a fresh one so this is
it and then this one is the installation since we are using the ISO file we don’t
need to do this right now we have downloaded it correctly and so we go
straight away to the installation part and you just okay let me tell you
important thing while navigating around this list I am using the arrow keys to
go up and down so you give the upper arrow key and go to the installs into s7
and then press ENTER so that takes you to the installation screen so while the
installation screen is being loaded let me tell you what happens behind it
what happens is it unpacks the various packages from the DVD and loads it into
a temporary location on the system’s memory and then from there the
installations installer starts running this installer for linux is written in a
language called Python and it has the graphical user interface as well as CLI
normally we use the GUI and this is what we can see it is a the installer has
kicked off and its first starting us that you know what language we want to
use for the installation process so the default is English and we’ll leave it at
that you can use other languages as well most languages of the world are given
here ok so we have this English selected here and English keyboard version the
u.s. keyboard which we are using this is default so let’s continue so these two
options are set and now it gives us a very important screen here we have a
lots of option to set up before we can start with the installation so the first
thing was already done the localization part date and time we need to do this
this one this one was done the keyboard English us in the last step this one was
done a language support for the date and time if we click on this it asks you to
click on a location where you are located I mean you are situated we are
in India so let’s click here you can choose anywhere in the world you are you
can choose your US New York City and you can choose anywhere ok any state you are
in so let’s choose let’s choose India and then we can chew
at the time comes up automatically you can even set it right here and
and you can also set the kind of pattern you want to see the time on the system
a.m. p.m. 24-hour so whatever kind of day a time you are comfortable with you
can choose that and then you can choose the date as well and what I do is I
choose the set this network time to on normally this helps you in servers okay
so once you were pressed on on this network time what happens it configures
itself to a protocol called the NTP head for time protocol so that protocol what
it does it it has a server around the world there are various NTP servers and
this protocol has a database by with which it connects to those servers and
syncs time so if your server is down for a few days and you have NTP installed in
it once you switch it on it will think it’s time and gets get itself updated so
that is how it helps these kind of servers to to manage time for them okay
so this is what we do here and since we are doing a normal installation we don’t
need to do any other changes here so done so once that is done then we get
back to the get back to the installation summary screen again and here we have a
security policy here what happens if you can apply the security policy on or off
we have applied on and we choose the default profile so you can do that and
you can select that profile so that default profile would be selected but it
has no rules for the pre installation phase what is it actually while
installation or post installation say we want to apply certain firewall certain
rules to block certain networks of ports we
have an option to choose it during installation but nevertheless you do it
this is not mandatory you don’t need to do this thing
why because it is always convenient to get the system installed first and then
you can install security policies firewalls later on so we will do that
when we come to the exercise on security and firewalls so here it is not a
mandatory step okay and so you you will learn all these options and their
meanings at that stage now you just go with the default right so security
policy is fine so software what does it say it says that what is the local media
you are using and from where you are getting the software to install so here
we have chosen the sent to a 7 DVD so it’s showing that one is mapped here so
we don’t have to do anything else here if people who install over the network
they have an option to give it here and get the installation running but this is
all disabled here why because we have already chosen a media and we have
started the installation from there and then the software selection this is very
important and this is very important these two options after selection and
installation destination software selection this is an important screen
why because this allows you to choose which kind of more do you want to choose
for the installation so as I said we have options like minimal install which
installs only the graphical interface I mean only a sorry the only the text
interface so minimal install gives you CLI only so what does it do it allows
you simple environment which is minimalist and you can only run a few
commands on it it would take very low resources and if you are good enough
and you if you are confident enough in Linux you can install this go into the
command line and then install the package which you need say you want to
prepare a webserver so you need only the Apache packets so you can install a
minimal version of server and then go on and install the Apache only so that
takes very low resources there are no unnecessary services on the server and
it’s very clean and bare minimum so this is basically used for server
environments where you don’t want anything extra you just want to run what
you want so this is a very good option but now since we are going to learn
Linux we have to know I almost everything that is available in Linux so
we will go with we will not go with this installation we will go with an option
which allows it to us to install most of the things compute nor this is for those
who are installing Linux on a cloud so it provides those tools which would be
necessary in the cloud as well as provide a minimal install so this is a
mixture of minimal and some tools for the cloud so what are those tools these
are on the right side add-ons you can add suppose they are going to install a
java-based application on the cloud so they are going to choose compute node
and then they would click this so this team who wants to use a java application
or linux they would and want to deploy it on the cloud they would choose
compute node development tools it would comprise the development environment for
most of the languages so that would help them so this is how it is done you can
choose various options like remote management that would be needed for the
cloud because they want to they would want to connect to their server from
outside so they would need the tools to do that so things like that so this is
how it is done let me uncheck this we are not going for this option also
infrastructure server the a piece installation if someone wants to
build a infrastructure comprising of multiple servers so he can choose this
option this allows to integrate with other servers I mean if you have say a
cluster which has 4 servers all of them are database servers who sync each other
so you need to have those tools which comprise of this the support to form an
infrastructure so this is needed similarly the infrastructure would also
add have a set of add-ons whatever is needed that can be chosen here you will
get to know every detail of what FTP is what file storage is what Hardware
monitoring utilities are everything once you get more acquainted with Linux but
for now just know that this is an infrastructure server when you’re
building clusters or multi server farms then you might use this option but in
Linux the beauty is you can choose any of these and get to work whatever you
like so most of the cases what I do is I go for a minimal install so that
installs a bare minimum base Linux and then I install those packages which I
need so that that way that way it helps me to segregate things and keep things
very uniform and very resource sensitive so whatever I need I install just that
and not everything so this is what we will learn and this is what our
philosophy will be so next there are options of file and print servers if
someone is using a server to just install a repository where he keeps his
files and from there he sends it to the printing since it for printing to a
printer print server so this server can manage multiple printers and files it
sources files and then sends it to the printer so if you want to choose that
then you can use this is a basic web server which has a
minimal install with Apache installed on it and you can install other options
like I said if you want to backup for the web server you can install this you
can install a Java platform if your website is Java Tomcat Apache Tomcat so
you would need Java for that if you have multiple of these web servers and you
want to load balance between them you can use the load balancer ad on selected
and then it would install it you just have to go in and configure it later so
these are various options virtualization hosts like if you want to run multiple
operating system or virtual machines on your de Linux installation then this is
the best option it would enable all the software’s that are needed for creating
a virtualization layer so like this we have then we have this option it put
this is the best option for learning why because it provides you a server
infrastructure and also gives you a GUI the graphical user interface so you if
you do initially when you feel uncomfortable with the command line you
can do some things with the GUI also as well as try hands at command line
because in Linux command line is the most important thing to learn why
because it makes things faster and really effective when you manage so a
good system administrator in Linux should be very good in command line
hands-on so this is the option we are going to use to install our system but
before that let me go through the entire list so that you get to know genome
desktop if you want to install this you would not get the option for the server
my you would just have a working desktop installation okay so this is for users
who just want to use a Linux desktop just like they are using a Windows
desktop okay so genome desktop and then KDE this
is also a graphical format and that desktop is also similar to the
previous genome desktop option but the graphics are a bit different and more
stylish than this one this is my observation and then development and
creative workstation like this is for the designers and developers like people
who code who do some graphical applications and as this is for them so
next we move on to the installation part by choosing the server with GUI so and
in this side we would not choose any package because we don’t want to install
this beforehand we want to do the installation after getting the base
operating system installed so that you can see each and every installation
which we want to do so let’s go with this and click on done so that is saved
it is checking the dependencies where that would be needed to install the
server dependencies means those software’s which are needed for enabling
the GUI and the server version of Linux so everything is linked now from this
installation source to here so if you choose those files and install it now
the once it installs where does it go we all know when we install Linux or any
other operating system it goes to the hard disk but we need to tell it where
it will keep okay so we choose this and here we have this 15 GB hard disk which
we created while creating the virtual machine so that is it it’s already
selected here that means it will use that hard disk if we have multiple hard
disk we can click here and check or uncheck the hardest which we want to use
and even if we want to attach a hard disk
well the installation begins before the installation begins we can do it and add
it here ok and here there are two options I will configure partitioning or
automatically configure auditioning if I do this the system will
partition the hard-disk on its own and then install the software if I do this
and click on done it will take me to a screen where it will ask you ask me to
create the partitions so today since we are doing an initial installation we
will choose this because the system will select it then we have a separate
session on file systems that day I’ll first tell you what are the various
partitions in Linux because we cannot straight away go ahead choose this and
then you don’t know what each partition means to Linux and why we should do that
and it would not work that way so let’s install a basic Linux go inside it know
what partitions are in separate session in this series and then the day we know
what the partition means then we have another installation exercise in in this
series of courses and there we will do this partitioning the the one which you
have to do yourself so here we choose the automatic one this is pretty robust
enough to help us install this Linux version so we’ll go with this automatic
one I would like to make additional space available this option is not
needed okay this is for provisioning some extra space to the server so we
have just 15 GB one hardest so we don’t have this option and encrypt my data
if you won’t want to encrypt whatever you keep in your server you have to
choose this this is good for security people who would happen to take files
from this server would not be able to decrypt it because they would need some
key files to decrypt so it is good security option but but I would not
recommend it right now because it makes things slower and
not recommended at this point of time so we click on done so now it’s saving the
partitioning scheme which automatically was created by the Linux server so if
you choose this you will get a running Linux system so no problem with that
kdump kdump is enabled we don’t have to do anything here we can just disable it
if we want but let it be enabled what is it it is a log sort of thing it
would love whatever we are doing well installation so that in case the
installation fails it takes the dump from the kernel and shows us what you
know what went wrong and why why it went wrong so it logs everything and if the
installation fails the failure screen shows us that dump and then we go to the
network and hostname section here we can set up the network the internet that we
created like you might remember I created a bridged Network so here we can
turn it on so once we turn it on we get the ethernet connected it’s showing
connecting so now it’s connected and it got IP address as well where did this
get it from I have a router here in my lab so we got a DHCP IP from that router
in case you don’t have a broadband router then you can go to configure and
then you can go to ipv4 settings you can choose manual and then click on add here
you can write an IP address 192 168 dot 0 dot 100 say netmask 2
fifty-five to 255 255 dot zero classy and then we can give a gateway like one
sixty eight dot 0.25 for this is gateway for my router so I’m putting it you have
to put it for your router and in case you don’t have a router you are doing
everything offline you can leave this black okay
because anyways you won’t be connected to the internet if you’re doing it
online you want to keep the virtual machine online then you have to specify
your routers IP so this is it and you need to save it okay because but I am
cancelling this one because I have IP from the DHCP so I won’t need to
configure the IP right so let me fall back to DHCP save it I have my IP back
so this is it in network if you have more network cards you can add it here
and do stuff another important thing is thinking you have to do here is setting
the hostname for the system like we have the host name Linux install doc lab so
our systems name is Linux install and domain name is lab so you can name
pretty much anything and then click on done that option is saved the internet
is connected and now we begin installation so it is preparing the
installation then setting up the environment once this is done it would
create the hard disk partitions like we selected of automatic partitions and
then sets of the file system like in Windows we have e X we have the fat32 or
NTFS file system similarly in Linux we have the XML file system or the ext3 or
ext4 here we have the automatic partitioning system uses x FS so that is
setup and it starts the package installation
process okay and meanwhile we have two more options to set and these are the
last options after that we don’t have to touch the Installer it would just get
installed okay so we do these options click on the root password so what is
root in Linux root is same as the administrator account in Windows
so root is used for administering the system and we can do pretty much
anything in Linux using the root account so we must be very careful with this
account and we should remember the password we set here so I am giving a
simple password Red Hat so let me type it twice for confirmation it shows that
the password is weak but good enough for now because we are just doing a lab
exercise but if you are on a real server it is mandatory that you do a complex
password here mixing up symbols numbers and words so you set the password here
you click done so it again asks for a confirmation because you need need to
confirm it twice so I click again and it set root password is set now it’s asking
for user creation no user will be created so what does it means if you
don’t do anything no user would be created but if we set a user user one
and the password same let’s put it Red Hat then what happens
it sets the password same two clicks to save it so the user one will be created
root password this set so both these operations are done from outside now we
don’t have to do anything we just have to wait until the installation is
complete so it’s just now at 3:56 out of 1236 packages so you just have to wait
until the entire packages are installed and then
ask you for a reboot so what happens now is it will take some time around half an
hour for my system and if you have a faster system it would take lesser time
so in order to minimize time what I have done is I have created another server
where I have crossed these steps and then come to a position where the
packages are installed so we can continue from there okay
so let’s go to the virtual machine manager and then see and then start that
system which was already installed this system was already installed and at the
stage where the installation is complete and I have saved it so I’ll go and
resume it so let’s see what happens here the root password was set and the user
creation was also done and the installation was in progress like the
one where we were doing it so this is the stage you would reach once you are
done with that okay so once the installation is completed it would show
this complete Centaurs are successfully installed and ready for you to use go
ahead and reboot to start using it okay so we do the reboot so the system is
rebooted and it will come up in a short while meanwhile let’s go through our
presentation and see what we have already covered we have done the
downloading media this we have done we have booted the media in the virtual
machine then we have done the installation wizard a kick off then we
have set up the language here and then the keyboard were
and then we did all these steps for setting up the installation destination
and then we chose the hard-disk this part was the manually partitioning
which we didn’t do we did it in the automatic partitioning we’ll do the
manual one in another video of the series and then we chose the date and
time and then we have this option the setting the root password and the user
creation after that we had that installation going on and then it was
completed and we have the boot up screen so we had to reboot the system so next
what we need to do is the post installation tasks navigating the system
knowing there are levels and running some basic commands so these are a few
things which we are left so let’s carry on and do that okay so the system from
here it’s giving us the post installation screen initial setup of
CentOS 7 core please make your choice from this one and continue so what is
the choice the license information license not accepted so I want to
continue I want to accept the license so it’s asking me read the license
agreement accept the license agreement so this option is to I want to accept it
so I press 2 then what what it asks please make your choice C to continue
how artifice so I do C then it asks the license has been accepted and we have to
continue so that is done so now the system will boot up ok and we created a
user Tom for the other system so it’s showing up here so if we click on it it
will ask for the password for this user had set it to Red Hat so it would
give me a desktop screen okay so it takes some time for the first
initialization of the desktop screen now here the desktop is up so this is the
center and seven graphical user interface desktop so initial there is
some other option that you may want to use so it’s asking for this kind of
English which we want to set it’s us so then we click Next it’s asking to
create some online accounts which I skip and then yeah using center is now so
it’s going to the getting started screen for helping you out with genome desktop
so we don’t need that you can yourself navigate and see what is around and this
is the graphical user interface in Linux we also have a command-line interface
and you can go to the command line for the system by opening the terminal
before that let me first show you what are options available here there are two
menus applications and places pretty simple so in places you can go to
various directories you could go to the home directory like you have my
documents in Windows it’s the home here in Plymouth so you had you can see
various files and folders here and then you have the documents nothing inside so
these are all folders where you can keep stuff this is the recycle bin the trash
then this is the entire hard disk and the various file systems are installed
in here the entire file system hierarchy and if you go to the applications you
can see other options like internet from here you can open the browser and see
you are connected to the Internet or not graphics you have some
options like LibreOffice draw lay similar to paint in Windows and stuff
like that if you install more spec eases it would show up here so this is it and
important option this one you go to system tools and settings this option
you can also go through here you can go to this corner here you have
the option to shutdown the system and hibernate or shutdown a love of and here
this is to lock the system if you are away for a short while and this option
is for going to the system tools from here you can create more users this tech
tom is there you want to add users you click here you have other options over
there like apart from creating users you can change background of the desktop you
can add notification settings you can save online accounts privacy security
options regional and language settings anything like you want to change the
display the resolution everything can be done from the settings option so this is
how we navigate the system how we install the system hope you understood
how we did that and let’s go back to the presentation and see if we are leaving
or something basic commands yes this is important in Linux you cannot do a way
where without the command line so you have to learn it in order to do things
fast to open the command line you have to first to go to system and then you
can go from favorites also favorites you have the terminal ok and from there you
can open it here terminal opens up okay so here you can run simple commands
the first and the most simple command in Linux is LS and let’s list the files
okay LS if I do this what does it show
it shows the files and folders present in the directory where I am so I am in
the home directory normally when a user logs in it goes to the home directory
this directory which I opened the home directory for his own account so here I
can see the name of the folders which are their folders are normally in blue
color and files are a normal black color in the command line screen so if I do LS
I can see these folders which I can see in GUI mode same but I have to give
command line if I want to enter the Dexter folder or the Documents folder
but the Downloads folder I have to go it through command line I have to do
another command called CD change directory and then the directory name so
say I write downloads so we enter the download folder and if you do LS we
don’t see anything that means there is nothing inside the Downloads folder here
you see it’s there is nothing so command line also shows the same thing now say
we want to create a file a blank file that is another command called touch and
then the file name so we name it test file so a file is created see here
automatically a file appears then you can edit this file and write something
inside it test and then save it and close it so this is how we use these
basic commands now if you want to list the contents inside this again this
folder again then you can do LS so what does it show
that inside downloads we have this file called LS test file so
Ellis does the listing of the files okay and there is another command pretty
important called the man command if you right man and a command name suppose you
heard a command name from somebody and you want to test it out you want to know
the options available for that command you can write man and LS man means
manual and it shows the manual for the LS command so what does it show
the name the synopsis the description and the various switches you can use a
log with it so you can learn from there and know
more about each and every command we have other videos in this series for
knowing commands as well so we will do more when we do that so for now you just
remember that these are some basic commands and if you you know want to
study and explore more you can use the man command
like from man page wiki we saw that LS has many switches so the simplest option
is to do – H so what is this show nothing the same text file so but if I
do hair less – LH it shows some important information what it lists the
files and shows us that who is the owner of the file and everything the group and
here shows the permissions I will explain everything to you this is a part
of a separate exercise so this is how the commands work the commands can work
alone and along with switches as well so this this is what I wanted to show you
that how to operate with the command line and how to operate with the GUI in
Linux and how to install it which probably you might have figured out till
now and another important thing and the last thing for this session I would like
to tell you is we have a option called run levels and Linux
as I said Linux runs in graphical mode and command line mode it can also run
just in the pure command line mode so there are all these options available in
Linux and we call them run levels like if you enable there are six on levels in
Linux if you enable a run level three you get the command line mode only if
you enable a run level five you get the graphical mode and you can also switch
to the command line mode from the graphical mode so these are the two run
levels you should remember right now natural on will Rev and they will learn
about more run levels and know what happens in each run level for now you
just remember when you go to run level 3 in Linux you have a command line mode
when you go to run level 5 you have a graphical mode so now we are using run
level 5 for this because we have installed server
GUI options so it installed the run level 5 for us setting kernel parameters
so what we will do is the kernel is a core of the operating system it is the
set of code which talks to the hardware on one end and user to the other and via
the shell so the kernel is the core whatever we do or want the system to do
is done via the kernel so the kernel needs to be loaded after the system
boots up and then it would start talking to the hardware and the user with shell
on one side as I said and directly the hardware on the other side so how does
the kernel interact and how we can make it interact in ways we want it to like
we want to set some specific parameters so we can do that in the kernel so we
will understand how we can do that so let’s move on and see what is the agenda
for today so the agenda is introduction to parameter setting this will do
know what exactly it is and how we can tweak kernel parameters then we’ll move
on to understand the Linux boot process this is very important but why is this
in the kernel parameter setting course this is because when the Linux boots up
it loads the kernel in the end and from there the kernel takes over so we need
to know what happens before the kernel takes over in under order to understand
kernel better so Linux boot process is a very important process which you need to
be aware of and apart from this this is such an important option of Linux
because that you are almost asked the Linux boot process in every other Linux
interview session so this is very important for job seekers or freshers
and even you need to know the Linux boot process in order to troubleshoot
problems so you have to be very aware of this and then once you get through this
we will move on to understand the relationship between this shell and the
kernel better and once we do that we’ll learn about /proc /proc is a file system
a file system which loads the kernel parameters which we set and which are
predefined and it is a virtual file system the kernel reads from this file
system and acts on real-time basis so /proc is a set of parameters which
kernel is running at that point of time real time and it stores them in the file
system this file system is destroyed when the system against shuts down and
recreated once the kernel loads again so we have to know about this and then we
move forward to understand about the Linux kernel parameter setting hands-on
so we will do the hands-on in the virtual machine and then we will check
whether they are working or not so that would add the Turner parameter set
setting session so let’s move forward and do this so first of all we have the
Linux boot process but as I said before that I’ll give you an introduction on
the Linux kernel parameter setting and why we do that okay so what is the Linux
kernel let’s revisit that Linux kernel is the core of the operating system as I
said why the core because this is the know this is the main aspect of the
operating system which would talk to the hardware because the what is the end
what is the end objective of an operating system to interact to the
hardware on one side and the user to the other on the other side like if the user
wants the computer to shutdown the computer should shut down and now who
will interact and be the interpreter between them so there is there is a
thing called shell the shell takes in the users commands and then the the
commands are interpreted into the language which the kernel understands so
the kernel picks up that from the shell and then it directly interfaces with the
hardware and lets it know what it needs to do so when a user writes power off on
the command line so the shell can visit that the system needs to be powered up
and the kernel sends it to the correct modules and the correct hardware that
would power the system off so this is how the kernel works and what is kernel
parameter setting kernel has a certain set of parameters like these are
settings you can say that the Colonel would want the software to be a
hardware to behave in a certain way so this parameter allows it it forms the
directive to behave in that way like say if you want your computer to not to
respond to pings you know what ping is ping is a command by which you can check
whether a computer is alive on the network or not so if you do ping to a
certain system you can see whether the system responds or not like I can show
you we have the virtual box running sent to s7 box so last time we installed
Linux on its and to s7 so this is running I have set an IP address to that
box that IP address is 192 168 0 to 10 so if I write the ping command and then
I write the IP address and see what happens
we are getting replies from this box and the reply comes back in this millisecond
time so I do a control C and end the command so what does it teach us that
this IP is a life so we are getting replies from this IP so what do we see
here is we are getting replies from the system because it is available on the
network ok so say we want to change this behavior we don’t want our system to
respond to pings from outside so if anybody will ping it would just give no
reply to it even though it is present in the network so this behavior can be
changed by using or setting kernel parameters so these are small things and
say we want our system to lock the USB drives so we can set kernel
parameters to not respond to the USB drives even whether they are present
like if you put in a pen drive in that server it would not recognize it even
though everything is fine the hardware is working so these are some settings
and there are lots and lots more which you can do by using the these kernel
parameter settings so let’s get back and resume our our session so we got an idea
what kernel parameter settings are and now let’s see what happens when the
Linux system boots up so that would help us further understand when the kernel
comes in and when it starts working so first of all the Linux boot process what
happens when we sebou tea in a system okay when we boot a system what do we do
first of all we go and do this power on when we do power on on a system the
power reaches the SP is the power supply of the system so what does it do the
power supply takes in the power it converts it into it’s actually contains
a step-down transformer so it converts the AC voltage into the DC ones and then
it distributes them into different parts of the system the server the desktop
laptop or any hardware you’re using so what it does it sends the power so these
the motherboard powers up and then first thing which initiates the boot process
is the BIOS the basic input/output system this is a chip on the motherboard
which stores all the information about other hardware and peripherals which are
connected to the system so it recognizes each and every hardware connected to the
system and then fires them up okay and at the same time it also lets the
operating system know that word peripherals and hardware are connected
at that point so that the operating system can initialize them and allow the
kernel to talk to them talk to these hardware so the next step that happens
is loading of the stage one of the grub you know what a stage one and what one
of these options we have to know what grub is Linux operating system has a
bootloader bootloader is a program you can say it’s
a program which which takes care of the boot process until the kernel takes over
before the colonel comes in who will talk to the hardware so for that we have
a bootloader program that that takes care of everything until the file system
and the kernel everything are up so that is grub the full form is grand unified
bootloader okay earlier Linux used another bootloader
called lilo Linux loader but now all the Linux versions have grab loaded on them
so here we have this grub bootloader you know and it has various stages you can
just say these are parts of the program so this is the grub it gets loaded first
and what it does it loads itself from the MBR MBR is the Master Boot Record it
is present in the hard disks okay it is present in the first sector of the first
track in the hard disk actually and the bias can read this
okay the bias can read around 512 off the first track the first sector of the
hard disk ok so we can see that the grub is being loaded from the hard disk from
the MBR of the hard disk and from there it reads the partition table the Master
Boot Record contains the partition table so
it knows what are the partitions in the hard-disk and how it’s going to work and
then they’ll know stage 1.5 and the stage 2 of the grub what do they do they
display the grub menu you know and from there we have the menu dot list the menu
dot list shows option that what operating system are there to live there
in the hardware and which one it should boot and then it boots on and presents
the boot time menu ok and now what are these things over the right side with
red arrows I’m just explaining again so BIOS it recognizes the hardware hands it
over to the grub the bootloader of Linux in any case that the grub fails or the
bias fails to load the grub say the operating system is missing or
someone has deleted something so it would show this missing operating system
if it loads 1.5 stage and then something goes wrong then what happens it shows the grub say the operating
system is there but something else has happened to the bootloader or someone
has corrupted it or something else bad has happened then it would show the grub
menu but it would not move for a further and then if everything is fine then it
moves on to the menu list it shows all the options all the operating system
available for you to boot on that hardware if you have just one operating
system on that hardware so no problem it will boot into that if you have multiple
boot boot options like some people install multiple operating system on the
same Hardware so it gives you a menu which one you want to choose and boot
into so that is menu dot list and then it shows it on the boot time menu and
once that level crosses it loads the need Rd the initial ramdisk
it’s actually a kernel image which it loads okay before the kernel actually
starts working so that image loads a bare minimum environment for this system
to work before the kernel and the file system mounts in so once this stage is
over we go to the next stage where the real kernel comes up and mounts the
filesystem root filesystem of Linux we will learn more about the filesystem in
a separate session so till then just you know that like Windows has a C Drive
which contains all the Program Files similarly Linux has a root filesystem
which contains all the important system files as well as other user settings
which will help the system to run the way it wants to so that is it
and then we once this is loaded we get into the kernel and the kernel starts
the first process of Linux which is called the init process so it is a
parent process which then starts all other processes under it so this is how
it works and then we see that these are the various errors if any of this stage
fails then it shows up this egg so if you see error file not found
you would probably understand that the kernel image could not load successfully
if you see that there is a kernel panic error or the system freezes at boot you
know that the kernel was not able to mount the filesystem so these are the
various settings that have that let you know and this is how the boot process
works once the in it runs everything it runs the other scripts and services
which brings on the boot system are so so we are through the boot system now
now let’s see how the shell and the kernel are related to each other how
they interact with each other okay so first of all the we have this option
called the shell and when we login we have the privilege to see this this is
the user first this is a logical diagram you don’t imagine that this would be
this is how it works inside no it’s not like that it’s that the user that means
you are for reading your commands to the shed the command-line like if we login
to a system let’s login to the server this is that
you’d add to read the IP address of the server this is the same system we
installed in the last session when we did the Linux installation and it was
ten so SSH what it is you will understand later when you when we do
that session on remote logins and all so SSH is a command which allows you to
remotely log into any system if you are on the same network root is the username
of admin and this is the IP address of that system
who’s asking yes or no we say yes we want to log in and save the key and it’s
asked for the password so I put in the password so we have logged into the
system so this is it we are inside the Linux system so now we are the users and
what are we getting here we are getting the terminal to run the commands like if
we run the command LS it will list the files here so we have all these files
here so what is it it is actually the shell who is taking commands from us and
then sending it to the kernel and who is again doing the
interpretation to the system and then giving us back will be posed so that is
how it happens so now what do we understand that we are talking to some
shell here we can even see what shell we are using then bash so this is the bash
shell which we are using similarly here we have this logical diagram which shows
that the user gives command to the shell it could be sea shell castle of Bourne
shell we are using born again shell that is called bash the shell then who gives
information to the kernel and the kernel talks to the hardware as I said so user
input goes to the shell and the kernel and then the hardware so this is the
relationship between them the shell is the interpreter for user commands kernel
is a takes in commands from the shell and passes it to the hardware so this is
what it is so let’s see how we can set kernel parameters and how we can do that
in real world okay so first of all in order to do that we have an interface a
command called tzitzit gear okay by using sis secure we can set kernel
parameters so before going to that let me just tell you that when we set
parameters in a kernel there are two things you have to remember access CTL
command first do a man of this command and see more sis CTL configure kernel
parameters at runtime and these are various options and switches you can go
through them and understand how it works so you can do a man the manual page of
the command CC TL and see how it works because this is the command we can use
to set up the kernel parameters in real time but the problem is when you boot
the system the parameters which you have set would vanish so if you want to make
the setting stick you want to make it permanent to the server whether it
reboots or not doesn’t matter well even if it reboots the setting would come
back okay so in order to do that there is a special file which we use and write
our settings into this file is the etc’ sis CTL dot con file so once you enter
this file here you can write your own parameters and set set them okay here it
has some default settings also systemd power default settings live in this and
this file you can write it over here okay this is how it should work
let’s see what are the default settings here here you have some default settings
set in the system okay these are some network related settings which are set
in this file so what do we understand we have
multiple files where we can set the parameters if we want to make them
permanent and if we want to do it in real time we can just set them up here
we can just set them up using set Cpl command so CTL is an interface that
allows you to make changes to the running Linux kernel now when we make a
changes to sit CTL where does it store it it stores it in the proc file system
if we go to the / CD / and do an LS what do we see we see that there is a bin
there is a boot there is a devil ztc these are various folders of the file
system under this root filesystem the slash so we also see that there is a
proc file system in here ok this file system stores real-time kernel parameter
data so when we set something using sis CTL or something in these files so it
goes to the it goes to the proc file system inside it
we’ll see how it stores those data before it let’s try some serial commands
to load the settings ok here we have 6 ETL – AC city and – capital a both are
same this one is an L a le s of this command
so let’s run it and see what kernel parameters are set see there are a lot
of these so these are all kernel parameters which have been set by the
system by default okay there’s so many of them so
change each and every parameter to make things according to our wish but we
don’t need most of them but as we move on with Linux and certain say when
you’re going to install Oracle database it needs to have a certain set of kernel
parameters when you said Apache it needs to have a certain set of kernel
parameters so all these things are taken care by this kernel parameter setting
that is why you have to know them now let’s see how many of them were there
just for you curiosity this gives us the count of the
number of lines okay so what did we see there were 954 parameters set by the
kernel so what does this command do it gives you a list of the parameters which
are currently being set so let’s try something let’s set some parameter and
see how it works so to make changes permanent we added the CCT alert call
and then it loads it into the proc file system as I said and from the proc you
can see what is the status okay so here I have example stored over inside proc
there is a parameter for IP forward like I said if you a make if you want to make
your system forward work as a router and forward packets to other servers so you
have to set this parameter to one that means you enable the forwarding and if
you may make it zero it disables the forwarding so let’s check what is the
current state of this one so in order to do that you just cat cat is a command to
show the output of a file so what do we see inside the file it’s written one
what does that mean that means IP forward option is on if it was zero we
would understand that before adoption is off even we can make it zero so in order
to change the parameter in real time we can do it this way we can echo we can
equal zero and redirect it to this file when we do that it writes zero inside
that file so let’s check again do a cat see the setting has changed to
zero so now the kernel would not forward any packets to any external system that
is because the IP forward is off now so this is how we tweak kernel parameters
now if you want to make this set employment you want to boot your system
and still see that the setting is zero because now if I boot my system it would
come back to one because that was the default option which we saw and if
restored in the proc so if we reboot it it would come back to one but if you
want to make the setting stick we have to do it by writing this option in the
society al.com file what do you have to do VI DC sir CTL con here we write this
equals zero and then save it now this will become permanent even if I reboot
the system this setting will be zero so this is how
it works and say if you have written something in file and you want to load
it and see okay you can do this sis CTL I can P it reloads the kernel parameters
which we have written in C CTL con so now this server would not forward IP
requests okay so similarly as we were trying that ping ping for the system the
ping was working right say we have another tab here do that
again let’s ping the server we are working on
one ninety two dot one sixty eight dot zero dot ten the ping works right we
want to stop this ping so let’s tell the colonel to tweak the parameter and stop
being requests for that we can do it in a pretty simple way here I have written
an example this thing this is the parameters to stop the ping
now how do you know all these parameters you can Google around you can take the
man pages you can check the serial – a options to know all the parameters and
then gradually when you start learning Linux you will know more of these
parameters so now you just have to know how to set these parameters and what are
these there see you saw there are nine hundred more than 900 of them so you
don’t need to remember everything you just need to know how to set them so
that when you come across any you would be able to set them so let’s get back
and set this let’s do something to stop this Bing so that my system will not
respond to ping glucose let’s tell the colonel to do that so we go to the CCT
elle.com sorry i did not give the complete path so it should be ET c CS
CTL calm so once I enter there I go to the end of the line and then I paste
that parameter and make it equal to 1 that means net ipv4 means IP version 4
all requests which come by ICMP ICMP is the protocol used by paying
so it would ignore all so I want it to be one that means it it would ignore
everything all the ping which was coming to it so the kernel would not allow the
pings to happen so I saved it saved it to the file and now we do sis ATL open P
this will reload resetting again it shows that this setting is reloaded and
this setting is reloaded into the kernel so now if you ping it it should not be a
lying-ass a ping see we are not getting any replies it’s showing request timeout
why because the kernel there was not aligned the ping so if we change this to
zero again then we would be allowed to ping so isn’t that kind of magic that’s
all happening due to the kernel and just because we have setting the kernel
parameters to behave in a certain manner so we reload it again so it’s zero now
so now we should be able to ping it see the ping is back so this is how each and
every parameter can be set you can set the like here there is another example
if you set this to one auto close then the cd-rom would auto close or once you
have put in the city to the auto close by taking and request from you and if
you make it zero it would not auto close so these are various settings like I
said you can even if you want to disable the ports of the USB ports of the system
so that you want if you want more security in your server you don’t want
anyone to put in USB ports you can disable it from the kernel and it would
not work so this is how kernel parameters are set and this is how they
work it simple go to the file say CTL dot count
right the parameter name set it to zero or one and a below disable reloads this
ETL – P and then you are done so this is how the kernel tracking work first of
all we need to know what software packages are all about you know a
software package is this is a program which has been packaged into a binary
format so that the user just gets the program he doesn’t have to know what is
inside how it works and all he just runs a few commands so that he can easily
install the package as well as the dependencies like every package has a
few dependencies like if you have a package which is written in C program so
it would have to have C library installed in the backend that enables to
run the C program so every package and dependency needs to be installed and
this is done by the package management software’s in Linux developers create
the software they bundle everything and make a executable out of it so when you
execute that file it will install the package okay so this is the way it works
and this package file is in different format for different Linux flavors like
when he use Centaurus or Red Hat flavor of Linux they have their package
management program called yum to manage this packages and the packages are in a
format called RPM bread hat package manager proprietary to Red Hat and also
used by other flavors like CentOS so similarly like if you use Debian you
have dot dev file which you need to install it’s very similar to like what
you used to do in Windows Windows we have exe files executables so we just
click them and the package gets installed similarly we have this RPM or
deb files in Linux for the Red Hat CentOS Linux we have the
RPM files and for debian we have the dot dev files and we also use the dot their
files with another package manager called apt-get and using that we install
in flavors like Ubuntu so these packages have different file formats and they
contain different control files which control how and what packages and
dependencies need to be installed so this is it and here like we have already
discussed Red Hat and Fedora Linux software is primarily available in
inform of RPM files that is the standard of packages for the Red Hat platform and
then for Debian and Ubuntu we have a format called dot dev and also we are
have simple binary files which can be directly executed or built and these are
also available I start zip archive packages so these are
different file types it could be a dot dot dot cheez-it file which you have to
extract and then install or build it could be a deer file for Debian flavor
Linux or it could be a rpm file so if anyone asks you how do we install
packages and what are the format’s you can say that I have installed in Red Hat
or self fedora it has RPM format if I install in Debian
it has a dev format and if you build from source then you have a tar file
from which you extract and then build your packages so this is how it works so
before we move on to RPM let’s go to our test server and then try out something
ok so first of all let’s go to the terminal let’s see here for installing
and removing we will use the terminal and command line mode only you can do in
the graphical mode you can do things very
simply because that is just like windows you have to just click on the RPM file a
window will pop up and it will ask you for installing the packages and you have
to just click on next and if dependencies are met then it will get
installed until finish and so we will use the text mode the more suitable mode
for system admins in Linux and try to install and remove packages ok so first
of all what we need to do is we will we will login to our server this is by
using the remote command called SSH and then the username you have admin user
and then we have this IP address this IP address is for the server which we have
configured for our test purpose so this can be different in your case and here
we have the password this after entering the password we will get terminals from
which we can run our commands so what we’ll do is first of all we’ll get to
know what RPM command is and how we can use it to install certain RPM packages
so first of all let’s write the RPM command with with the switch – edge that
will give you different options here what does it say that since this has
option called – edge which is for the hash so it will not show you the help
options so in that case you can do one more thing Linux is very beautiful it
allows you to do the same thing in lot many ways so you can write our man RPM
man is a command which gives you the manual for a particular other command so
if I write this then it gives me the manual for the RPM command so I get
everything all details about a command from the man
Paige so here what do we see rpm is the RPM package manager and these are the
various options which can go with the RPM installation we would in our
day-to-day work not need all these options but a few of them okay so these
are various options which you can go through in your spare time each and
every one and find out what are the important ones and which one you can use
but I’ll show you some of the functional and basic rpm command usages so that
they will help you in creating the package
I mean installing the package and removing the package querying about the
package okay so that would get you going so first of all before we do this before
we get on with the installation let’s know how RPM works and how we can source
packages from where can we get the packages we want to install and then go
about installing a package okay so first of all let’s see what RPM is RPM is free
and released and the GPL okay it’s open-source in that sense RPM keeps the
information of all the installed packages under violate RPM database RPM
maintains its own database and keeps the information of all the packages and rpms
have various components and this includes the source code with which they
are built RPM deals with dot RPM files like we saw when we want a package in
Linux to be installed it would be a dot RPM package if it is Red Hat or sent to
us so in order to install remove upgrade verify and query we have various kinds
of commands which enables us to install and do these kind of operate
so we will go through each one of these operations and try to work out how to
install a package how to remove a package how to upgrade how to verify and
how to query so we’ll go through all of this but the question is where do we get
the packages from so first of all what do you have to do is you get your
packages from repositories like it’s just like library you can see a say that
when you want a book you go to the library you search from list or and then
from there you get to know the name of the book or the shelf number where it is
kept and then from there you get the book okay so it works pretty similar in
Linux packages management also so rpms are they’re present in a repository
which is managed by another software called yum okay we’ll come to it later
on in this session so first let concentrate on the RPM part so rpm can
be found in repositories managed by yum rpms can be found by the Linux
installation CDs every Linux installation CDs has a folder which
stores all the rpms which are normally required for that distribution so you
can get them manually from there and copy two over to your system and then
install whichever you want want to install so apart from that we can find
this from the internet also there are various sites which are public
repositories just like I said repositories are kind of libraries so
these websites rpm find dotnet reddit addcom fresh rpm start net RPM people
dot net these websites provide you rpms so you have a simple massage menu in
there and from there you can search and install
the RPMs which you need so first of all let’s let’s get going and install one of
the rpms and find out so for that let’s first go and get the RPM and I will show
you how to get rpm from the internet for that let’s start our browser let’s open
a new window so from here we’ll go to a website called rpm find dotnet here it’s
a simple site from which you can search your rpms let’s install a sample rpm
there’s a simple command called cows a in Linux it doesn’t do any important
things or operations just a simple command for typing something and getting
replies so it’s just like that so let’s search here it shows you the cows way
rpm is present and here are some options like mga sakes know are so what are
these and what is this so this is the version number this is the build I mean
for which distribution it is like I said Linux has various flavors so this is one
kind of Linux this is one kind of Linux Mandriva Fedora CentOS Red Hat there are
various kinds of Linux and this is the architecture like in hardware we have
processors they could be 64-bit processors or 32-bit processor so this
package has been packaged for Noah like it is independent of I mean the version
of software like the x86 or x64 threading of processors and this is the
build for the distribution like sent OSX Red Hat 7 whatever the version that will
be written here and cows say this this is the name of the RPM and this is
the version of their build like if they build a new version they would name it a
four point something or or anything they want to like the first thing gives you
the major version and zero three this part gives the minor version of the
release so we can take the packages from here and install them now how do we know
which one is correct for us for that you have to go back to your terminal and
know what Linux you’re using what is the version and what is the architecture of
your processor for that we have some simple commands which we can use and
check these things out so first of all we do it easy
Red Hat release this command is quite important you just check the contents of
this file et Cie Red Hat release if you are in centaurs already at this footwork
so what does it show centaurs Linux release version this
score so we get the information that we are using CentOS Linux 7 but we don’t
know the architecture yet for that we have another command you can use you
name half an a it will show all the parameters about the furnace so here it
shows the operating system uses x86 64 bit so it uses an Intel processor 64-bit
processor so we would need packages for 64-bit here if it is a 32-bit it would
show something like this I 386 okay and sometimes we have AMD processors which
show some other information but here X 64 or 32 this is how we know which
version would be needed so for that lets go to the time download the RPM there
and then get going and in stole it so we would need a 64-bit for
our sent OS so Enterprise Linux would be good for us and the 64-bit version this
one so let’s copy the link address to get the link we don’t want to download
it here we want to download it in inside the server so we get back to our Linux
box and we are in the temp folder so this is the command W get it will fetch
you the package from the link which you provide it so it is just downloader so
here we write the URL which we copied the link of the RPM and I W get once we
do this what is it it is connecting to RPM fine net log again as the FTP user
because this was an FTP link and then downloading it so it was a test package
as I said cows a doesn’t do pretty much and that’s why we chose it it would
download very fast because it was just around what was the size of this package
let’s check out it was just around 25k so pretty small so let’s see where the
package is this here we have got the package
cows a three points or so and so and no art and rpm so this is the RPM file we
were looking for so let’s do one thing let’s install it first like we said we
have a few options by which we can install software remove software using
the RPM command we’ll know that first so first is installing this for installing
this what we do RPM I have an IV edge and then the package name
simple RPM – ivh and then the package name now what
does I stand for pretty simple it’s for installing V is for verbose verbose
means when we install it will show other information like if the package already
exists it would show the information that it is there so we don’t know to
install it if it is not there it would ask us if there are some dependencies
errors it will show us so verbose is pretty good to enable so that you will
get to know what is going behind the scenes if you don’t put the V it would
just silently run the command and get to the next prompt and for H it checks the
hash and it shows you the progress of the installation in the hash format so
for that we do the three switches we do add the three switches rpm – IV H and
then the package name so for any package you can do it this way download the
package step one then you run the installation command step two and then
you get going so first of all we press and what does it do it extracts the
package and then it’s already installed so let’s works before I proceed to the
next concept there is a question for you which Linux installation provides both
text mode and graphical mode below are the four options option a server with
GUI option B minimal install option C Linux desktop and option B Linux CLI
tools do commit your answer in the comment section below to test your
knowledge let’s proceed to the next concept so when we do the installation
it installs fine but when we remove this package it’s not showing that it’s not
installed but it is we know we have installed it why this that is because we
are giving this command in the wrong way like you have to erase rpms
I mean remove rpms of packages with – e but you do not have to
give the name of the entire RPM package that is because if you give the entire
RPM package it would search for its RPM database for the entire package name
which it would not find it just you need to have to provide this cow say this
much the name of the package not the entire rpm file name while installing
yes you have to provide the entire file name to extract and install that file
but once it’s extracted and installed it just needs the name of the package and
not the end drive binary so if we do this RPM – e cow say then it removes
this from the entire system so this is it simple so that’s removed from here
and then now we have to move on and check other options of RPM commands so
for that you have to do this man RPM man gives you a manual page of the RPM
command so that’s gives you various options in which you can use RPM to
install to upgrade to query to e race and other allied things so you can go
through all these options and check them out and try them out and find out how
they would help you but I will show you some simple options which you need in
your day-to-day life here and Linux so first we know about installation rpm I
have an IV edge and the package name so that was it for removal
it was RPM – e just the package name but not with the dot RPM right so there is
another command called RPM cue a this will list all the rpms that are present
in a particular system this is a pretty useful command in scenarios like you
have two servers in one of the servers you have some
software installed and someone asked you to create a exact replica of that server
in another server and you don’t know what are the list of packages in the
first server so for that you need to find out the list of packages installed
in the server or any Linux system for that you can do it by RPM – QA using it
it will show you all the rpms that are installed this is the list of all the
rpms that are installed in this system now how do you take it as a list I mean
as a file containing the list because the screen would scroll down and you
cannot see what what is the contents are so for that it’s another simple addition
here you can give this symbol the symbol is for redirection so redirecting the
output into a file so let me name the file like rpm rpms list dot txt so now
what it does it doesn’t show the output on screen but sends it to this file so
we can open this file using any text editor and we can view the list of rpms
installed so that is pretty simple to get a list and then we can use this file
to install it in some other server or on any other Linux system so this is how
this command is useful QA it queries all the rpms
right so similarly we have other such query commands like if we want to check
anything about a particular rpm let’s go back to the cow say and install it again
so this is installed rpm ivh now say rpm so the RPM is installed now let us check
what are the contents of this rpm and where are they installed ok if someone
asks you you install a package but what are the files inside the package which
were installed and we’re at the port so to find that
you can use this query rpm – Q L it will list the contents of an RPM where they
are extracted so here what does it show it’s not installed is the same ol error
that’s because it just knows the name of the package nor the entire package name
just like RPM – e needs just the name of the package not the entire file name so
the same so just the same here we can see that it lists where are all the
files related to the Cousy RPM and where ever have they’ve been extracted – so
this is a pretty useful command but you just have to remember that how to pass
it like this is how we pass it and this is not how we do it okay so you have to
remember this that’s why I showed you both the ways the wrong way which you
shouldn’t do and the right waves you should do so it shows you this there is
another I mean you have another variation of this this is rpm QP and
caps are and here you have to use the entire name of the RPM when you do this
it will show you the libraries which this RPM would use when it is extracted
or installed here it shows it uses the shell it uses the Pearl it uses various
functions of the Pearl library it uses the RPM lip so this is a pretty good way
of knowing what the dependencies would be when we use a certain rpm so this is
how it works and you can check the main page anytime to check about more options
available for rpm command but only you have to remember these important things
of install and uninstalling I mean the erase
erasing of rpms and then the query of rpms rpm QA rpm QL and this command and
apart from that there is one pretty much important command for rpms that is the
that is the upgrade here you have this I rpm – you viet just like i bh you
replace i install with you upgrade but you should be your capital you and then
the package name I mean the whatever like here we have cows at 3.0 3 but we
want 3.0 four or four point something then this is the way we need to upgrade
it there’s a difference between upgrade and install in install if you want to
install a higher or version of a package and the present version already exists
so you have to first remove the package RPM – e and the package name not the
entire file name and that would remove it and then you reinstall the higher
version but if you want to keep the existing one keep the settings and
everything and just replace the new files which come with the new package
you have to use the upgrade command this is more useful in linux when you have to
upgrade a kernel so in a kernel you don’t want to take in case of a kernel
you don’t want to take risks and and you don’t want to just uninstall a kernel
and install a new one so in that case you do the upgrade so that stores the
existing one you can go back to it whenever you want you can roll back the
changes and that’s where you use a uvh command mostly so and if you can go
through the main pages you can know the other important uses of RPM but for now
this is enough for installing and installing and doing other stuff so now
let’s go and go on and discuss the other users I mean the other users of the
rpm command apart from installing and uninstalling
you can also do a query which we said but there is a disadvantage in using the
RPM command what is it in rpm if we install a certain package and it
requires some dependencies then it would not get installed what is it like say we
install Apache and it requires a dependency called Lib a PR so in that
case a passive would not get installed or it would not work the way it should
so in such cases we have to first install the Labour PR which is a
dependency for Apache and then install Apache then only it would work so how do
we do that how do we know all the list of rpms download them install them and
then install the RPM we want there’s pretty confusing right so in order to
resolve that you resolve the dependencies we use a program called yum
it’s yellow dog Update Manager yellow dog is the name of the company nothing
else so if we use yum it manages the
dependencies checks various repositories in the public and finds out where our
RPM lies and download sets and then installs it so this is how it works so
what we do is we install in the yum command already when we install Linux
and CentOS and Red Hat we have this demand and then we write yam install and
then the package name so here we want to install Apache HTTP D so we write yum
install httpd yum install httpd what it does it resources the package from
various repositories and finds out that this is the package we need and the
dependencies have been resolved that means whatever dependencies were there
were already present in my system so when we write yes it in downloads the
package and then installs it so what information it finds out is what is the
package name what is the architecture required you might remember that we
checked the architecture before downloading the RPM file for kausi we
had to do that manually right and we came to know that it was a 64-bit system
and so we downloaded the 64-bit RPM but in case of vm it resolves everything it
checks the dependency checks the version that would be suitable for you and then
finds the repository where the Apache is available and then the size and then
downloads and then finally installs it here it’s done Apache is installed and
installation is complete so pretty simple this one is simple yah makes
things very easy just yum install and the package name you don’t have to know
the version what is right for you what is wrong for you
yum does everything so that is a pretty simple way of installing similarly you
can use yum to uninstall as well ok here you have yum removes and then the
package name so we just installed httpd we installed it we remove it so what we
did yum remove httpd it marks the package
for removal and asks us is this ok so we right yes it removes it so that is it
it’s simple to install as well as remove so IAM removes the package now for us so
we have two commands to remember yum install and vm remove package name apart
from that there are pretty simple and interesting uses of yum say you have a
server and you run the netstat command let me show you what netstat is the stat
is a command to show you which ports which network ports your server is
listening to so this is the address this is the port
which our server is listening to what is the PID and things like that will come
through this command later when we do our session on networking so just to
illustrate I’m showing you this example netstat is a command say you go to a
system or server and you write the netstat and shows command not found so
what do you do the first option you want to install the
netstat command for that you have to write this yum install netstat if it’s
already there in my system it would show that netstat is present and if it’s not
there it should show that nest at is not present and i’m going to install it
right let’s see if that happens or not what does it show no package is
available but my command is running so how is that
that’s because netstat is not the package that gives you the netstat
command right otherwise it would have got installed or it would have shown
that the package is available or whatever so yum install netstat is not
the correct command to install that’s that so how do we know which package
provides netstat command so if you happen to come by such a problem you’re
a you know a command in Linux but when you run it it shows command not found
and you want to know which package you should install to get that command
working so in that case you have option in yum called what provides so you write
what yum what provides the command name which you want to install okay so when
you do that it shows you that there’s a package called net tools version this
and this for this architecture which has basic networking tools inside it
netstat is one of the files in that package so you get the package name from
here now you can simply do yum install and the package name if it isn’t there
in that system that would be installed but in my case it was there already
installed and latest version so it had nothing to do but in those places where
net set command is not there you can use it
so not just netstat you can use what provides to check any command which you
want to install so say we want to install the command ping so what does it
show there’s a there’s a package called IP util which contains the ping command
so if you install this your ping would start working so this is how we use yum
to know which packages need to be installed forgetting which commands
which we want to have in our system so this is how it works yum simple
installed removal and what provides these are pretty simple usages for yum
you can also get to the man page the manual page and check out the yum
command details so here you see yellow-dog update or modified and here
you have the entire options which yum can provide you we can very went through
the install similarly if you write yum update and the package name it updates
your packages and upgrade if it if you want to upgrade the entire operating
system version which you are using and yum remove or arrays in order to remove
the RPMs and other options like it yum list to lists various informations about
the packages so this is how it works you can try out all this like if you want to
check yum list HDD PD you can list about httpd
if you want to check about my sequel package the database package it’s not
there in my system so let’s see what it does it shows no matching packages to
list so this is how you can find which package is there in your system which is
not there and this is how you can install uninstall or upgrade packages
and even you can know what provides what package provides which command and other
such information let’s get back to a presentation and check what else we are
missing out so here where do we get packages we did that in case of rpm and
in case of yum we don’t have to do anything we need to just have
repositories inside our system configure and you will get to know more about
repositories in one of our future sessions and then we have this
downloading section in case of rpm we have to manually download it and for
that we use this command W get and this will download it from HTTP or FTP
archives and then we did this hands-on on installing using rpm rpm IV s command
removing using the RPM – a command and then we use the yum install yum remove
commands in order to install and remove software packages I would advise you
when using dealing with Linux software you always go for the command-line
that’s why I didn’t show you the graphical user interface for installing
and removing packages because command lines makes it faster and more effective
okay you use W get to download you use the other command-line options the RPM
and yum to install run and install but in case of the graphical mode it’s
pretty simple just need to double click to install and to uninstall also you can
go to the settings option and there you find the packages and then you uninstall
them but that is not very effective and in case of servers system admins
normally prefer to use the next mode that’s because Italy gives you
more flexibility and you can work with using less resources okay so and it’s
faster it’s faster and convenient once you get used to just a matter of
remembering the commands and in case you forget the switches you can always use
the man command to check out for the options where okay so this is how we
work on the software installing and D installing in Linux managing system
services and Linux we will discuss about the services which are related to the
system’s working of the operating system in Linux so the operating system
comprises of a set of processes which are running in the background in a
proper sequence in order to make the operating system functional so Linux has
a set of services which start up whenever the system is booted and the
kernel loads and these services run in the background and enable various
programs to work properly and also enable the system programs to keep the
operating system up and alive so we are going to understand what these services
are how to manipulate them how to start and stop them and know the status of the
services how to change the nature of services how to monitor them and stuff
like that so let us first go through the agenda the agenda is studying the
processes in Linux what Linux processes are and how the
processes run and who are the owners of these processes then we’ll go on and
learn how to monitor processes in Linux then we will learn how to schedule
processes in Linux like if you want to Shatila process you have to be able to
know the various aspects that allow you to set the process to run or stop at a
particular time so that scheduling would be taught and then we will move on and
understand what our services in Linux system services and how do we manage
them so that’s pretty simple it’s all about services and processes which are
running and know how to bring them to background or foreground how to schedule
them so things like that so we will be concerned with the commands that enable
us to do that and we’ll do a hands-on to check out how the monitoring of Linux is
done so let’s get going this is going to be really interesting so what exactly is
a process in any operating system you might have noticed there is a process if
you have used Windows if not Linux then you might have run the task manager
there you can see number of processes having certain PIDs running and if some
processes hang you just right-click and end task to kill that process and stuff
like that similarly every operating system including Linux has a process
process is a program that has been loaded from a long-term storage device
usually a hard drive into system RAM and currently being processed by CPU on the
motherboard now that is a standard definition of a process now let us break
it up and try to understand what a process exactly is so that you get a
very good understanding of the term process a process is a program that has
been loaded from long term storage device what does this mean this means
that a storage device like a hard disk which contains the entire operating
system contains scripts which can run processes which comprise the operating
system like you have a operating system there are many processes running which
keep the operating system up so these processes are actually present as
scripts or programs inside the hard disk of the system and then we use it we use
the process and that process when we use the process the process actually
executes that program and loads itself the hard drive into the RAM and as long
as it present it is present in the RAM or the memory then the process is
running and he’s being processed by the CPU which is definitely present on the
motherboard so whenever a program is run and when it moves from the hard drive to
the RAM and is being currently processed by the CPU
so that becomes a process so program which we run or a script which we run
and move it into the the memory and is being serviced by the CPU that such a
program is known as a process so process needs to be running it cannot be a dead
one okay so every process is life is life because it resides on the RAM and
is being helped by the CPU to get executed so there are various types of
processes one of them is a user process okay the user process is the process
which is created by the end user when he or she executes a command from the shell
prompt and through the or through the X graphical interface before we go and
understand this let us first login into the Linux system and see what the
processes are and how they are running then we go and learn some commands also
because unless you see some processes running you won’t be able to relate what
user processes are what system processes are so let’s go back to what exactly is
a process and then go to our terminal here I have logged into the Linux system
earlier and then let me first do a command simple command PS aux this
command gives me the output of various processes that are running ok PS is the
process command so here various processes are shown let’s take a bun
of them and analyze first here what does it show user is route the PID means the
process ID is one this much member CPU is consumed this much memory is consumed
and so on and this is the command which is running that means this is the
program which we are running user live system D system D this is running in the
background okay so this is a daemon and as you can see this process resides in a
location in the hard disk in the slash user Lib directory in the hard disk so
what it is the system D is a binary which is being run by the pro and since
it is being run it is loaded in the RAM and being processed by the processor so
each one of them are showing up it is taking this much memory that means in
order to load the program and execute it we are using 0.3% of the memory present
in the system and this much of the CPU present in the system and each process
is assigned a PID or called process ID so PID of this process is 1 and it is
owned by the user root that means the root user has executed this process and
it’s running with a PID 1 so we got an idea of the entire definition of a
processes resides in the hard disks when it is run it takes up some memory
because it is loaded into the RAM and uses the CPU to execute itself because
the CPU is the central processing unit it is the one who processes each and
every program and it is having a tag called process ID which is one here in
this case and each of the process is owned by some user so here the user is
root in most of the cases ok so this is it the definition of a process so you
might have got an idea and the command VI used to invoke the processes PS aux
we will go into the commands later on in this session and then you
will get a fairly good idea on what processes are and how to monitor them so
now you just remember the process is a program and it has been loaded from the
hard disk and when it runs it it runs on the stays on the RAM and is being
processed by the CPU so now let’s get back to types of processes now it would
make more sense to you user processes some processes are created by end user
when he or she executes a command from the shell prompt or through the X
Windows graphical interface so this is quite interesting when a user runs a
certain process it is or executes a certain command he he or she makes a
process in the background so even when we do let’s clear the screen Savior
pinging a particular IP 192 168 dot 0 dot 254 okay we are doing a ping and
getting some replies here so this now might have created a process on the
background because some script is running which is enabling this ping ok
let’s try and find out if we can track that process or not so in order to do
that we have to open another terminal this one is running the pink parallely
we go ahead and open another terminal to the same system we login as root to that
as well put in the password big beer in that system so now if we do PS aux we
can see lots of programs are running ok but can we track that ping let’s see yes
here that means the user root is running a
ping to this IP address so it has created a process in the background and
given it a PID of this month and since the ping is a very lightweight it is
almost using zero percent of RAM and CPU so but the process is alive and it has a
PID of this and even we can filter and check only that process I do this sorry
let’s use grep in combination with this command PS a works and I want to grab
the process which is doing the ping so it could show up that this is the
process which is doing the paint the second line is the grip itself since the
grep command itself uses the ping string so it shows up so we are concerned with
this one so now we can know that ping is running and so there is a process with a
PID which exists now say if we kill this one with ctrl C we can kill a command
the command does not exist anymore now if we do a grep of ping we should not
see this line we would only see this line let’s do that yes so that line has
vanished just because the process has died ok so this is how it functions the
user processes some processes are created by the end user when he or she
executes a command like we just did and from the shell prompt or through the x
window similarly if we go to the graphical mode and try to open some
program it would show up here as well so we are not doing that we are just
running one ping command and trying to see whether it creates a process and or
not and we saw that it does so such a process is called a user process then
there is a second kind of process which is called a system process or a demon
the web server FTP server file server anything which runs in the background is
called a daemon like say say we installed the Apache
server and then run the Apache process okay so to install the Apache server we
will do yum install HTTP deep so it would look up for the Apache package and
download it and get it installed so it is checking the repositories and trying
to find out where the Apache process is so meanwhile let’s discuss what will
happen once this is downloaded and installed we would get Apache install in
our system and once we start the Apache process we would have a background
process which is called a demon so every service which is running in a server or
a Linux system like like we are doing the web server installation now so we
will get the Apache web server running in it
so that would help us to run a demon in the background called HTTP d d stands
for demon a demon is a background process which comprises some programs
which would run silently on the background and help the package to be up
so such processes which are not invoked by users and run on themselves when
certain services are started unknown as system processors or demons these are
actually background processes these are not created by users but the system
itself ok so now we are ready with the installation let’s kick get off using
yes so now the RPMs are getting installed for Apache to start up so once
everything is done we can clear the screen now and start the Apache service
so for that we have a command system CTL we will go through these commands by the
end of this session so right now just remember in order to start any service
like I am the patches of a start-up right now you
have to give systemctl then you have to write start and then the name of the
demon so once I do that I get the prompt back again what does that means the
process has started probably in order to ensure whether the process has started
or not I write systemctl status httpd now what does it show it shows that it
is active and running seventeen seconds ago so that means we are running this
process httpd dot service it is a background process or a demon that’s why
it’s written httpd that’s the demon and the service is also called as HTTP
detour service so that means this service is running and it has a PID of
three eight zero eight correct so now if we run the previous command PS ax and
now if we grab the Apache process grab httpd we should be able to see the
process related to this what do we see we see that three eight zero eight is
the core process which was invoked by the root user because we have started
Apache as root and then there are some child processes which are owned by the
Apache daemon themselves okay so this is the Apache user which is owning those
child processes because this is how the entire Apache thread is running so such
processes which are run automatically by the demon itself like these ones are
known as system processes or demons because they run in the background which
did not start this script we started the service and it started a daemon which
has a thread of other services child child processes which makes the entire
Apache stack running so such a process is known as a system
process of a demon these are usually two diagram processes
which keep on running on the background so that Apache is running or my sequel
is running or Samba is running so various services in Linux can be run
using such processes now we are not going deep into this because when you
install each and every component like web server FTP then they will get a
greater understanding now you know how to monitor the processes you just have
to know all these things how to monitor them how to know whether a process
exists or has died whether it is a demon or a user process and stuff like that so
let’s go further and try to do some monitoring of the processes first of all
we go ahead and check the top command like we did with PS and PS aux command
and we used a combination of psix and grep and the process name in order to
search the processes similarly there is a command called top which gives you a
life experience of what all processes are running in the system so you get n
live in its insight into the system’s processes that’s very simple to remember
and this command is somewhat similar to the to the command we use in Linux to
teach using Windows sorry in order to check the processes called the task
manager you might have used task manager in Windows
so you when you press ctrl Alt + delete the task manager opens up in Windows and
shows various processes running similarly we use the top command in
Linux don’t use the control or del in Linux
because that would reboot the system so here we go ahead with the top command so
what did I type in just I type in tup top okay so this command is pretty
interesting and gives us a vast pool of information about the system first of
all what does it do here in the first line we can see that the top command
started up at the so answer time and it is showing that the system is up
for 22 minutes that means the server I’m using is up for the last 23 minutes
right now and there are three users who are logged into the system so we can get
that information as well and then I can see an information called a load average
this shows the five fifteen and thirty minutes average of the load on the
system we will understand what load average is or at a later stage right now
you just remember load average of zero point something is quite comfortable for
the system when it crosses one that means the system is experiencing a load
and that should not be an ideal case for the system but then it depends entirely
on the configuration of the system so it shows the load of the system now we have
very less load on this system so it is fairly healthy next there here it shows
that there are a total of 143 tasks so that means one for duty processes are
total running out of them these are dormant processes two of them
are actively running right now none of them are stopped and none of them are
zombie zombies are processors whose parents have died but they have not sent
the exit signal to the children processors so these child processes have
become zombies so we will learn about details of these things as well now you
just know that the processors are used in order to processor in order to
monitor processors we use the top command that is what you need to know
right now so here we can also see the total memory of the system and how much
of that is free how much of that is used and how much is acting as a buffer and
stuff like that similarly we get information about this rat trap actually
is part of the hard disk which is reserved and being used only when we are
low on memory means the system does not have any more
RAM so it uses a bit of the hard disk which is assigned as swept in order to
process stuff when there is no memory it needs to keep it stuff somewhere and
process it later on when the memory is free so in order to do that the system
uses the sweat so currently we do not have we don’t have any strap being used
we don’t see any sweat being used what does that mean that means the system has
sufficient amount of RAM and it does not load it up so that’s why rap is not
being used right now whatever total strap is there that much is free so
that’s a good sign so this is the preview to the top command now the real
thing that we monitor with the top commanders we can see all the processes
which are running similar to the PS aux command and then we can see which user
is owning which PID and then other information in detail this we will
discuss at a later stage or we can go on and discuss this as well
and then the final column shows the command so let’s discuss each and every
aspect of the top command so that would wrap it up for you today itself so here
first is the PID the process ID of the process this one so say this is
something which we can see in white so this process is having a PID 11 what is
the process RC u OS there is some system process so the first problem is the PID
the second column is the user which is owning the process the name of the user
that owns the process so that is pretty self-explanatory that means the process
is owned by some user that means the user either invoked it or that service
which was invoked by that user is running using that PID and the third
column is the PR pyaare here tells us about the priority
of the process okay the priority means say we want to assign a priority of a
certain process over another process let me give you an example say I have Apache
in my system as well as I have another another package installed say a database
my sequel database but my Apache is more crews crucial for this server okay I
don’t want my Apache to be slow because my website which I am hosting here is a
static website and they want to be up all the time and it should not hang okay
and the database I am having the my sequel is not so important I
occasionally store some for some data in in it but even if it hangs or it is slow
doesn’t matter because none of my customers are viewing the website the
database they are all viewing the website so in that case I would want to
have the httpd having up having an edge over the my sequel D demon so since
there are two demons two processes and I want one of them to have more priority
so that whenever there is a resource crunch I mean when the system hangs or
has less CPU or memory to allocate it would choose which one to allocate to
then in that case the one which has the higher priority will get the first
choice will be the first choice of the CPU of course in order to allocate the
resource so that the Apache here in my case will receive the more attention of
the CPU and the RAM so that’s why that process is least reliable to hand so
that is the that is the use of this PR column it shows which process has a
priority and which does not have so next we have this ni this is the nice
value of the process nice value this one and I nice value is also related to the
priority those with the higher nice values have lower priority and the
vice-versa so this is how the process priority is set and just for this
session you need to remember the nice values can set up process priority and
once the nice values are set you get the priorities assigned okay then we have
the word this is the amount of virtual memory used by the process here we can
see some virtual memory is used by the gdm process which went away right now we
can also do a shift M shift M would show the processes which use the most memory
so here we I press shift M and got back to the process which used the most
memory so here I can see the gdm of the genome desktop manager is using the most
memory so GD M is the genome text of the graphical mode of the system since we
have installed graphical in this server as well so GD m takes up the most of the
memory and here let’s come back to what what is the amount of virtual memory
that the system uses what is virtual memory the real memory is the physical
RAM which we have in the system virtual memory is actually a part of the hard
disk which is used by a process to store data which are in its cache is kind of a
cache okay where the system stores data on the hard disk and then uses it and
loads it to ram as and when it needs it so this is how it works the virtual
memory so this section shows the virtual memory when you have a when you see a
figure in the virtual memory section you understand that that process uses a
lot of RAM because in spite of having physical RAM it also stores some care
does some caching in the virtual memory so the next one is the amount of
physical RAM the process is using so that is this is the rest of the residual
Ram which it uses with this much this is the virtual memory and this is the and
if I add these two I get the total amount of memory that is used by the
system and that is 6% of the total ram which we are having if this one is taken
as 100% so and the rest of the time the this shows the time since the command is
running I mean the total amount of time it has been running and then this is the
shell genome shell which is the command or the process name which was having a
PID of 2 3 0 2 so this is how you write a queue to quit from the top command so
this is how the top command works out you should try that up command and try
to understand it better then we go on to the PS command the PS command as we have
used it earlier gives us a process okay but here we have some more options in
the PS command so if you just write PS you get a very less amount of
information what do you see the PID the TTY you are using like VL or we are in
to TTY s– so showing to 2 device each TTY also has a PID TTY is the screen
which we are using like the it is full form is pretty strange teletypewriter
actually it means the login shells which we are using each session has a TTY okay
and then it shows the time and the command which we are using so not much
information and this that’s why we add switches
to the PS command to get some more information
one of them is EF if we do PS EF we can see certain other options like the UID
the user ID means the user identification is route PID value is 1
the PP ID and the other settings so here we get to know what exactly these stuff
are S stands for the state of the process so here this one doesn’t show it
the S let’s try another of BSS variations this one this one pretty much
covers more information so here we get this stat this shows whether the process
is in which state so the state of the process this column uses the following
course ok if it has D in this column that would mean that the sleep is
uninterruptible that means the process has gone into a sleep which would not
respond to user interruptions are shows that the process is running s shows the
process is running but currently not executing anything in the CPU so most of
the processes are sleeping here this one is running so it’s showing are these
processes sleeping because this processes would just be interrupt in any
sleep which can be interrupted that means the process has gone into a
background sleeping right now not doing any execution on the CPU
once it gets some signal from the script with which it is running then it would
get back into action and its state will change to R if some processes shows us T
that means that process has been stopped we don’t have any such
process right now okay so similarly if something shows as I
said it is zombied process like it said the processes of patterns have died but
they have not sent a termination signal to the child process so the child still
waits for the parent to send its termination signal and it just exists
there but does not do anything such a process is zombie this processes should
be removed because they take off a lot of memory and then PRI the priority of
the process this we have seen in the top command as well and then the nice value
similar we saw it in the top command s head shows the size of the process and W
Chan it shows the kernel function in which the process is sleeping we don’t
have any such process but you just for your knowledge you should know that
there are these terms which exist so this is how the PS command works out you
can try the man page for PS and know each and every option and normally in a
normal day at your Linux system you should use just this switch either PS EF
or a PS aux in order to list the processes and then you can use it in
combination with crap and try to check whether a brad particular process is
running or not if I want to check its GT PD I do this say I want to check Bosch
is running or not so then what do I do a two PS aux then a pipe shine assign and
then write bash it will show which are the processes which are using bash in
the background as a shell so there are three processes we always leave this out
because this is the command that we running and since it contains a string
bash its itself as well so we leave this out so
that is it that is how the PS command rolls out so now we’ll do an interesting
task of she dealing processes if you want to schedule a process we have to
understand the Quran command there is a demon called Quran D which helps us to
shedule the process so let’s do a feeling of certain process like say I
have a let’s write a script a small script just create a file first for the
script name a test script dot as such and then inside it we write a certain
small script we do a echo on the screen which is starting script then inside the script we do certain
tasks like let’s do a ping then that IP let’s do ping google.com and we’ll do
the ping two times so the count is two and then let’s write this into a log
file so what do we do we do the Eco at so-and-so time so the date command
gives the current time and date so we write that the script ran at this date
and then we send it to a log file the log file would be say /root slash test scrip dot log okay once this is done we
exit and before exiting we also Yuko stopping script so we are done now we
save this file so we can see we have a test script file here inside / root our
current working directory / root so we have this script here let’s make this
executable we have learnt how to make things executable so in order to make it
executable we have to give a permission of seven five five and then thus name
now we can see the script is executable it’s having executable permissions for
everyone so now we can execute the script in order to execute you can write
bash because you are using a shell to execute it and the script name correct
so now what did we see first it started the script then it was asked to ping
Google two times which it did and then finally after the ping report it said
stopping script and it might have also created a file which is called test
script not love which we asked it to do and it has done it so inside that what
was there let’s see this test wave dot log inside that it is written the script
ran at such-and-such time so now my objective is now if I don’t want to run
this script each and every time manually like the script which is in /root don’t
want to run it manually each time what do I want to do it
I want to keep it inside a shitty wing system for that I use the Quran command
which is being explained here so for that there is already a process called
Quran D which is a daemon which runs in the background and you can use it to
shave your scripts okay so that is pretty simple to set up for that you
have a command called Quran tab – e to edit the Quran tab
okay you have to remember this this is very important
crontab – e once you do that you can see here this should be a blank file
normally we had done something previously that’s why there was one line
which I deleted so now this is a blank file now what do we do it
and then do here we can put certain columns and each column has a particular
significance okay so first of all there is it says that we can put five of these
columns with stars and each signifies a certain thing like the first column
means the minute second column means the hour when we want to run their script
third columns means the day when we want to run the script fourth the month and
Swift the day of the week like Sunday Monday or any day of the week so how do
we deal with this let me explain you with the script okay say we have that
script the scripts name was this new test script dot SH we wanted to run
every one minute so what do we do we press start the first column stands for
a minute write this one for the first column so
in the first column we write a star and slash one which means every one minute
and the second column stands for the hour we want it to run every hour so for
every it star and for every day of the month we want to run it every day
so we understand the three stars are over
already then we want to run every month so that also gets a star then we wanted
to run every day of the week irrespective of the days so we gave
another stuff and then we put command which we want to run the script name
okay so once this is complete we can save the file so what did I do the first
column is four minutes so every one minutes of course so star
slash one then for the next star only because I want to run it every hour and
then I want to run it every day and then I want to run it every month and then I
want to run it every day of the week so that is it it’s set now if I save this
file it shows that one tab has been installed so now if we wait for a couple
of minutes we will see the log file would have been
populated a few times does that mean if the background the Quran tab is running
our script and populating the log file now if I do a cat to the log file the
test script or log I can already see that it is run three times we had
actually run it two times ourselves but now it’s the third one has run what does
that mean it means that the Quran tab is already scheduled to run every minute so
every minute it is running one of our running our script and logging it here
okay so if we check after some time you know what’s the current time 1323 so in
1324 when we check it out we will see that you would have a fourth line again
and that file that means the Quran tab will run it every minute and as it is
scheduled to do so okay so we’ll check one more run and then we’ll go for back
into the Quran type file and check some other options
so what is the current time it’s already 24 so we should get the fourth one so
let’s check the log yes so the fourth one has already run
yeah so every one minute they are running the crontab is running our
script and populating the log file so everything is fine so this is how it
actually works the Quran so now say you want to make some changes on tab – II so
you one don’t want to run it every minute you want to run it at a specific
time so you want to run it at 12 o’clock in the night so you just write zero zero
zero means 12 so you want to run 3 o’clock in the night then just write 0 3
it’s like a 24-hour clock if you want to run it at 2 11 or 12 and you just write
that so this is what does this mean the first column is 4 minutes right I’ll say
first column is for the minutes so if I write just 11 so it will run on the 11th
minute of every hour so as I said if I want to run a 12 o’clock in the night I
have to make it zero zero so the minutes is zero zero but here I have to write
zero zero as well because this stands for the hour so that this is going to
make it run into AG o’clock in the night so if you want if you just make it zero
zero here and the star here then it would run every hour when the minutes
hit the zero zero that means it will run at one o’clock two o’clock three o’clock
four o’clock and so on if you make it 5:00 so it would run on the fifth minute
of every hour if I make it 5:00 5:00 that means every this is every day at
5:00 50 ok 5:50 a.m. because this is 5 and
it’s a 24-hour clock so here you can make it 19 that would mean 7:00 p.m. in
the evening and things like that similarly the third column that would
mean the day day of the month if I there’s actually the date so if I do 23
then it could run on the 23rd of every month and then at 7 5 okay so this is
how it works the fourth column what does it say it says the month like if I want
to run the sprong just on the month of April and for ok the number of the month
then finally if I want to run on this particular time every 23rd of April
which should be a Sunday if it is a Sunday and 23rd of April and the time is
this then only it should run then I can write a zero because the last column is
the day of the week and starts with zero means Sunday and ends with Saturday
which is 6 ok so this is how it works the crop you
should use the Quran more and more and try to figure out how to shield the
tasks so this is how the processor shield now let’s get back to some
services like we already started the Apache service there was some important
fire important commands so to say in order to list services and in order to
know where services are running or enabled so services as I said are some
background processes or demons so you can use the system CTL command system
CTL and then list unit files if you do this you can see
what all services are present in the system and water enabled enabled means
they would run themselves when the system boots disabled means they would
not run they would lie on the system until we enable them so there are lots
of processors here say we want to enable Apache in order to run every time it
boots so what do we do it do here is systemctl and novel then the process
name so it creates a link which enables the service and if we want to disable it
we write systemctl disable HTTP so it removes the way so now if i reboot the
system httpd would not start itself if you do it manually it will start but if
i want to make it automatically star get started then i have to do this
systemctl ‘nevelocity DVD if i have to manually start a service then i have to
do this command start so it starts it if i want to check whether the service is
running or not i have to do this status so it shows active running and other
information if i want to stop a service then I have to write systemctl stop and
their service name so it stops the service now if I check the status it
shows it is inactive or dead that means the service is loaded but not
working because we have stopped it so this is how this command works out you
can enable/disable stat stop now the status there is another function also to
restart the service if it is started it will stop it and again start it if it’s
already running then it will stop and start and if it is not running then it
will start that is restart it will start it
in a spective of the state so now we have run the restart and check the
status again it shows it’s running so this is how the system CTL commands are
list unit file shows you all the files whether they are whether they are
enabled or disabled so you can know that whether a particular thing is enabled or
disabled my list units you can see all the running units so let’s clear the
screen here let’s recall the commands list unit files this shows the entire
list if you just do list unit it shows that unknown operation because this
version of Linux is not supporting it okay similarly if we use the system CTL
failed it should show the fail units if any of them have failed but there are
none of them have failed then we would not get an output for this so let’s try
this it shows that this option is invalid now we have to give a double
dash so what does that mean that one of the services has failed this mandate
service okay so this is how you can see so there are
three commands which you have to remember list unit files
this unit will show the running but this is not supported by sent to a7 so not
supported here but other system we supported operating systems will might
show this so you don’t have to worry about this command you can do systemctl
list unit files instead and now all the files which are enabled or disabled if
you just want to see the enabled ones you can use your knowledge of linux
commands use grep enabled so here you can see just the enable ones if you want
to see the disabled ones you can do disabled so grab does it for us so we
don’t need a Journal command to do it so in any case
that can be done so these are the systemctl commands where you get to know
the status and you get to know as we get to start stop services disable them on
good when I build them on boot and so on so this is how the services are managed
in linux and this is how the processes are monitored you have to go through
this hands-on again and again in order to get very good confidence on my the
workings so this brings us to the end of this session if you have any queries do
comment below we’ll reach out to you immediately also do subscribe to our
channel so that you don’t miss any of the upcoming videos thank you