Linux Tutorial for Beginners | What is Linux | Linux Administration Tutorial | Intellipaat


hey guys welcome to this session by
Intellipaat currently the Linux kernel has 20 million lines of code and this is the
smallest it has ever been and Linux is one of the biggest open-source projects
in the world and you would have come across this programming language quite
often which is the C programming language and 95% of Linux is written
using C also guys before moving on with this session please subscribe to our
channel so that you don’t miss our upcoming videos now let’s take a quick
glance at the agenda to start off with will learn what is Linux and about its
kernel after that we’ll look at the basic Linux commands moving on we’ll
look into files editors and file permissions after that we’ll look at
shell scripting and also looping and conditional statements moving on we’ll
look at more advanced Linux commands and finally we look into networking in Linux
also guys if you want to do an end-to-end certification training on
Linux Intellipaat provides a complete Linux certification training and those
details are available in the description now without any further delays let us
begin with this session so first let’s get started with
introduction to Linux Linux is a uniqe like operating system developed by
Linus Torvalds and thousands of open-source contributors so what does
unix-like operating system mean so there was this UNIX operating system even
before Linux was existing after that Linus Torvalds came up with an idea of
creating a open-source distribution of Unix
which is now called as Linux but right now Linux is more popular than Unix
but the base of any Linux operating system is Unix because it follows the
same architecture of shell and kernel and other applications
so now Linus Torvalds is the main contributor for this large open source
project Linux but there are other contributor contributors as well the
Linus Torvalds started of this project but later on ask this is an open source
project anyone could contribute to it so like that there were eleven thousand
four hundred and thirteen different changes by individual contributors so
this was after version 2.6 before that still there were a lot of contributions
after that there were again a large number of contributions even from
companies like Red Hat Red Hat is one of the most popular Linux distribution
company so Linux operating system distribution company they have both
community versions and they have paid versions so Intel is their normal is
their IBM is their there are a lot of companies and they’ve all made
contributions to the kernel moving on so Linux is an operating system it is
reliable and secure than other operating systems also it is completely open
source so open source in the sense you can take
the basic Linux operating system and create your own operating system out of
it repeat so so it is completely open source this basically means you can take
the base of a Linux operating system lets operating system
structure and create your own operating system using
that so it was launched by Lannister walls in the year 1991 on 17th September
so it is reliable insecure than others this comparison we’ll do right now
because right now I am using and Windows operating system to show you this
particular presentation so the most common usage of any operating system is
obviously Windows because it comes in built in a lot of laptops a lot of PCs
and a lot of CPUs because Windows is the most popular the most easier operating
system and also it has a name for it for personal computers because you can play
a lot of games in that Linux is not that much compatible with games but
coming to the IT sector coming to the development part Linux is preferred than
windows ok guys a quick info if you want to do an end-to-end Linux training Intellipaat provides a complete Linux certification training and those details
are available in the description so one more reason for learning Linux is Linux
is everywhere so any operating system you take will have some kind of a Linux
system within that so even in Windows you have command prompt in Mac OS again
you have terminal even in other Linux GUI is currently like Cent OS , Cent
OS Red Hat GUI then there is Ubantu gui GUI I in all of those graphical user
interfaces still you have terminal emulators so normally the Linux system
might be an command line interface but right now you have GUI based Linux
operating systems as well but currently you might have a phone in your hand you
might be watching this video in your phone or your phone might be on your
table but every one of your family member right now will have a smartphone
maybe not but right now any smartphone which is running Android on it has Linux
running on it because the Android operating system is built using Linux
principles it’s built on Linux the Android sorry the Android operating
system is basically Linux and you can see 85% of all
our phones or based on Linux that means there are iPhones there are windows
operating system phones there are other operating systems which are again a
subset of Android which comes under Linux and this is one of the reason
second reason is your car uses Linux especially self-driving cars not just
self-driving cars there are cars with inbuilt interfaces which have multiple
operations you can basically click on a button and the window wiper will start
so these structures certainly these algorithms or these these
microcontroller systems are again running in Linux even self-driving cars
need Linux to run them so why because Linux is faster it’s secure it’s
reliable than other operating systems and one more again refrigerators also
have Linux running in them so cook em so coming to why Linux is so popular and
you can I would have told you cars using Linux your smartphones or on Linux even
your refrigerators use Linux there are so many other possibilities your micro
microwave ovens and there are so many devices which might be using Linux so
now let us look at the supercomputers so you might be thinking okay so they’re on
Linux but why not Windows why shouldn’t I keep Windows and use the Windows
operating system to do all that so here comes the fact so you can see here that
sorry so you can see here before 2003 or 2004 UNIX was dominating the
supercomputer market and even there was some bsd there was some Mac operating
systems there was some Windows operating systems running on supercomputers but
right now in 2020 the top 500 supercomputers existing in the world are
running on Linux operating system you can see the entire market is right now
captured by Linux so why all supercomputers need Linux is because
Linux is lightweight Linux is fast Linux is secure Linux is reliable so coming to
the fact so if supercomputers are running Linux
and they are successful using Linux why not your PC why not your desktop so
basically it’s not a bad practice to use all other operating systems but coming
to the development part Linux is more preferred by developers it’s not my
personal opinion but Linux is more preferred by developers but if you’re
building an application on the.net framework obviously you need Windows or
you can emulate it on Linux operating system as well you can learn run of
Windows virtual machine or Linux so choosing an operating system is you wish
it’s for what kind of a need you need that operating system but right now we
have come to learn Linux let us look at more more data about this Linux so right
now let’s compare between Windows and Linux so this is one of the main
questions asked what is the difference between Windows and Linux so this you
should understand very well first Windows Server you need to purchase the
license windows is not free windows is not open source if you’re running
Windows so if I’m running Windows currently my windows should be licensed
my Windows is licensed if it is not licensed that means you’re it’s a
pirated version of that operating system next Linux is free it is open-source
operating system there are paid operating systems as well in Linux but
so cent OS is free Ubuntu is free so you can download them and install them for
free and then not many customization options because like Windows releases
few operating systems in few years like let’s say right now we have Windows 10
maybe in a couple of years or the next year we might get a Windows 11 or 12 but
you cannot customize it a lot but in Linux there are so many different
distributions even let’s say Ubuntu there are so many different versions in
Ubuntu then there is sent OS then there is Federer that we’ll look at later we
look at the various distributions but this is what is available there are so
many Linux distributions and you can choose one according to your needs and
then Windows is vulnerable to viruses and malware threats
a powerful antivirus software is a need so in Windows without an anti-virus
software if you are trying to download something from the internet I’m pretty
sure you will catch up a malware in your system because Windows operating system
is quite weak in the security aspect it still has Windows Defender but still
Windows Defender is not equal to a full-time dedicated antivirus software
which basically watches all the time for malwares it detects and tries to delete
it so that’s why Windows is a no-no for downloading things without antivirus but
in basically in Linux it’s more secure than Windows and the kernel is
built as such viruses cannot be easily broken so for an hacker to create a code
which will break the Linux system it takes a lot of practice the code should
be very efficient so that it breaks the Linux system so these are the
differences between Windows and Linux and before Windows was ms-dos which was
again a command-line interface and then there’s Linux again it was a
command-line interface but then later on or operating systems got evolved windows
got its GUI now right now Linux also has its GUI there are various types of GUI’s
so now let us look at the different Linux distributions you can go for
coming here then you can see Debian you can see fedora you can see Ubantu
can see Cent OS you can see the Red Hat and you can see SUSE so there are still
a lot of Linux distributions but I’m just putting up some popular
distributions you debian fedora Ubuntu and all so CentOS is the operating
system which you are going to use throughout this Linux course so will not
be using any other operating systems will be using CentOS CentOS is
basically the community version of the Red Hat on price Linux and cent OS has
all the features of any other Linux distribution there is also Kali Linux
there is there is so many varieties there are so many distributions and
relax so you will have to go ahead and check for what exact
purpose is this particular distribution better for and choose your Linux
distribution accordingly but most probably accept the package managers the
commands the Linux basically Linux commands the basic Unix commands are
going to be the same in every single Linux distribution so that it’s pretty
easy to move from one distribution to another so basically if I am currently
working on CentOS i can easily adapt to Ubantu so it’s like that so this is
the introduction to Linux okay guys a quick info if you want to do
an end-to-end Linux training Intellipaat provides a complete Linux
certification training and those details are available in the description basics
of shell now let us get into it so first we’ll be looking at the Linux
architecture so the Linux architecture in the sense it is not an architecture
which is built using hardware so the hardware part is what you mean by the
laptops hardware or the CPU so that is the middle part over here hardware so
hardware’s just cannot contact with the users directly so let’s say if you just
have a motherboard laying on your table you cannot communicate with it a
motherboard or an microprocessor or anything a complete set up is there and
you cannot basically you cannot communicate with it because there is no
common language between you and that CPU so to enable that there comes kernel
which is the middleman which basically contacts the hardware for us so we are
the users we try to utilize few utilities or few applications so let’s
consider the application is a calculator so the calculator as using the
calculator you want to do arithmetic operations so now let’s say this is the
calculator you are trying to use that application so now the calculator will
basically this application so there are a few commands within D so there are
some commands within the Linux and those commands are executed on an entity
called the shell so we will see what is shell but right now let’s consider the
architecture so you have the applications and you have this shell
after that shell basically execute your commands for
you it will basically communicate with the colonel for you
so as an end-user you see the shell you type in a command or you type in
something or you just click on an application the first instruction will
be given to the shell so the shell gets it so let’s say you want to copy a file
so you use the copy command so shell knows that you’re using a copy command
you’re trying to copy a file to another file so now this instructs the shell
instructs the Kernel basically it interprets the command and
it instructs the colonel to do this particular operation so colonel will
understand what exactly is the operation and it will push that to the hardware
which in a language switch the hardware can understand so an assembly language
or something like that or a microcontroller language so it sends it
to the hardware so the hardware will do the operations for you send it back to
the shell which where you can view that so as a user you just know you’ve typed
in the command but you do not know what happens inside and what comes back so
you type in a copy command and you get the results in fraction of a second and
you don’t see what exactly happens behind so you only see the monitor where
you type in the command you are typing the command on the shell which is an
interpreter for the colonel so the colonel gets the command and
knows what to do and it does those operations with the help of hardware and
then sends it back to the colonel and which is this will on your shell which
you can see I understand that the operation has successfully happened or
if there is an error you can see the error too so this is the Linux
architecture so moving on freely first I have to understand what is shell so I
shall interprets the commands you have entered using a keyboard and sends it to
the operating system to perform them so as we have discussed the Linux
architecture you have the shell and then you have the kernel so both these
entities shell and kernel or programs which are running on the operating
system the operating system is what making the shell and kernel possible so
kernel is trying to communicate with the hardware shell is the interface between
the kernel and the user so now what shell does is it interprets the commands
which as a user you give into the system using the keyboard or
the mouse so shell interprets that it understands what you’re trying to say
and it translates it and sends it to the operating system operating system in the
sense the kernel so it sends it to the kernel kernel now understands what
exactly should be happened it uses the hardware help to complete those
operations and once it is done it sends it back the shell so that you can view
it on your monitor so the basic explanation of shell is this you need to
understand this only then you can go ahead with your Linux training so we’ve
understood what exactly is shell moving ahead so nowadays yeah there is a lot of
graphical user interface based to the next systems so even st. OS is a
graphical user interface based system there is also CentOS server which is
a command-line interface but there is also a graphical user interface so like
Cent OS there’s Ubuntu there is Red Hat there is Debian and there is Kali Linux
there is a lot of Linux distributions which have GUI s– so in a graphical
operating system how can you basically communicate with the kernel with the use
of a shell so to emulate the purpose of a server to emulate the purpose of the
command-line interface all the GUI based Linux distributions have a terminal
within them a terminal is basically an emulator or a duplicate of a
command-line interface so if you click on the terminal I think most of you
would have seen this at least once if you open the terminal in your GUI base
to the next system you will see a terminal like this so there you will
have your username at localhost or any name any of your systems name can be
given here and then you have this dollar symbol and here you will have to enter
your commands still you can see I have entered the command called PWD which
means present working directory this shows the present working directory and
currently the directory is slash home slash intellipaat so it’s in the
directory Intellipaat so that’s what you’re showing over here so this is the
emulated version of a command-line interface so you can see here a terminal
which we see in the GUI server emulates a command-line interface in Linux server
terminal emulators are were commonly used now due to GUI
operating systems like Mac or Windows or Ubuntu so even in Windows they have a
command prompt even in Mac we have a terminal even in Ubuntu or ascent we
have a terminal which emulates or duplicates the purpose of a command-line
interface server so now coming to table shells we saw what is a shell and how
does the emulator official looks like in a GUI based system now we’ll be looking
at the top shells in Linux so there is not just one Linux as I told you Linux
is an open source system so obviously there are a lot of contributors who
creates different types of shells so the most common the most so basically a
default or shell you can say is bash that is life the name the elaboration of
bash is born again shell is a default shell in a lot of Linux distributions so
born again shell is the default one and even in CentOS and even in your went
to in a lot of different Linux Distributions- is the default one you can
further install other shells also it is your version and then there is Z hesed
which is basically Z shell and it is similar to bash or an extended version
of it so basically as I told you they take the Linux operating system and
create another Linux operating system which has better features so like that
they they took bash and made it better or added few features like sharing your
command history across multiple terminals so let’s say there are four
different users using the same Linux operating system within different user
names so you can share your command history to another user so this is one
of the features there are so many useful features in Z shell this is one of the
useful features in V shell so that’s what I want to share with you so going
ahead there is fish-friendly an interactive
shell so it is again an extended version of the common shell which is bash so it
has great features like auto completion of commands so fish is an amazing shell
so fish has this ability to autocomplete your command so let’s say you’re typing
in grep and command is going on going on so you
don’t want you do not want type all of that so if there is a command grab if
you just type gr and hit tab you will get it auto-completed so it is like
intellisense so it is like an ide with intelligence so you can use fish for
that and then tcsh then X seashell is an extended version of seashell so there is
another shell basically see SH or the seashell basically the seashell is
written mostly on the C programming language that is why it is called as
seashell and tcsh is again an extender version of the Cecil
they’ve taken Cecil and added more capabilities to it so the plus of tcsh
it is scripting language because it will be similar for the users who already
have experience in C programming so that’s the benefit of tcsh if you
already have a good experience with c programming if you know how to write
code in in c programming so then you will find shell scripting pretty easy in
tcsh because it might have the same method of writing so that’s what they’re
telling over here there are still so many shells you can just do a simple
google surgeon getting over what more multiple shells but these are the top
shells and this is the most popular shell so that’s why i’m showing them
here so going ahead so that’s this is the command which i executed in the
previous previous window which I showed you while showing the GUI based
terminals so a simple command to interact with the shell this command
below provides the present working directory so I wanted to show an example
of how you interact with the shell so basically if you type in PWD and you are
interacting with the shell when you hit Enter the shell understands that you are
entering in in a command first it validates the command whether this
particular command is valid in this Linux distribution PWD is the valid
command then it further pushes it into kernel kernel gets it in and pushes
basically execute the command with the help of the hardware provided and then
it gives back the result of the shell and shell displace it to you so that you
can view it so this is one of the example which I wanted to show you the
kernel okay so first a linux kernel is a unix-like operating system kernel so
again as Linux is the unix-like operating system obviously the kernel of
Linux will be a unix-like kernel so it is a computer program which is the core
interface which connects the hardware components to the software processes so
the software processes which you are trying to establish or trying to
interpret as basically you are typing in the command on the shell and hitting
Enter so you will know this part basically you
will know the application part where you are typing in the command and then you
do not know what happens in the back it just you get the result so what happens
is whenever you type in a command you have the kernel in the middle a
kernel is basically a very huge program very it’s a very huge program right now
I think it’s standing up at two million lines of code so it is a very
complicated program and so a kernel assets complicated it is also that
helpful so a kernel is the main interconnection between the software
application or the software processes on the hardware components so let’s say if
you are trying to find out how much RAM your system is currently using so you
cannot directly go and check the ram in your system you need a process running
in the background which basically connects to the hardware components and
checks how much ram is being used and sends that information back to you so
that is what the kernel does so kernel does all kinds of operations that we’ll
see now so the top operations performed by a kernel first resource management
and then memory management and then device management and finally system
calls okay now let us get a brief about each of those operations first Resource
Management so kernel decides which process gets a resource for an operation
so let’s say you are running multiple processes parallely saying that multiple
processes two processes need the same resource for an operation so right now
the kernel will decide which operation should use that resource
first or which should you second because it should not end up in a
deadlock situation so to avoid that Colonel performs an operation which
basically chooses which exactly needs the resource right now or it may delay
the process of execution so it might give it to a process which takes lesser
time first and then it gives it to a process which takes a longer time so the
resource management there are varieties but this is one of the main operations
which the kernel does second one is memory management memory management is
very important for any server for any computer even in your Windows system you
have 1 TB of space and even then memory management is very important because
memory management is taken care by your system your operating system windows and
it takes care of it well so like that kernel takes care of memory management
as well kernel has complete access to the system memory and must efficiently
manage it and a lot of memory access to process so why do you need memory
exactly is memory is not for storing content memory is to run processes
efficiently and effectively so the kernel should know how much memory
should be allocated to each processes so that your system is not completely taken
away of free memory so let’s say you have 100 MB of memory and there are 10
processes your kernel should decide how much memory does each process deserve to
use so it should provide that efficiently and the device management so
device management it’s pretty common in every single operating system so
basically if you are using a Windows system if you just enter the pen drive
you will be seeing that in your my computer or this PC software so like
that device management is also taken care by kernel so if we connect devices
as a printer or a pen drive so the kernel will detect it and the system
will establish connections with the peripherals so if I connect in a
pendrive so this particular system my operating system should detect whether I
have connected a pendrive or not but that’s not detect then there is no use
of you USB port in your computer so the kernel will detect it and there is a
separate directory in kernel which is known as /dev de B so
that particular directory is especially maintained for device management so any
device entering into this particular Linux operating system or any Linux
operating system will have a separate directory for them in the divet so if I
enter pen drive that pendrive will have a separate directory within that /dev
directory so the next kernel also takes care of device management and finally
system calls system calls this is one of the important concepts and this is an
interface between a process and the operating system when the process does
not have permissions to access a resource a system call provides it
without the process accessing the resource directly so basically let’s say
you are running a process but you’ve not given the processing of permissions to
use a particular resource so you can use system calls for that process you can
embed system calls in your shell script or in your code so that when that
particular system call is used your process will be given access to that
resource indirectly using system calls so that is the purpose of system calls
itself to not stop the process from running it does not interrupt your
execution it helps your execution to complete as fast as possible for that
you can use system calls and also you can use system calls to basically do
more operations on the operating system level so let’s say you want to abort a
particular process immediately you can use a system call for that so there are
various system calls are these are the four important operations performed by a
kernel so we’ll be saying this later in this course so you have to just assume
that kernel is the you don’t need to assume actually you’ll have to
understand that kernel is the main component of any Linux distribution and
kernel manages all of the top operations of a Linux distribution so right now I
think we can get started with Linux itself so first we’ll be looking at some
basic Linux commands so that we can get started with Linux easily so these are
for understanding how exactly Linux works so first we look at some basic
commands moving ahead okay so first we’ll look at these commands
command and their tasks so PWD shows the present working directory who are my
shows the user name date shows the date time and then so there are still more
commands who make directory cat move so now let us start from the first PWD and
try executing these so let me open so I have my virtual machine opened so I
opened it but once it’s open we can start off with the process I’ll open
terminal terminal as I told you terminals are emulating shells they’re
emulators of shells where you can type in commands and it works like a
command-line interface so so let’s get started with that once it comes yeah so
now I’ll open terminal yes I’ll just click here ok so since it’s running and
yeah so first was PWD if I type this in you can see slash home slash in telepath
so you can see that over here so this is my present working directory
so under Intel apart right now I’m working so that’s why I just showing it
as the present working directory so let’s say I go back and now if I do a
PWD it shows home because I am in the home directory so that’s how this works
that’s how PWD works and it’s one of the important comments you’ll have to
remember it’s pretty simple so let’s say you have navigated into multiple
directories you exactly do not know there so you can just do a PWD and check
that for yourself now next one is Who am I so Who am I is again a simple command
but it shows you which in user name have you used to log in so let’s say you have
PI different users now you can basically you can log into this particular central
system from multiple users as multiple users so if you might have forward which
user you are using as you can just type in this command and it will give you the
user name and then and then there is date history
so again I’m going to type in date it shows you the date Friday January 31 and
it shows the time and it shows a year ok so we have seen that so this is eastern
side of time so that’s what it’s showing so next we have history we’ll see
history later then we have copy the abloom ooh we have clear man exit and
cat move alias echo LS so echo will see later LS will see later because we will
do these commands in detail we learn about these commands in detail right now
I’ll just start off with the basic commands so first so
let me clear this so right now you have cleared it and you don’t know you want
to see what and all commands you have used still so that you can take out the
command and use it again so for that you have this command called history which
type in history you can see all the commands which you have executed
previously so you have history clear date Who am I and PWD play WT and these
were previously entered so it also shows the previous history so this is why you
need this tree if you would have forward any command you can just type in history
and copy that and paste it within this and so let’s say I have forward in this
so I will just copy this and paste it over here so this is what history and
then one more thing is touch touch and one dot txt so the file got created but
it won’t open so you can see the file got created over there so now there are
various text editors we learn about text editors as well so right now I’ll just
open it Nano dot txt and hello world to save it
is ctrl o enter ctrl X so I’ve saved the file and the file is ready right now so
let’s say I want to see the contents of the file without opening the file so how
can you do that so it’s pretty simple you can use the command cat CID and type
in the file name so cat one dot txt and you can see the typed in the files
contents over here so this is why you can use cat and another thing so let me
create another file – dot txt and right now you have a one dot txt Anna – raagh
txt file so you want to copy the contents of one dot txt – 2 dot txt you
use a copy command which is CP then source and destination so once they’ve
entered so now if I do a cat or 2 dot txt you can see hello world inside that
I do not open those files I just use the command CP which copied the contents of
the first file into the second file so you can use this also you can do one
more thing that is move 1 dot txt – p dot txt so right now there is a 3 dot
txt file but there is no 1 dot txt file because I moved the contents of one dot
txt as well as the file I moved it into 3 dot txt so right now if I do a cat of
the file 3 dot txt you will see the same content inside that again I can move it
back by use in this command so this is the move
command you can basically move pile within a directory or you can also move
a file outside of a directory so let’s say move one dot txt slash home slash
one dot txt so I want to move it to a file which is not in this directory so
it’s showing permission denied cannot move so let me add a pseudo in front and
check so I’ve given the permission so now you can see here the one dot X T
file is not there going back so I’m in the home they retreat and here you can
see the one dot txt file and if I do a cat it should have the same content
because I just moved the file here I did not just move the file also I move to
your contents of that file so guys we’ve seen the basic Linux commands which are
needed to start with Linux any Linux distribution those commands are the same
so right now we are going to see another command which is called echo and it was
one of the most important commands which you have to know so moving ahead
so first what exactly is echo echo is used to display a line of text or string
by passing it as an argument so now you can see this example over here
echo in telepath it basically printed that over here so again you can see over
here echo so sorry for that again you can see over here echo display text
display line of text so this is what it does this plays a line of text and there
are some descriptions trailing newline or so these are some examples which will
be doing so right now we just remember this it is basically a command to
display a line of text restraint so now there are some options you can use these
options while using echo so echo and if you use a minus n it gives you the
output without a newline it adds that particular oh sorry it adds that
particular option to the same line itself so first let me clear this just a
second an option two so I’ll just make it huge so that it’s
clearly visible okay so right now I assumed it so guys I wanted to say I Pro
so echo hello so you can see it has printed hello
so echo hello it can also sprint a complete line and then so you if you do
this hello – so as you told you it will not use a new
line it prints with the command line itself so this is one option of echo
then another option is – e this will allow usage of back backslash escapes so
there are some backslash escapes or there is B there’s n t b so b removes
the space between text and n prints the text in a new line then that’s a
horizontal tab does a vertical tab so let us execute these one by one so first
let me do this so if I type hello / I’m using / B so I don’t want space between
these two lines but if I do this it won’t work because /b is not escaped
over here coming back here and also I have targeted and wrong so even though
if I have typed in the slash correctly so again you can see the slash is not
there but B has been added so to escape this you can use the option – e hello
world so think I’m doing another mistake so
the thing is I think we’ll try with codes yeah so that’s what /b basically
again I did not put in quotes so it thought that that is again a part of the
string itself so right now I’ve used – E to escape the
particular option that is backslash B so now hello world in between that I used
slash B and it removed the space between hello world now one more thing is – /n /
end separates the words and prints them in separate lines so let’s say hello
world how are you so you can see that hello
world how are you so hello is in one line and after that I have a newline
world how is in one line then after that I have a new line then are you so this
is one and then you have two most commonly used ones which are / H + /
each so / t does a basically a horizontal tab / you can see here / t
that’s a horizontal tab / b does a vertical tab so going here / v
and now you can see that horizontal tab it left in eight spaces or a tab between
hello I am void and horizontal vertical tab is basically a new line but it will
be on the same line but it will be a line different so let’s see them with
both and now now these are slash tees now let’s see both of them with slash
B’s and now you can see the difference so here when we did hello world are you
here we used a slash t and here we use the slash way but right now I am using
in both the places and using slash me basically they’ll be in the same
position as the same line but they will be a line apart so this is how you use
these options so now I’ve also added some examples over here the same kind of
examples how are you and /v / t / b all these examples and one more thing i want
to do is show is you can do this with echo so now X I’m putting in a variable
and I’m just giving it some random number so now if I do a dollar X you can
print the variable so this is one of the most useful things about echo I’m going
back and you can do one more thing like if you do an LS you see all the
subdirectories of that particular tree you can also do that with echo thar so
you can see them but they will not be displayed in a colorful manner LS
actually differentiates between directories and files but echo cannot do
that it just prints what are the contents of that particular directory
going back what are the examples yeah there is one more example for expression
so let’s say I have already entered the value for x Acme enter a value for y
yeah so no echo dollar this is the format so now X and plus try this if it
works then it’s fine yeah so it’s 79 so it has added 23 and 56 so the problem is
if you do this dollar x plus dollar Y it will not print it it just prints the
content of X separately and Y separately but to do an arithmetic operation you
will have to put dollar friend and to paranthesis and in between
you will have to write in the our thematic competition so let’s say you
want to subtract them then you can go ahead and do it like this so this is how
you use the echo command and these are the basic examples of it so we’ve done
the hands-on for echo command so we’ve seen echo and other basic Linux
commands now we are going to see set and unset so set again is a command but
there are various types of doing it there are various commands to set a
variable and there is this unset command so if you have set already a variable as
a global variable or the local variable you can use the unset command to remove
that so now let’s get started first we learn what is set and unset
so first the set command is a built-in function in bash and few other cells
which you can use to define the values of system variables set it’s not
required to set a variable there are various ways to do it
so as I told you set is the command so in the back end that is the command
which will run so I did X is equal to a number in the last session or doing an
echo of it so when I did that it automatically took it as a variable so
that particular operation is a set operation set need not to be a command
to be used but that is the operation which happens whenever you are trying to
give a variable value so you cannot use the command export to create environment
variables so while you create environment variables you are using the
command export basically again that is a set operation export is another command
to set environment variables even though setting environment
variables and variables are similar the only differences environment variables
are for the complete system globally it is available but normally setting a
variable like X is equal to 23 or local or locally available there local
variables and finally the unset command the answered command is a built-in
function in bash which you can use to remove a variable which is set so if you
already set a variable using export then you can use the unset command to remove
them for going ahead we will see some options the first option is – be notify
of job domination immediately second one is – e exit immediately for command
exits with a non zero status then third one is job control will be enabled and
fourth option is pretty good so all export these are they stay
other options you can see these options over here you can use this set command
to turn off or on particular functions so all export in the sense if you are
not enabled this then you cannot use the export command if you have enabled this
then you can use the export and so we’ll see some examples first though you can
see hello one echo hello this is what we did in the last session so this is done
this is for local variable and this again the same thing this is a global
variable and yeah it could all Hollow one echo dollar X unset hello echo
dollar hello dollar X it’s only printing the value of x not hello because we
removed that variable and then again here hello one export hello we have made
hello into a global variable echo hollow is showing again we are entering another
bash I under the bash we are trying to do that but again we are getting the
value but in this particular example you can see we entered another shell but
under that shell you cannot see the value of hello because it’s a local
variable when you use export it becomes a global variable so now this is one way
of making a variable global and there is another way which is export X is equal
to two instead of providing hello equal to one then export hello you just put
expert hello equal to one so that will be more than enough and then you can see
this set plus oh this is where set command comes in so you can basically
stop or dot particular operations in your system so if you have installed so
there is a particular text editor called Emacs it might not be installed in the
fall you can install it later so even though if you have installed it you can
basically use it if it is – OH that means you cannot launch eMac if it is
plus / then you can launch Emacs so you can use the set command to stop and
start particular operations so that’s one of the useful examples so you can
see to do that set – oh all export if I do a set plus o it shows all the set
operations over here and you can see that it shows all export has become – OH
that means I cannot use the export and here it’s + o okay so we’ve seen that
now let’s go and do the same commands in the operating system so if we open it I
will enter the wrong password now I’ve entered it right ok so right now guys
let’s do some operations so we did this hello key so let me use
X itself so X equal to 45 so let me echo this so it’s showing the value now if
you end a bash because as I told you incent OS the default shell is bash and
if I use bash so now I’m inside another shell so you can see that if I do an LS
it’s showing the content but if I do an echo it does not show the value so
basically if this particular shell does not have the value for x so here I can
so let’s say I’m giving 76 and different doing an echo of X so it shows 76 but
you might think won’t this overwrite the value of my
already created X variable so to exit a bash shell
it’s basically exit for any shell else exit so if I do an exit it comes out so
now again if I do an echo of my I mean now it’s again shows 45 why it shows 45
because that particular X is equal to 76 or have set the variable X as 76 in the
bash which I launched recently but the variable X which was already available
which I already said had the value as 45 so I do not make my X variable global
when I first created it again I did not make it global when I again created it
inside the another shell so that each shells have their own values for X right
now because they are local so now how to make it do good so it’s pretty simple I
already have a variable called X so what I’m going to do is I’m going to use this
command export export X right now sorry I don’t know why I did LS but X for X
right now it made my X variable as global so right now I’ll do a dollar x
over here so you can see that my dollar X is 45 here now let me do bash and try
it over here and again it shows 45 because I’ve made my X variable global
it over red so basically I made my X variable global this made this
particular variables value the same in every single shell so you can launch
another shell over here but still the value of x will remain the same because
it is now a global variable with the same value throughout the entire system
now I’m clearing it sorry I’m exiting it so this is how we use
export one more way of using export is like this export y equal to 67 so now
this would have already become a global variable so other examples I wanted to
show are I’ve shown those three examples and then yeah I wanted to show set
command so I’ll clear this now set just I will enter set then you can see every
single function you can see every single variable which is set over here
so you can see columns 127 you can see every single value set over here mail
you can see the mails directory you can see you can see the old PW this was the
last time I used PW and the last time when I use PW this was it so now let’s
try this once again let’s do a new Peter WD and now let me type in the set
command now let’s go up and check the old PWD so now the oh the value of old
PWD should have been changed to the newly entered value of newly entered
value which is a Center going up you know I came to the top so things over
here login that should be here movies for columns final lists and then there
is no home home variable login name is in telepods home and not able to find
old yeah it’s over here again it’s the previous one not able to find variable
okay so that’s fine so set another option of setters so one
more thing I want to show is so you can see this so this was one of the
important commands you should know so let’s say you’ve done let’s say alias
and not alias or so you can see update a exclamation and I typed in just PW so it
already recognized PW means PWD and it shows the later
execution of it so let’s see easy just let go so it shows the execution of it
so if you have typed in a command which you don’t want to type in completely
again or you don’t want to search it in history and again type it you can
basically put xsplit exclamation and type in the first two letters of your
command and it will detect and show you the latest results of it so this is one
of the things then coming to set set let me type in oh sorry set plus oh and now
you can see all the operations over here so set plus keyboards at minus zero
monitor set plus notify and all all of these so basically you can I can do a
set minus 0 and all export so now if I do another so now you can see it would
have been changed to – oh so this particular option stopped this so let me
try so to understand this better the set command so let’s do this so there is
history over here so let me type in history and it shows the complete
history with the history command so let us try this
– oh sorry plus history so now let those two a plus Oh so I think now it would
have changed history where is it history is plus oh let’s try history
once again so it’s showing the complete set of everything so now let us stop it
once again so basically it disables but it does not stop it from working so
again you can see history the latest one so this is so no coming back to set I
think to understand said you can check the manual page so if you open it it’s
not showing the exact command but it’s showing some other things so you can see
Bosch echo enable eval execute like say it’s showing all of the commands in this
particular batch but it’s not considering set let me quit this now let
us do a man for export what exactly is exported so again it’s not showing that
it is a default command so now we’ve seen the export command and how to set a
variable now let us see how to unset it it’s pretty simple
so now echo dollar so it has a variable then
use the command unset and this type in X so now let me run this again so right
now you don’t have a variable so this particular variable X does not have a
value so now I have unset that variable so this is how you set it up and there
is one more command env so env is for setting environment variables so if you
type in env you can see the complete environment variables and you can see
that user name is in telepath and then you can see the user is in three
polygons and photos so I wanted to show something really relatable so that’s why
I wanted to show this and then there is the shell because as I told you the
default shell here is bin Bash it is bash actually so the location of Bash is
underpinned so that’s why it is showing the shell over here so this shows the
environment variables the set command basically shows the complete variables
inside this virtual machine or this particular operating system so the set
command shows the entire variables of this complete operating system but env
just shows the environment variables of this particular operating system so we
have seen these commands so the next command is expr or expression so let’s
see the basic definition of it so the command expr computes a given expression
and displays the output so the exp our command is used to calculate an
arithmetic expression which we have provided and it gives the output of it
so the below command which is exp are – – version shows whether we experice
installed in your system or not normally it will be already installed in your
system while installing any Linux distribution because the experience one
of the most common commands so check it if you want to and if it is not
installed then you can install it normally and then I checked this in the
man page so these are the operations which exp R is capable of there are
still more operations but these are the most common operations so you can see
argument 1 and then argument – then R so basically argument 1 slash is basically
our operation and you can see if it is either null or
null not zero other ways argument too so it shows argument 1 if it is neither
null or zero if argument 1 is nothing or if it is 0 then it considers argument 1
it cannot really go to argument 2 and then this is a non command and then
argument 1 less than or argument – if argument 1 is lesser than argument 2 it
will give a number 1 if not we’ll deliver a number 0 so these are some
again some logical operations then coming to arithmetic operations plus
minus you can see I added Matic some arithmetic difference product quotient
and remainder so moving ahead and these are some examples so first you can see
an addition second you can see a subtraction then multiplication division
and you can see exp or length as well you can check the length of a string
then you can see some logical operations which I did in the right side so let us
do these in the shell so let’s start off with it so expr let me do the first
command so I’m going to check whether the experienced all so yeah it does
install it should be installed so now exp r1 plus 2 so there should be
a space in between only then it works so yes otherwise it considers it has a
single argument so exp r1 plus 2 it gives me this then 1
minus 2 gives me this 4 but one more thing you have to consider this while
doing an operation like multiplication or subtraction you should add the
backslash in front of it so let’s say backslash star I’m going to multiply 1
and 2 so only if you add a star in front of it gives that so let me change this
so now you can see it’s 8 so only if you give a backslash it will work if you
don’t do a backslash it will not work because the argument is wrong so now I
will do yeah so this is division and then you can see the coefficient 0
because it devices perfectly so I’ll just give a random number and you random
number here so it’s 16 so you can see the quotient also is shown and you can
also divide them it can be any big number so
it will not show the decimal point over here so it will show you a perfect
number so then we will do some logical operations expr 10 equals 10 so it is
equal to then it gives 1 if it is not it so if it is not it gives 0 then we can
see the or operation also alright one more thing I wanted to show is 10 less
than 11 okay sorry I forgot the backslash so now you can see it’s 1 so
you can see it’s 10 so let me make it small again it’s 10 so now if I make it
0 now you can see it’s 23 it’s this is what this operation does and then there
is greater than and then there is sorry there was greater than then there’s
greater than or equal to and so you can see this is how you can use expr there
is one more thing about expr is that you there are some certain so let me check
the main page there are some certain operations which you can do using the X
they are so this is where I got the list of what are the operations it does you
can also you run some regular expressions in that after giving
valuable names variable names so here you can see the length and strength so
you can calculate the length of a particular strength so now let me give a
string is equal to hello so now at exp odd length a so it shows the length of a
now I’ll do a dollar and print of it now it shows the length has 5 so when I gave
a just calculated the length of a when I gave dollar a calculated the length of
the string which the variable a has so this is these are the basic commands
which you have to remember while working with Linux so now add a file of shell
script using Java so the name of the header file header part of a shell
script is called shebang which the hash and exclamation marks together
so this is one of the most important things you have to know before starting
off with Linux because in Linux you do shell scripting so for shell scripting
this is one of the important things you’ll have to understand
so first hashtag and exclamation together so this represents which
interpreter or script should be interpreted with so using this shebang
header you can mention what is the interpreter so normally in this
particular operating system which is sent OS 8 so here bash is this shell so
you can just type in hash exclamation slash bin slash bash and then start
typing your shell script so that when you run the shell script the shell will
automatically understand this should be run in bash or if you put hash
exclamation slash bash slash CSH if you type in a different shell if the shell
is installed in your particular machine then it will use that shell to execute
your shell script so this is how it works
so the last one is bin slash bash is this not provider if it it often
considers bin slash as such so as such is the most basic format so normally if
you do not provide the header file for a shell script it automatically considers
it has a normal shell script and it uses the default shell and it uses that to
execute that shell script when you put that particular shell script shebang
header so hash exclamation slash bin slash bash in your script so that
particular kernel will understand that it should be executed in bash and it
will be executed so this is the use of shebang and coming down so this is a
small script or a small shell script so you can see the use of the shebang over
there it understands it is bash and echo this is a sample script SH using SH or
using bash there are various ways to run a particular script file I’ll show that
so this is the sample speed okay so this is a sample script let us go to our
system and run it all so okay so first you will have to create a file I’m going
to create a file Nano let me just type in 1 dot sh I’ve opened the file so hash
exclamation slash bin slash bash echo hello all
so this is going to my script fight I’m saving it I’ve saved
it so the first way of exiting this is using as such second way is using –
third way is pretty simple dot slash so for this you will have to be the root
user against another command not font so that is the basic way of doing it or you
can do on one more thing so let me do another file create another files so I’m
going to type and just echo hello and saving it
so now there is a wonder research and research file so if I do this it’s
showing hello even though I did not enter a shebang file because it is
stored in a format called dot SH and also I am running it using SH so
basically it assumes it as a shell file and it uses the shell to interpret it so
you don’t need to always mention the shebang header file but when there is
Sidney when there’s when it is a huge shell script then I suggest you to
insert it so that your particular shell script is considered as a shell script
because you might copy the shell script and use it in some other shell and at
that time without the shell header it will not know that it is a shell file so
that’s why you’ll have to use that so we look at various text editors the first
we’ll look at them there were some of the most commonly used text editors on
one of the most popular text editors so vim is actually lightweight and there
are a lot of benefits we’ll look at that later so then there’s one of the most
popular text editors then Emacs and then GNU Nano so I quite often use Nano I
don’t use them that much I like Nano better than them and there
is G edit so even G edit is a quite popular text editor which is basically G
white text editor BIM in Nano or the command line text editors where you can
type in the terminal itself so now looking at these we look at the most
popular text editors them and Emacs are the most popular text editors use so
this is basically based on personal opinion you might prefer a particular
text editor for its usability so I use now because it’s pretty easy to create
save and close the files and it’s pretty easy to type in files also so in them
again you’ll have to look at the functionality you will have to work with
it if you are fine with it then you can go ahead with them if not you can try
Emacs as well so these are the two most popular text editors now this is how
them will look so them basically is a command line tool as it told you and you
can see that it just opens a window whether it is the command in the command
line itself and it shows something so first to start off typing you
have to enter I which is insert then you can start typing and then coming to
Emacs you will have to install Emacs and I need to when you open Emacs it will be
open the as an application so Emacs it’s not a command-line tool it is an
application so again these two are the most popular but still people use Nano G
edit and still there are a lot of text editors they be use all of these text
editors – if it is comfortable for them so next we look at some things about
them so them stands for an improvised version of the VI text editor so
basically them is V I improved that’s it so VI improved a slim it’s the
improvised version of the VI text editor which was commonly available in a lot of
not even in a lot of in or every Linux distribution which is available so right
now why is film popular so first it’s light right it’s easy to open it’s easy
to work with it and it does not take a lot of space second it’s very easy to
open an identify as I told you third if you boot on that system will miss most
possibly installed that’s what I was telling you because women’s one of the
most common text editors so that in most of the Linux distributions so even we
installed CentOS I’m pretty sure incentivize them will all be be
installed so in most of the Linux distributions women will already be
installed in it so that you don’t need to go ahead and install it once again
and start using it so that’s why we miss popular so moving ahead these are the
BIM modes first is the command mode in the command mode you will not be able to
type but you’ll be able to enter commands so you can see you we can enter
commands for copy paste delete or replace and then in the insert mode once
you press I in the command mode you your command mode will be shifted to insert
mode then you can start typing in and then once it’s done you can just press
the Escape key which will come out of the insert mode and then command line
mode this is also a command mode so again this is command mode but every
command you provide should start with a colon
so to quit its : q to save and quit its : WQ so this is what happens and fourth
is visual mode visually like text and run commands on selected
sections to shift from command to which will type you allow to press V so once
you press me you can visually select and edit things like that so these are the
four different bi m modes then modes so you’ll have to remember this so now
let’s create a file so just first let us look at the peabody then go ahead to our
the next machine and start working with it so i’ve created a file and pressed i
and entered some text as hello world and then just escaped and you can see in the
bottom corner : WQ and hit enter so the file would have got saved
so these are some options inside the boom command mode is for inserting
capital OS insert text on the previous line small OS in the insert text on the
next line ie sup in text after the cursor capital a is up in text at the
end of the line so these are some options there are still many many
options you can see here creating and saving a file so first let us go to the
in the next machine so this is my machine so I opened it next I’ll have to
open the terminal and first I’ll make this bigger yes
so right now if I type in them so you can see Wilma is already installed in my
system then P I am through so that solid showing them is already installed so now
I get back so : q I got that so Emacs the thing new Macs will not be installed
Emacs is not installed and then nano so Nano is installed and I mostly preferred
Nano because it’s pretty easy for me because mostly I’m not going to edit
anything I’ll be typing in and then I’ll save it and close it off so now it’s
pretty simple it’s just three different controls we’ll have to remember to
navigate them ISM has a lot of commands a lot of different modes you’ll have to
remember all that to work with it so first please create a file with web so
to create a file with name first enter them and then enter the file name so
let’s say one dot txt so I have created the file but so now I will not be able
to so now you can see I am able to type in but you can see there is nothing over
here so I’m going to press I and you can see the insert
word over there so this means I’m in the insert mode so endangered mode I will be
able to type so once I hit escape now I’ll not be able to die I’ll be given
here so if I hit Q what happened what will happen is it will just quit it
won’t save the file but if I hit W it basically means to write and quit it
will save and then quit so done so now if you open the file once again now you
can see it is created and saved now let’s hit V now it’s visual mode so in
visual mode again you should learn some things and see I’m selecting everything
and I’m able to change it accordingly so basically visual mode is to select so
let’s say select a particular text or select a particular line and then use
that line on that line you can change it but in insert mode basically you cannot
do that in insert mode so you can see I’m trying to do that exact same thing
so you cannot do that but in visual mode you can do that so you can see I can do
that in visual mode but not in insert mode so now I’m saving it once again so
if I do work that out quando txt so this is the latest save once so going back to
so we’ve done the first part we saw or the various text editors and we also saw
what is women how to create a file and say we tell them so these are some other
options we also saw the visual mode and the command mode command mode does not
show the name command over there but you can type in commands like what I did : q
: WQ all those commands you can type in so ownership of Linux file so when you
create a file basically in a Linux system you have three types of owners
one is the user which right now in my Linux system is Intel apart telepods
it’s a user and then there is groups groups are basically you can create a
group and add in some users and give them some so that give that group some
permission so all that users will have only those permissions and then finally
others in processes so processes in the sense when a process is running that
process might require a particular resource to work on a
particular file to use for that particular process so that process
should be given permission to use that particular file so these are the three
different types of owners so you can see the purpose of users and groups of our
access and permissions so let’s say if there are no users and groups then
anyone can log into your system and anyone can use any file access any file
even if you’re the owner anymore any like if I am the owner of a file you
can log into the system and you can change the contents of that file which
is not good for me because it’s my file and I want that content so for that you
have users and groups so if my user logs in and creates that file only my user
will be given owner permissions only I can edit that file and you cannot edit
it because you’re a different user now every user has their own directory every
user have their own directory usually the slash home slash user name so under
slash home you will have a directory call with your user name in our
particular virtual machine you saw that slash home slash intelli pad in telly
pad is the user which we created so basically this particular user has a
directory under their name and then even processes need permission to access
specific files and locations yes so while some process is running
obviously that process will have the permission to use a particular file or
login to a pod or go into a particular location and access a file so these are
the three different types of owners now what is the difference between a user
and a group so first user owner of the file and then so these are not the
differences these are basically the characteristics of users and groups so
first of all let us see the users so users again the owner of the file and
then system uses user IDs to manage juices so let’s say there are a hundred
different users and in that ten people have the same name so the system will
not understand that if all of them have the same name it will think they are all
the same user so to differentiate between the users the system has its own
identity so system has its own identity scheme which users user IDs so every
user will have their own unique user ID whenever that particularly user
working on the system the system will check for the user idea I didn’t know
who exactly is working on the system right now and then system identifies
daemon processors as users so daemon processes or background processes and
system will assume that a bagging process is running because a user has
induced it because mostly this the user who is inducing it only if user switches
onto the system only then those background processes will start to run
so now groups groups contains two or more users so all users in the group
have same permissions as given to the group so let’s say you’ve created a
group or let’s now not assume group so let’s say now you have ten users in that
file users or database admins now all of the database admins need the same kind
of permissions so instead of providing every single user the same permissions
you can create a group ID these five users to that particular group and give
that group those permissions so once you give that group that permissions it will
be applied to all the users under that particular group so that is why groups
are used and then finally groups are identified by GID like how users are
identified by user IDs groups are identified by group IDs now others and
processes a process can open a file and even read or write in a file yeah it can
if provided with enough permissions and if a process is using a file and we
delete it it does not get deleted so what is what does this sentence exactly
means let me explain it to you so while you are using a while a process
is running and it is using a particular file so while that process is running
you’re basically deleting that file you would see that that file is not
available in the system but the file will not be deleted it will be just
deleted are blatantly from the top but from the memory it will not be erased
only when the process is complete and the result is successful or if it is
failed only when the process is complete that particular file will be deleted
from the memory because if you delete that file while that process is
happening and you stop that process that is not beneficial for the process as
well as the user so this is what happens while a process is using a file and
finally there are three types of user IDs effective user IDs real user IDs on
se nice so we look at these user IDs in
detail okay so first effective you ready so an effective UID and a real user UID
is basically the same once you log into the system because in telepods the user
which I created and the root are the same person and the UID will be the same
because I’m logged into the same system and I’m using both the superuser
privileges and the normal user privileges that is super user in the
sense when I used a sudo su or su the minuses to become the root and in most
of the time while you are running a process affecting view ID is used so
effectively you ID in the sense you’re normal UID of the user so the system
will understand which user is exactly trying to access this particular process
or which shape user is attempting this process using the effective UID and the
real user UID comes into play only when you are shifting the user from your
normal user to the root user so while you are doing that it is check for the
UID it will check for whether the effective
UID and the real use of UID is the same or not if it is the same then it will
accept and move ahead because sometimes using their normally without super user
privileges when you are trying to execute something it might fail and ask
for the it might say it does not allow because superuser privileges are not
provided but once you use pseudo in front of it and provide the password for
it it will work so how this basically works is while you’re not only using it
it should take the effective UID and it’ll assume you do not have those
permissions but once you provided pseudo and the password it will assume that
your root and even though you are root you will have the same UID because
you’re just shifting from the normal user to the root user and finally saved
user UID is basically once once the system knows it’s the same user and then
it will be automatically saved and then once you hit sudo su and the password it
will automatically change the user privileges so that’s what save user
saved user UID is the first time it might ask you that are you same user
please enter the password but once you’ve done that after that it will not
ask it directly ask for the password and you can Moorhead so these are processes
moving ahead now create a user and groups so that we can
understand better so let me open my system so first if you log into it and
so right now Internet is not connected I don’t know why I need in general but
still I’ll connect it I okay so first you can see this and so this is the user
which I am logged in right now and you can see this w it’s the same thing and
clear okay so right now I’m logged in as in telepath there is currently only one
user because going back under form there is only one particular user which is in
telepath because we’ve not created any other user
so now what we are going to do is we are going to create another user to a
company into the path let’s create in telepods number two Intel apart to and
to create that user it’s pretty simple it’s sudo user add user name so let’s go
back to the terminal sudo user ID and username into the part two and and the
administrator password now it is done so now if you go back to home now you can
see there are two different folders Intel apart and Intel apart – because
you have created on new user so we’ve created and as the user right now and
that’s fine now let me enter into until if I – for
permission derived – let me do a sudo and still not able to enter into it thing will have to login before entering
trying to enter it okay that’s fine so right now our second step was to
create a group so again it’s the same process to create a group pseudo group
add and group name I’m going to name it as Group one so I’ve created a group so
you can already see there are there is a group called intel afire and there is a
Google group called V and V I’ve created a group right now so one more thing so
right now try let’s try to do something let’s try with file permissions we have
created a user and a group this is a via create so I just wanted to show that
first now let’s try one thing now going back
so first let’s try to cat /et see shadow so permission has been denied so going
to or PPD you can see here it won’t work but right now with a sudo cat so now you
can see it has displayed all the contents under it so why I wanted to
show is this is where permissions come in so you might be thinking how it
happens with sudo because I’ve done this a lot sometimes I do it normally
permission will be denied but then I’ll use sudo and hint at the password then
it will work you might be wondering why it is but basically it is just
permissions normally a user will not have permissions to view the contents of
an easy TC shadow folder but a super user or root user will have the
privileges to see that so that’s what happened over there so now one more
thing is how to get super user privileges
it’s pretty simple if it’s sudo and su or so you can see now it’s not asking
for the password so exit you can do sudo – s so both are the same sudo ICU and
sudo – s are the same so now we are logged in as the root user so now let us
try so now you can see I’m able to enter the
folder into the pipe – but as the user Intel apart I did not have permissions
to enter Intel if I – because it is a different user and that user has not
provided me permissions to access access his folder now I am the root user so now
you can see I can just type in cat et Cie shadow and I will be provided if
there isn’t yeah you can see this so I’m provided with the result so why I
am provided with the result is because I am the root user and the super user and
I have the privileges and permissions to do this let’s go back to the slides so
this is how it works now coming down so now root let’s look at the root and it
is the directory at the top of the hierarchy so we have a filesystem
hierarchy in Linux and root is the top of the hierarchy because root is the
first directory under root there are everything else in in a living system
root is the main directory under root there are so many directories which are
for so many different operations but root is the main directory which is at
the top of the hierarchy so it then has a root like structure and under it
containing multiple directories and files so it is the ground level for root
of the ground level and under root there are so many different branches going
under which forms different file structures so that is how it got the
name root and this is how this is the symbol of food a slash a backslash is
the symbol of root coming down so guys this is how the file structure will be
so you can see this is a top folder root and under root you will see all these
major folders you can see all these major folders over here so when etc’ has
been USR VAR dev home live MNT opt proc and root so we’ll discuss them in
detail right now we are understanding file permissions and right now we are
looking at the file structure the file hierarchy of a Linux distribution system
so here we have root at the top and under root we have other sub directories
now let us look at these directories one by
first /bin which is essential user command binaries so you can see every
single command so you can see gods we can see yeah copy did a go grab hostname
kill less LS make directory mount move nano all of these commands are under bin
every single command is under bin that is why we use slash bin slash bash even
Basha standard min so you can see bash so we use bash to run shell scripts and
bin is one of the most important directories which is required so that
you can run commands so without these commands basically you cannot do
anything else in the Linux system and then et Cie configuration files for the
system you have crontab you have the host names you have the network’s you
have the passwords here given the passwords are stored you even the time
zones are available here the services running or available here you can see
every single configuration files in under the EDC folder and then we the
s-pen essential system binaries again this is for the user binaries user
command binaries this is as bin is for system binaries so you can see fdisk
fsck Getti halt if config reboot make swap make
filesystem so these are all system based commands so make file system is for
let’s say when you mount a particular file storage but that storage does not
have a file system in it it does not support the Linux file system then you
can use the mkfs command to install a Linux file system
within that storage and then you can use reboot to reboot the system
and halt – halt every processes if config to view the system’s
configurations and IP addresses and MAC addresses so that is what s – and then
us are basically its user read-only user applications support data and binaries
so under us and the user you can see AB in most user commands under that you see
include standard include files for C code and library obj pin live files for
coding packages these are basically for the user these are meant for the user
even the man pages are under user because a user is going to look for the
man pages because if I don’t know a command so let’s say I
don’t know what fingers so I’ll just type in man ping and the man pages are
actually stored under the USR directory under us are the store under shared
under said it is stored in a man so from there it will be fetched and it will be
given to me so that’s what starting so you can see you static data shadow will
across all architectures so you can share this particular data across every
single Linux distribution and it will not stop your functionality and then VAR
variable data files you have a cache application cache data so one some
application is running or you meet this cache data so without this that
application will not know what exactly is happening and once you delete it it
has to do the processes again and again it has to store that data in cache even
the history command needs cash why you type in history you will be able you’ll
be seeing all the commands which were previously executed but where will that
be stored it will be stored in the cache and then you have beer lib data modified
as program runs you have lock you have the log files you
have the opt variable data for installed packages so basically any package you
install first it will be so it will be under the VA or opt package and there
are temporary files as well temporary files saved between reboots so once
you’re rebooting there might be some files which is getting saved so that
will be saved and stored in the temporary directory and once you once it
is rebooted it will be regained again and then there are some other important
directories slash dev slash dev is basically for a device file so if I put
in a pendrive I can find that pendrive under the slash dev folder and then
there is slash home so slash home is basically a user home directories so
that’s what I was showing you the home directory which has all the user names
under it and then live slash lab is libraries so be installed kernel headers
and kernel development kernel devil’s in the start while installing the
additional the VirtualBox additionals so those additional files require these
kernel modules because kernel modules are the files which are required so that
we can contact between the so we can have contact between us the shell and
the kernel so that’s why we need the libraries and
the kernel modules and then /mnt is basically for mounting if a new file
system is getting mounted to the system you’ll you can find it in the slash
mount directly then again opt is there practice there and finally in one root
is their home directory for the root user so even under root there is a
folder called root under that folder you will find some sub directories again and
that particular sorry and that particular directory is for the root
user and that that is the home directory for the root user so normally for a user
like in telepath the home directory is slash home but for the root user the
home directory slash root so that’s what we’ll have to look at so these the this
is the file hierarchy in a Linux distribution in every single Linux
distribution this is how it’ll look so understand this particular concept very
well so because everything in Linux is a file as I told you / – slash for the
device name basically if you enter a pendrive again that pendrive will
consider it as a file in the Linux system so every single entity is a file
in Linux so that’s why files and file permissions are very important in Linux
this is a lot about file permissions users and groups so now let us look at
these two commands which are really important and highly used commands which
is chmod and CH owned which basically it’s CH modifications and CH ownership
so these commands for highly use now let’s look at these commands
so first modifying permissions chmod is the command which you can use to modify
the permission of a file or a directory so you saw that read permissions rather
than write permissions and all that so let’s say you have a file and you have
written rate and you don’t save it now you don’t want anybody to write inside
that file now you can basically change your file functions and remove the write
permission from that file so that even you cannot try it inside that file
unknowingly so that’s how you can use it and to add or remove a permission you
can use plus or minus so you can see some examples in the band you can see
chmod you
plus X 1 point txt and doing an LS minus L 1 point
txt basically what it did is it removed or it added 4x over here and it removed
X from both of these places and then again chmod u minus X 1 minus T XE so
basically this particular file did not have permissions already so that’s why
it is showing that this place is empty and then while removing minus X that is
execution it removes X from every single place of
this entire permission so RW – RW – r – – so X was removed from every single
permission that is the user permission the group permission as well as the
other or process permission and then another way to modify permissions are
providing numbers now numbers let’s say 4 is read permission to write permission
and 1’s execute function so here you can see our W and X so R so our W and X so
the addition of our W and X is 7 that is 4 2 & 1 it is 7 so now coming down so
you can see here chmod 755 1 dot txt so now what would have that what this would
have done is 7 in the sense it is 4 plus 2 plus 1 which is 7 that means give all
reader access give all reader access and 5 means it is 4 plus 1 then it is remove
right axis from group permissions and remove right axis from other permissions
so that is what 755 means and you can see here RW x the read permissions has
every single for me the group permission does not have right as I said and even
the that permissions does not have right as I said so now you can see it but what
is sine Phi Phi there was no 7 or Phi over here so now coming over here 4 plus
2 plus 1 is equal to 7 so all access is permitted so that’s what happened here
in the first place that is 7 then Phi which is basically 4.0 4 plus 1 is equal
to Phi read and execute permissions so that’s
what was provided in the second and third options but we do not use 6
overview 6 basically provides read and write functions and it does not provide
exhibit promises so this is one more way to change it one way is to use
plus and minus second ways to use numbers in the then ownership permission
ownership permission is ch own so like modifying the files functions we can
also modify the users and groups ownership of the file and for that we
must use CH on so you can see here again LS minus L 2 dot txt so forget about the
part where we saw the file permissions now just concentrate on this particular
part which is root and root which are basically the ownership of this
particular file so 2 dot txt you can see the ownership was with root and root so
now I wanted permission so I use the command see its own cody to Rohtak see
and you can see the change over here so even as usual Cody I’ve got the
permission to use this particular file called 2 dot txt so this is how you can
use CH on and there are some other ways of doing it so now you can see here CH
own user name file name ownership of file for user so let’s say I created a
file but I want so let’s say in telepods created a file the user in telepods and
this particular user wants to give that permissions to in telepath to user
so now this particular user in telepods can simply provide CH own in telepath to
and file name and the file permissions will be provided to that particular user
and then there is CH group and group name and file name so CH group is
basically changing the ownership of a group so if you have greater group you
can use the command chgrp and group name and file name so that that group has the
file permissions so let’s say this to dot txt that particular file will have
so every user under that group will have permissions to either access or not
access that file according to the permissions provided and then see its
own user name colon group named file so now both user and group at the same time
so let’s say you want to give permissions to a user who’s not in a
group and also to the intent group so now you can use this way of doing it
CH own username : group name file name so this will give permissions to go to
the user as well as to group now hands-on chmod and CH own let us do this
in the console you know let us proceed with the hands-on part so let me open my
it’s just little bit slow this is is really started so I’ve restarted it but
you know let’s get started with CH more and CH own I’ll open the terminal then
we execute few examples of how you can use chmod and how you can do CH own now
let me first open the so here I will do this will do the chmod part first so
I’ll create a file then after creating a file will change some permissions and
check whether it changes or not and then we’ll change the map to that we’ll use
numbers to do that and after that will you chmod to change the permission of a
user as well as the formation of the group so that will do and I’ll going
back here opening the terminal so first let me make this bigger again so I made
it bigger okay so now let’s start off with it so first let me create a file
Todd so as I told you touches just to create a file I’m going to make it as
load or txt or just file one dot txt I have created the file and there is a
file file on dot txt LS minus L so this command will show me whether about the
file permissions so you can see it has read/write permissions for users
read/write permissions for the group and only read permission for processes so
the user isn’t any pad and the group is also Intel affected so now I’m going to
use chmod to change this to chmod u plus X this is just for the user you plus X
and file one dot txt so done now again al is L so now you can see I’ve added
the exited permissions just for the user so now let me do one
more thing now I’ll do for G for the crew sorry
now let us try yeah so I’ve added it for the group as well so now let me add the
write permissions sorry let me remove the write permissions from group so done
so you can see I’ve removed that I permissions from the group but I have
provided the execute permissions so now I want to remove write and provide only
read for others or processes for that it is full and it is going to be amount of
room you are and I’m going to I tell you I get zero instead of oh so done so now
if I do an LS so now you can see I have provided only W the right permissions
for others or permissions of C sorry others or processes this is what I did
using chmod so now let’s do one more thing so now in give permissions using
numbers now I am giving seven seven seven
so what does seven seven seven me 1077 is basically providing every single
permission to that file so five ones or txt so now if you view it and when you
can see this particular file has every single permission so let me change it to
seven five six toward will this do so this will they still make this well it
will remove the write permissions from group and this six will basically remove
the execute permission from others so let me hand out and I can do an LS L so
you can see it took up the write permissions and it took off the execute
permissions now let us do one more thing so I will remove the write permission
from the user so let’s say our user is in telepods so I’m going to remove the
write permission from this file which basically is three only right sorry if I
remove that permission it is with pipe read and execute so I’ll give five five
six it’s going to be the same so now yeah so only a region and executors
there now let me open this file and you can see it is unraidable because the
user does not have functions going bad let me change this once again I will
make this I’ll provide write permissions as well as we need an execute because
they are already available so now let me try nano again so now I can write
because I have provided the permissions to write so this is how you can use
chmod so let me just close this okay now we’ve done chmod let’s do CH on so while
I’m doing this LS l v one dot 60 you can see internal pie and in clip
at over here so this is the user and this is a group for your graded items so
now let us change the group which can access this file so the CH on and the
group name so first I don’t know the group’s so I’m going to turn this going
to do a cat group so it’s Intel about to Intelli 5-3 into the path there are no
other groups so what I’m going to do I’m going to create a group to group add
them I’ve created a group so now let’s try this once again but this time I’m
not going to that I’m going to get up there so a group is all available so
we’ve created a group now we’ll have to add users to this group so I’m going to
add in telepath so sudo G password so you’ll have to provide this for ID it’s
minus 8 then you’ll have to provide the username which is going to be in
telepath and then the group name which is a depth for adding user ID back to
group them it’s added so now we can check by English and it is added you can
see that over here so now we have created a group and added it now let us
change the permission of finally yeah so now let us change the permission of file
one dot exe so this particular group in Delhi pad is going to change to group
del so to do that it’s simply C as shown so we saw this file name sorry user name
and group name and fine name this basically is the syntax you can provide
the user name of you group name over here and file name over here so right
now we just want to change the group name so for that we can either give the
group name like this there and I 1 dot txt so it needs so now it has changed
now let us check file 1 once again so now you can see Intel apart and Dev the
group name has changed so we have done that you also have another option to
change that so you can use this command CH group and group name so now checking
once again now you can see the group has been changed back to in telepath so the
same way you can also change the file owner so see its own and interview part
– now let’s check now you can see the user has been changed – in telepak –
because we change the file ownership so now let’s do this I know Phi 1 dot txt
and do an LS so you can see there are I trade a wrong file I have to open file 1
dot txt so you can see it is unraidable for me because I’ve changed the
permissions to Internet by 2 that is another user so right now I don’t have
permissions but so let me change it once in sudo CH own Intel apart and filing so
now if I open file one but txt I should be able to write yeah because I’m the
user who has permissions over this file right now so I should be able to write
so done so CH own and chmod if these are the operations you can do with its own
chmod it’s very helpful and I think you didn’t use this so let me go back to the
slides display contents of a file we have various ways of doing that we’ll be
looking at some ways of it few few different commands to do that ok so
these are the four with commands which I wanted to show first head first 10 lines
and then tail last 10 lines grep searches for a pattern I think we’ve
used grip multiple times already then cat again we also use cat but we
will not use head and tail so we will do head and tail so let me go to ok so now
let’s see if I have any files here I have demo dot txt for cell to head they
know dot txt so we can see it’s showing the first five lines but head basically
shows the first 10 lines so what I’m going to do is I’m going to open demo
dot txt and I’m going to enter multiple lines so that it will be easy for us to
debug so there are so many lines so I’m just going to make these bigger lines
okay so it’s fine I’ve done it ok so now let’s do head once again and you see now
it shows only the top 10 lines for the first 10 lines and the tail command the
tail command will show the last 10 lines so you can see that as well tail command
shows the last 10 lines now grip ASD demo dot txt so you can see grip is
finding a pattern called ASD and it is showing all those lines which has that
put it in the pattern so let’s just type in tofu it again found a pattern so
that’s why you use grip and then finally we have chart that basically provides
the entire file so you can see that over here and one more few more things you
can do with the tail and header I think in tail you can use the end command to
sew so you can see it shows only the last four lines and in head again you
can do that and it shows up first file ends so
basically you can use these commands to display the contents of the file as well
as track them so using grep you can see every single instance of a particular
name inside a particular file which is very helpful for recognizing patterns so
that’s what we did right now so for example I will open the motor tx2 once
again okay so I’ve opened demo dot txt now
what I’m going to do is I’m going to enter the username which is in telepath
in various places it’s telling okay so entered in three different
places so what I’m going to do is I’m going to use grip to find it but I’m not
going to use my username directly I’m going to use a meta character dollar and
the command a command called Who am I which basically reads the username to
grip Who am I demo dot txt so now you can see it is
reading my username and then it is using my username to find a pattern inside
demo dot txt here we are using both the displaying contents for finding a
pattern we are using grep as well as we are using the who are my command and
also we are using in meta character to basically read the Who am I command so
if you just type in Who am I it searches for Who am I
if you put the dollar command and see the dollar might a character in front of
it basically it means that the value of Who am I which is intellibid
so that’s what it does so this is how you use tail head grip and finally cat
you can do all these operations using all these commands there are still a lot
of commands but these are the most basic commands let me get back to slides so
we’ve done this next is copying a file moving a file renaming a file and
deleting a file let’s start off with copying so I’ve already showed you
copying and move but still we’ll look at them again first copy copying files the
command is CP CP then source then destination or CP source to directory so
these are different ways of copying and CP souls one source to source n so you
can give a number of files and copy them to another directory so now let’s
execute these copy commands let me open it
okay so first let me create few files file can I name them demo one to txt the
mode or I’ll just give demo one demo to the mode three so I think I’ve created
three files see I’ve created now I will do a nano of demo one I will put hello
and I’ve saved it next demo – I’ve typed in something and there more three same
thing I’m typing some other sentence and I’ve saved them
so all these files are saved right now so first let us do a copy within the
directory that is copy demo one to demo for so now duo and LS now you can see
there is a demo for file also before it was not existing now there is a demo for
file and if I do a cat of demo for you can see the text same as demo one so
next copy they move to inside desktop let’s move inside desktop so I’ve copied
it right now you can see demo 2 will be available here as well as desktop so you
can see the motive over here as well coming back next will copy multiple
files into another folder under the directory that is first demo 1 demo demo
3 in demo 4 we’ll move these three files inside downloads sorry so done so right
now these files would be available here as well available in downloads as well
so you can see these files are available over here
so you’ve done copy next we’ll do the move command so again move has the same
functionalities so you can see that over here it has the same functionality it’s
the different command but the same syntax so now let us move a file within
the same directory that is demo 1 I’m going to move demo one to demo file so
now there will not be a file named demo 1 anywhere here there will be only a
file named demo file because I moved the contents of demo one as well as the file
itself to another file named as demo file next I’ll move their move 5 into
another I’ll move to desktop so now you can see demo Phi is not available here
but if I open desktop I should find the file over here because the stock is over
here next I will do one more thing coming
back will move multiple files so they are more 3 demo 4 I’ll move these 2
files into documents too many arguments sorry I
provided a wrong I provided the wrong command at this move and done so right
now demo 3n demo 4 will not be here but if I go into documents they’ll be
available and you can see them over here so this is all you use move and copy now
going back now renaming a file to rename again it is the same command as move so
let’s see rename once again so let’s say I’ve created a file name so I’m not
going to create another file so let’s say I have one dot txt so I want to make
this as the word that is oh NP dot txt one dot txt so I’m going to use Move
command one dot txt – one dot txt so now you can see there
is a file named 1 dot X but there’s no file named 1 dot X because I’ve renamed
it but here the process is not actually renaming the file it’s actually moving
the file but you will have to use the Move command to rename the file as well
and we’ve seen rename as well now deleting so now to delete it’s a pretty
simple first RM RM is a command remove remove and file name then to move and I
the driven star dot txt so what this does is it will delete all the dot txt
files then remove source one source – you can also remove by providing
different file names now we’ll try all this so first here you can see you
remove demo – I will do mu demo to demo to is removed then I will go inside
documents and yet there are different types of files so I will remove them by
typing in demo 3 demo 4 + 2 dot txt and now I’ve removed these as well now here
let me go inside desktop sorry and there are two files over here so I think I can
delete them using this RM star now you know do that I think you can do this
remove power and demo so it’s not considering it so let’s
leave that okay so now let’s remove these files normally first demo – and
demo file it’s not there so now what I wanted to do is so let’s see there is
what demo dot txt as well as file 1 dot txt as well as one dot txt so I want to
remove all the txt files in a single go for that what I can do is remove star
dot txt and so this will basically remove all that dot txt and file so I’ve
removed all those files so we have seen how to delete files as well and now
common commands make directory we’ve done this remove directory and then find
searches of file or a directory so let’s use find find one dot Sh so it is
showing that it is existing so if I search for one dot txt it will not exist
so let’s say find so first let me open this thing nothing will be here so there
is gamma one let me search for demo one but it will not find because it’s not
available here but find demo one I think if I provide documents sorry if I
provide downloads again sorry
so it’s finding downloads and it also shows the files under downloads so this
is one command which is really useful it will show the directory as well as the
sub files and subdirectories of the directory and then there is PWD which we
have done already then file shows the type of the file so going ahead to file
downloads so it shows it’s the directory no file
was let me see yeah yeah one dot is H so file one door Sh
it’s a shell script now let me create a text file and file one dot txt
so it’s an empty file because I have not entered anything and so that’s what it
means so here you can see it’s born again shell script and this is directory
this is empty file so that’s how you use file UNIX process controls commands or
Linux process control commands so moving ahead you can see here a command issued
in Linux starts a new process which invokes a five digit unique ID called
process ID or PID using the process ID the process can be tracked so let’s say
if you type in a command that particular command will invoke a process so if a
process is invoked obviously that process should have a process ID so once
it invokes that ID using that ID you can track that particular process it is
basically reversed checking it so let’s say I am trying to find out a pattern in
a particular document or I am trying to do an LS or I am trying to find the
present working directory provided here PWD so when I type in PWD and hit enter
obviously it will start a process by using that processes unique ID
so once that happens once it is called that particular process can be tracked
using the process ID so that’s what they are meaning to say here so now
initializing a process striking a process stopping and other processes so
we look at these steps first initializing a process a process can be
visualized in two ways foreground and background so foreground every process
runs in foreground by default when it has started so when I type in PWD it
will show you the output in the terminal so it is a foreground process fronts in
the background allowing other processes to run in parallel so basically let’s
say in another terminal there is another command running and
this terminal you can use an and in the back which will basically push your
command to the background so now it will be a background command so let’s do this may open the terminal and I will zoom it
in so LS PWD and no such file or directory so so PWD basically is a
foreground process and PW and will become a background process so you can
see here 1 1 2 1 5 is the process ID for this particular process so firstly then
walk to the process ID so it checked whether any process is running in
already running or not if it is already running then it will run parallely if it
does not it will again execute it and show you the result so the result is
over here and it shows it’s done so this is what it means so normally when you
run any command it will run in the foreground
once he use an and in the end then it will become background so let’s do for
LS LS dollar C sorry LS and let’s do this LS and type PWD and so I think I’ll
remove this and I will put Turner and here so you see the second process has
completed so let us try once again LS PWD so now you can see it first did
this particular process but it did not do the second one because it took the R
so now let us use and so now you can see it did both the processes that is it
first did LS then it did PWD but it did it in a single go basically
it considered it as a single process and it executed it but it also considered it
as a background process that’s why to show in the process ID as well as the
done mark now going ahead next tracking a process to track a process you have
the command PS we look at these commands in depth in upcoming modules we are
looking these right now like we’ll be looking at these a little bit but in the
few coming upcoming modules we’ll be looking at these commands in depth PS
and there are still top there are still more commands we’ll be looking at them
in depth later right now let’s just go go ahead with the presentation so next
all running processes can be tracked using the following commands PS so now
let us try this command yes so you can see two processes running
one is bash 1sps now if I do a PS ox it will show every single process which is
running so you can see that over here the root process who is running the
process the process ID and this is basically an onion sorry this is
basically a none interactive document it shows all the processes which are and
the process ID and it shows every single thing even it shows PS ox as a process
so it just shows all the processes which have done which is running every single
thing so that’s what awesome it’s so even PS shows the current running
processes and let’s say PWD and and I will do a PS so right now it won’t show
because it has to run in synchronization only then it will show going back so
this is what what this is why you use PS or it will show all the running
processes so for example I can show this so let’s connect to the internet okay so
let me zoom this in now I think google.com
I will teach both the ping command lane the later modules now just so you can
see pink is running so now let me do PS think it is not now it’s running here so
let me open another tab and do PS so it’s still not showing it so PS ping so I can do this so let me close this
right now let’s let ping run I’ll close this so let me open another terminal and
I can make it bigger so now let me do a PS so now you can see another process was
running meet this figure you can see every single process which ran in this
particular system and you can also see their process IDs you can see that over
here but the current processes which are only running only that PS will show
nothing else because it’s not an interactive command it is basically a
document so let’s leave that next moving on next another command is there so you
can see a running process can be tracked using the following commands so you can
see uie PID PID C s time terminal time cm cm D basically this is the command so
UID is basically the user ID or the ID of the user running the process and then
second is PID the process ID so you can see the process ID as well PP ID is the
parent process ID if this particular process has a parent let’s say you are
running Firefox then opening ten different tabs so it might have a
process ID and then sub IDs and then C is CPU utilization of that particular
process so here in this case there is no CPU utilization and then s time is start
time of the process when the when did this particular process start and then
TTY is the terminal associated we are using only one terminal that’s why it’s
showing pts / 0 its 0 terminal and then time is CPU time taken by the process
how long it took basically we did those processes did not run and it did not
take much time so that’s why it is showing 0 0 0 0 0 0 and finally CMD is
the command of the process now this is what I was showing you
PS aux lists out all the running processes for all users it not just
shows for this particular user it shows the running processes for every
single users right now that’s what I showed you PSO and then PS – you user
name will show all the running processes for one user so this is an interesting
command so we try this so PS hog States – you so either need a
oxy – you and Intel apart ok so right now
it’s showing every single process running under intel pad you can see that
printing mouse key box client the hash normal so this is the terminal that’s
what it’s showing Lecter let me run Firefox and let’s try this once again
and now you can see Firefox is also been added so basically it is showing so if
they do PS it only shows these two if I see for the user it is showing Firefox
PS bash and chrome terminal because all of these are running currently so so I
will just close this I will require now if I do this again it should not show
Firefox because I stopped it so it was showing web content as well so right now
as I closed it so the I close it so question here no I did not that’s why it
is still showing close tabs and so let’s run it once again so now you can see
there is no Firefox because we’ve closed the process so this is one way to track
the process under particular diffusor you can check that and then the next one
is stopping a process so let us do this so let’s again run Firefox and so you
can see the process ID over here let me run in once again because it will show a
single process ID so I can use that process ID to kill the process and it
will automatically close this particular console so now you can see Firefox this
is the process ID I have copied it going back so let us understand the let us
understand the syntax first if a process is running in the foreground that means
let’s say you’re running things so if you’re running ping if you hit control C
which will it which is so keyboard interrupt it’ll automatically stop the
process for example let me do a ping in telecom so now if I do a ctrl C so you
can see it automatically is terminated it so now this is one way of starting a
process the second day you see is to use the command kill so kill terms signal so
this is where you enter the signal and this is where you enter the PID so
signal is what tells what exactly this particular kill command should do in
order to stop a background process use the following command so coming down
take a look at the list of terminate signals so let me give kill on the cell
so this shows every single signals available in
your Linux distribution so you can check it over here sig Hogg sig end sig buzz
and then there should be a shake abort signal is their sigil arms that’s it
stop is there so all of these are different signals will be learning about
signals as well in the further modules and then there is a cat and command so
example stop the cat command running in background by so we’ll do this example
we’ll run the cat command in the background so once we have run the cat
command at the background then we will kill this process using its process ID
so that’s what we are going to do on so let’s go ahead and do this so I’ll close
this I will open another window I will run the cat command
it automatically stopped I’ll just copy this so now P sorry killed and I think
we should use the number of nine – nine so – line is basically terminate the
process abruptly it will kill the process of roughly and minus nine
so it was already stopped so it killed the process so you can see right now
there are two processes so one is let this run will close that as well let me
do the spring clearly part calm so let this run let us do a PS right now it’s
not showing but we have the IP so I’ll just copy this still running so let’s –
nine and the ID I think this is the ideal little chip once again and I’ve
pasted it so I think it would have killed the process see how the process
stopped so they feel it killed it so now let us do the same thing with Mozilla so
now first I’ll do PS walks and you can see every single process running and for
Firefox you can see here on Firefox Firefox content Pro Firefox content flow
so I’m going to just stop this particular I’m gonna kill this so kill –
9 which is for terminating or sigga sigga bot so this will basically so
sorry it is sick kill this will basically kill the process so kill – 9
and I’m pasting it and you you saw the mozilla window with this disappeared
from the behind basically it killed the process so let me do a PS ox once again
so now you cannot see the Firefox process running because I have killed it
so this is all you can use the kill command to kill the process so we did
that particular example to use Mozilla and we saw how to kill a process right
now we saw up till PS the command PS now we look at top and few more commands so
first top so the following command is used to see all the running processes
within the working environment of Linux basically this is an interactive shell
you can see the processes changing in real time so if a process is killed you
can see that in real time if a processes are invoked you can see that in real
time you can use the top command for that so we’ll do them one by one now let
us just see what are the commands available sorry so next we have nice so
you can see the following command is used to start a process and assign it a
priority value at the same time so nice – nice value and process so nice value
ranges from minus 20 to 19 where minus 20 is of the highest priority so you can
see that and it started the process in the background and then PS minus L it
was showing all the running processes and you can see priority is 80 nice
value is zero default priority is 80 and the command is can so you can see all
the priority values over here and you can see cata stopped over here coming
down you can see nice minus 19 cat and so basically what this will do I say as
we told you minus 20 is the highest priority so minus 19 obviously will be
the I is priority right now so you can see the priority has changed from 80 so
here we can see the priority has changed from eighty to ninety nine nice value is
nineteen priority is reduced to $2.99 and this is again cat and nice 19 cat it
stopped again so and again one more is nice – – minus nineteen command so nice
– – nineteen plaid and so again it started the cat it started running cat
nice value is minus nineteen and priority is increased to 61 so that you
can see over here so this is what – nineteen does so if you just provide –
/ – any value it does not consider it is so it does not consider it is it has or
– 20 value it basically considered it has a positive value will have to
provide two hyphens only then it will consider it as a – value which means it
increases the priority of that so this is 99 and this is 61 basically which
means this has increased the priority so now the one more command is realized you
can see the following command is used to change the priority of a process so
while that practic particular process is running you can change the priority of
that particular process so be nice again the same
– nice value then process ID so let’s say a process is started with a nice
value of minus 10 now it’s minus 10 cat and so nice – 10 cation so that’s what
they’re doing here nice – -10 cat and so this is the process where dsl at 70 ni
is minus 10 coming down now using green ice – 3 and the process ID basically
they change the value automatically so you can see it got changed old priority
was – then new priority is minus 3 so 77 minus 3 and that’s what they are telling
here so but what do you mean by priority why do you need priority so let’s say if
a process is having the highest priority CPU will provide the maximum time for
that process to complete but if you provided that particular process the
lowest priority of 19 then that process will not be given the same priority as a
process which has minus 20 or some value nearby that so that is why you need
priority so now and then one more command is DF this command basically
lists the block devices available on their disk space so you can see these
are the file systems so now let us start off with the first command and look at
all these commands and let us finish you off with this particular module let me
open my done I opened it so let’s start off with the first command which is top
so as you can see top command is running and you can see the values are being
changed top gnome shell nominal so let me open another window and let me run
pink dot-com so I am pinging right now so there should be a new process created
Bing so I think it just went and it went back right now it’s showing the top
processes over here to start so let me stop this and one once again think you
see the changes going on here okay let’s stop this now let me become
the super user and run a command in the background so let me run cat and so cat
is running in the background so right now it should show a cat command if it
has enough CPU memory so you can see here PID priority is 20 minus 51 then ni
are these processes of the highest priority because they are minus 20 and
then what else you can see the now the time which are these processes are
running and you can see the memory which this particular processes are taking the
shell is taking 11.5% of the memory and 19.4% of the CPU at this particular time
top command is taking 1.7 percent the gnome terminal is taking one point seven
percent of memory and one percent of right now it’s saying three percent of
the CPU so you can see this is an interactive way of looking at it and you
can see the number of tasks running to thirty to thirty total tasks two are
running three are running to twenty five sleeping two are stopped and the memory
2837 three memories 637 used just thousand 73 and available memory is
thousand eighty so you can see the real-time changes in the CPU memory
available and not available so let me now stop this kill – 9 1 – 8 – 1 so I’ll
stop it so the cat command should stop and the
available memory you saw it had a slight increase because one particular
background process stopped and that gave the memory a little space so this is how
topped works now let me close this and so we saw top next we will have to seem
nice so going back here so nice and the value
so first let us run cat in the background and then let us do the same
process over here so I am just going to open this –
I’m already logged in as the root and sudo sorry I’m already the root so I’m
going to run a process – 19 cat and so now I’m going to do PS – L and now you
can see the cat process running which is – 19 19 and 19 so first let me stop kill
few processes no sorry I should not kill it now I’m going to do the same thing
but I’m going to use – – 19 cat and and PS minus L so now you can see there is a
fourth cat process which is running with this different PID but the parent
process ID is the same because I told you all similar processes will have the
same parent process ID but will have a different process ID so first let us
kill them 1 3 1 5 2 done 1 3 u 1 7 5 done on three one seven seven done so
right now only one seven eight is running so the 1 1 sorry 1 3 0 8 6
process is running so let this run so right now what I’m going to do is I’m
going to realize this process so that’s what we’ll have to do that is rename we
did both of these commands we’ve changed this particular value so now we’ll use 3
nice that is you can see really nice – 3 and the process ID so I’ll put 3 nice so
I’m changing the niceness basically I’m changing the priority so that the CPU
will give memory and time accordingly so V nice I’m going to give minus 6 and
I’m going to give the process ID cross ID is 1 3 u 1 0 sorry it’s 0 8 6 enter
so now the it’s showing old priority is 19 and new priority is minus 6 if you do
a PSL again you can change you can see now the process ID has changed on the
priority has increased to 74 so this is you use realize and then finally there
is a DF command so let me create this and hit DF so now you can see there’s a
/dev which is mounted it is completely available because no other depth
device is touched then there is slash run and there is slash boot so boot is
the directory which is used for booting the system to basically to start the
system without the boot directory you cannot start the system and there is run
user 42 + thousand so thousand is the user ID of in telepods user so that’s
what and there is a fourth one for the guest additions so the guest additions
is running and the use is 100% this particular directory is used hundred
percent because it’s running all the time so this is how you can view the
mounted devices the device files as well as the storage which is used by them and
the storage is available and you can see the mounted location also so this is
route so you can see in the root so this is the root and you can see it’s mounted
to the root folder and eleven percent of this particular root folders the space
is used and you can see the available storage and the u storage so this is how
you can view it so now we view all kinds of processes going back so we’ve
completed this module guys so thank you meet you in the next module so let me
just recap the last part we saw the PS command
we saw the PS aux command which lists every single process but top is the same
kind of a process but top will show that interactively PS ox will show just the
processes which are already which are running when that particular command is
typed in once that command is type in and you’ve got the result after that if
there is a new process it will not show but the top command will show that so
top is an interactive running to show the running processes it’s an
interactive command but PS is not and then nice and green eyes or commands for
changing the priority your processes so it will decide how much priority should
the CPU should give to this particular process so according to the nice value
and the renames values so Riina’s is to change the nice values so the highest
priority is -20 the lowest is 19 so accordingly it will prioritize the
processes and run them accordingly it will give the maximum memory and time to
the processes which have the highest priority to complete them first so
that’s why you can realize your processes if they do not have high
priority or if they have high priority and then we also saw this
command which is skill we used the kill command by using – the 9 and the process
ID we can stop that particular process completely and using and at the end you
can basically run a process in the background so that we saw and it only
works if you are logged in as sorry not logged in if you are a super user only
then you can run the background process otherwise you cannot do that it will
automatically stop itself and then you can also use control-c which is
basically an interrupt keyboard interrupt that will also stop it and
then yeah so this is what we saw in this particular module okay guys a quick info
if you want to do an end-to-end Linux training in telepods provides a complete
in the next certification training and those details are available in the
description okay guys we come to the end of this session
I hope this session was helpful and informative if you have queries
regarding this session please leave a comment below and we’ll now to help you
out thank you

15 Comments

  1. Guys, what else do you want to learn from Intellipaat? Comment down below and let us know so we can create more such tutorials for you.

  2. 👋 Guys everyday we upload in depth tutorial on your requested topic/technology so kindly SUBSCRIBE to our channel👉( http://bit.ly/Intellipaat ) & also share with your connections on social media to help them grow in their career.🙂

  3. I was surfing around the Internet to learn Linux from the past 2,3 days…

    What a timing Intellipat 😁😅
    Thanks for the video 💙🙏👍

Leave a Reply

Your email address will not be published. Required fields are marked *