Hello, beautiful people in this video, we are going to cover filesystem, what is a filesystem?
It is a system used by a computer operating system to manage your files and directories.
The system controls how data is saved or retrieved from your computer hard disk.
Let's compare a computer file system with a simple closet.
Now, looking at this closet, you'll see we have our shirts on one section of the closet.
Our accessories go to different sections, skirts to a different sections, jackets, shoes and pants
and so on.
We organize them or we put them in a different sections of our closet.
Now, if you don't do this and you just throw all your clothes in one big closet, then what will happen
in your closet is going to look like this, a complete mess.
So it will be so hard for you if to pull out a jeans that you're looking for our socks.
So that is why.
The filesystem was born to avoid this cluttered way of things, so operating system stores, file and
directories in an organized and structured way.
For example, system configuration files would go to one folder, user files to another, log files
to another folder.
Commands or scripts will go to a different folder and so on.
There are many different types of file systems.
In general, improvements have been made to file system with new releases of operating system and neat,
and each new file system has been given a different name.
So whenever there is a new release, an operating system, usually that comes with an improved or enhanced
file system.
So let's talk let's take a look at a few operating systems.
There are 63 for office.
And by the way, these three operating these three file systems are the Linux file system where as NTFS
and fat are the Windows file system.
All right.
So if we go to our Windows machine, I have my Windows 10 machine here.
And let's say if I go to my file explorer and I'll go to my C drive, which is right here, and you'll
see it has a predefined folders.
When I had my first operating system was built.
So the program files and program was 86.
These two folders are used to store the applications that are installed on your computer.
They go in these folders, whereas when you create a uses in your computer, your operating system put
that uses profiles into this directory going back.
Similarly, Windows, the operating system files the configurations will go to this folder.
So it's a lot easier for the operating system to pull or retrieve the files it needs because it knows
which folder to look for.
Now, if I go to my Linux operating system.
Just right here, let me log in.
And I have the terminal open right here.
So I would have to go into KDDI Slash because everything starts from the slash, which the root directory
hit enter, and I would do this myself.
And right here you will notice everything will start from these directories or folders, just like in
windows, everything start from D and then everything starts on scratch.
So you have been directory.
Boat at sea, where the configuration file go home is where all the user directories are located.
Then you have opt with the programs are running, then you have SBN.
That's where your commands and scripts are located.
Then you have temp directory, you have your directory where your log files are located.
So that's how the Linux operating system has its own structured way to save the files and directories.
So that's what exactly a file system is, and I hope you could remember that you could compare that
completely with the closet and then you will never forget what a file system is.
In this lesson, we're going to cover the directory listing attributes when you do this within a directory
to use KDDI into a directory and you do less and you can only see the directories inside.
But when you do else minus Él or LTI or other options within that command, you're going to see different
fields that's going to output on your screen.
The first field is the type of the file.
So if any file that begins with D, it is a directory.
Any father begins with L, it's a link and any file that does not have anything on it, it's just a
regular file.
So the first rule tells you about the type, the second field tells you about the number of links.
It has a heart length that attached to the directory.
The third one, it tells you the owner of the director who owns it, that the fourth the fourth one
tells you the group of their directory, which group owns the directory and then the size of the directory
or file the month, the day, the time and the name.
So these are the basic attributes.
When you do X minus L, that's let's go to our Linux server and see how it looks in our Linux server.
Which directory are you in?
That stupid W.D. and I am in my directory, so let's go to slash home directory.
Sorry, slash just slash director which is the parent and then we will do X minus L here you will see
the first again the first column right here tells you what type of file of this second one.
How many links.
Owner of group owner the size the month date time and the name.
So this is what you should need to know whenever you're doing this, because if you are trying to do
CD to a file, let's say we have this file test file.
If you do test, if you're trying to get into this file, it would tell you it's not a directory because
it's a file.
That's how you should know whether you are able to get into a file or not.
If you go into, let's say, KDDI slash user.
There you go.
You are in slash user directories because it's a directory.
So that's how you find out whether a file is a directory or a link or just a regular file.
Creating files and directories in this lesson, we will cover how we could create files and directories,
different ways to create files.
The first one is the touch the touch command creates a file that is, of course, an empty file.
The second way to create a file is if you are copying an existing file and creating a new file at the
destination location.
And the third way to create a file is through V.I. Command.
Now, why is our editor, which we will cover in detail later in the lessons, but I will cover quickly
how we could create a file using V.I. creating directories.
The easiest way to create directory in the command is mkdir, which is make directory.
So now let's get into our Linux machine and we will use every command listed here as a practice to create
our files.
OK, the first thing we have to do is to find out what user I'd've logged in as you do, who am I and
will tell you you are logged in as yourself.
And then the second thing you have to know which directory you are in.
And I am in my home directory now.
I have I will be creating a few files and as your whole work, I want you to create those files and
directories as well.
The first way to create a file here is here.
I have a list of hours that I will be creating.
We will use the first command to create a file will be touch, touch space I have here, Jerry hit enter
and you hit enter and you get the power back.
That means your command worked.
Now, how do we know where is that file you do Ellis minus L and you'll see here the directory you have
is right here, Gerri.
Sorry, the not directly the file.
Now I want you to create another file.
Touch Kramer again.
Check if it's created.
Yes, it is created.
Jerry and Kramer.
Now I use the option else minus L which will list all the files and the directories in alphabetical
order.
Now, if you want to list all the files or directories that are created that it was last modified,
you will use Ellis' minus LTI or which means give you everything by the timely order and in reverse,
meaning the oldest, one of the top and the newest one at the bottom.
Then you hit enter.
You will see Jerry was the first one that was created, followed by the Kramer.
Next one we are creating is George.
How do you verify that file was created to do Ellis L..
These files can be changed or renamed and moved, but will go to the next set of files to create.
I want you to use this time to copy command, so I want to use copy Jerry and then the destination file.
I want you to be Lex Dualisms and Sal TIAR.
So what exactly did it copy this Győri file and named it?
Lex, I want you to do the same thing for Clark, so copy Jerry for Kramer or whichever file and do
Clark.
Same thing.
Copy Jerry and Lois, let's verify we have all those files.
You we got all six files so now three files we created with Tushka man three files we created with the
copy command and the rest of the files will create using VI.
Now remember, V.I. is a very tricky so I will only create one file and we will cover the VI later.
So V.I. Space Holmer so hit enter.
Once you hit enter it will bring you to file ed.
Now be very careful what you type in here because you will not be able to get out if you really don't
know what you are doing.
So at this point I just want you to do shift colon W as in right.
Q As in quite an exclamation point which is also referred to as bang hit.
Enter the file.
Holmer is created.
How do you verified this to address multiple TR and there you go.
The homework file is created.
Now the other three files I will create by the touch command.
Now you will notice you don't have to run touch command over and over again.
You can run the command just once and do Barch Space Lesa Space and May Augie March.
So now with this just one command, it will create three files.
So hit enter verified all three Fassbach March Lisa all of them are in this directory.
Now the next step I want you to do is create directories within your home directory.
Just do just to make sure you are in home directory.
Then from here you do mkdir space cine film.
Now the directory is created because you got, you got your back.
How do you whereby a less munsell tr and you see at the bottom that's where the directory is created.
And if you notice some of the Linux distributions also change the color for use of this way it will
be easier for you.
To identify which one is the fire or which one is directly same way it wants to create another directory
mkdir Superman.
And again, you can also do the same way instead of running one command after the other, you could
just run one command and followed by two different directories.
So the second actually, we have a Simpson Simpson
and enter once you hit and Turkey and do this myself to see all three directories at the bottom and
you have all your files right here, listed here.
So this is the way you create files and directories in your home directory.
If you try to create a directory in, let's say, slash or somewhere else where you do not have permission,
it would tell you that this directory, you do not have sufficient rights to create a directory.
So let's take the example.
If you go to code slash ETSI and I want to create a file here.
Let's call it test one, two, three and hit enter.
Going to tell you you do not have permission to create the file in there because we don't warn Slash,
who owns the slash route, owns it and you are not rude.
Who are you.
Who are yourself in this case?
I have.
So again you learn three, four commands touch, copy, v.i. to create files and the last command we
learn to create directories is mkdir.
File maintenance commands in this lesson, we will cover a few of the commands that are used to maintain
or keep or change your files, some of the commands are listed here.
The first one is the copy command copy, which copies one file to another.
The second one is to remove a file, which is R.M. The third one is move.
This command is used to move the location of a file from one location to another or to rename a file.
So it does two things or it serves two purposes.
Then we have mkdir, which is to make directory and then our MDI are to remove a directory.
Or there's another way to remove a directory by typing R.M. Space Dash or Hoffner.
Then we have change group, which is the ownership of our file, the group level, and then we have
change ownership, which is the ownership of the file at the user level, some of the commands we have
already covered and some of the commands we will be covering in this lesson.
So let's go to our Linux machine and go where these commands one by one.
And let's log into our machine.
We already have the last screen open.
Let's clear this out.
Where are we?
We are in see when you type and hit, enter and then PWI.
Now you are back in your home directory.
Clear the page.
So this way you will start fresh.
Now, with the first command we will be learning is KTP against CPI's a copy command.
You can find out by hitting man and keep this will tell you sepi copy files and directories.
So the way you could do it in Windows is you right.
Click on a file and you get the option of copy and then you go to another file, another directory or
another location and then right.
Click into the paste and Linux.
This is how it works.
We will let's look at our listing.
We have all these files.
So now we will copy the file called George and we will name it to a different name.
Let's say another character for show David and you hit Enter.
So this will tell you that Sepi space source, which is the George and the destination, which is the
day you enter and then you do X minus L tr the the TR option will give you the newest file created at
the bottom you enter.
So the David file is created.
If you also notice the George file is still there and it created a file.
Copy the file George and rename it David.
We could also add something to the file is let's say at Coke.
David Purdie.
Is.
Elaine's boyfriend.
And then I'll put to David and hit enter and how do you verify you, Dukat, David?
You'll see the contents in there.
That's what you do the copy for.
You could also do as you copy, David, and then you can copy it.
Not at this location where you are.
You copied some other location.
Let's say we wanted to copy into temp location.
So it is going to copy it is now going to remove, therefore it will copy it to the temp directory to
enter.
Do it myself.
Here you'll see it has the David copy.
The original copy here now will go to slash temp and then we will do this myself to the bottom to see
the file as there, see the same file that we copied.
But it's in a different location and it is owned by me on by the same group as myself.
And it has the same number of bytes you could do, CAD and David, to see what's inside of the file
service territory.
You are in the intimidatory.
If you want, go back to our homework.
You just simply type hit enter and you are back in your home directory, Ellesmere's Altura and that's
what you have here.
All the files that Savar, the copy.
You could practice their copy command by copying different files or different names, whichever names
that you like.
The next command we're going to learn is remove.
Let's create in the file touch and we will create a new file in Homer, Bart, Marge, Lisa, and we
call another file UPU.
Apu is another character of Simpsons family.
So we'll create this file called UPU and we'll do this myself.
TR and you'll see it created a file UPU.
And if you wanted to upend a file or add something to allow for what he would do, we do echo UPU is.
And Indian character.
In the show, right?
So I'll put that to where you are, you were fired up.
Poo poo is an indicator.
That's how you do it.
Now you want to remove this file now after certain times, you don't need it.
So what do you do?
You do are Apio H0 simply is that hit enter and it's gone.
Let's try.
Let's make sure it's gone or not.
Yes.
See, there is no such file UPU in our directory because we removed it.
We could also remove a directory, but we'll cover that when it's turns going to come the next come.
We have to learn is move now, move command actually move the file from one location to another and
also rename the file.
How does it work?
Let's call Lex and Superman.
There is this character, of course, this a villain character, Lex.
So let's see.
We have the Lex.
Yes, we have there.
We wanted to rename that to Luthor.
So lax last name was Luthor.
So let's try.
We wanted to change Luthor.
So how do we do it?
We do move LAX and this is of course the source.
And what's the destination name we want to give it to Luthor.
Ls you are.
This is going to rename this file within the same directory hit Enter Ellis mysel tr and you, you see
Luthor.
So this is how you rename it.
If you want to rename any other file you could do that or you wanted to create a different file, you
could do that.
Let's say we have this file called David and we wanted to change to the last name of course, which
is Move David to Pudi.
So that's his last name.
So we're moving David to the name Pudi sled's mysel TIAR they change the name from David it to Pudi,
but it kept the content of their file, which was if you look at you'll see David Petraeus, Elaine's
boyfriend.
So it just changed the name.
It didn't change the content.
Next one, by the way, also to change the location.
If you wanted to move Putti from this location to a different location, let's shift to temp.
It will move that file to a different location temp.
Now, let's see, do we still have that file?
No, we don't.
Where did it go?
We moved it to temp.
So how do we know it moved to temp?
You'd KDDI into temp.
That's manslaughter.
See, this is the PUDI file that you created.
Now this move this back to more.
Back to our home directory.
And what is our home directory?
You guys should know that home your username and hit enter it should bring you back to the your home
directory.
When you do hit enter, it will bring you back to your home directory to address myself to your annual
party files.
Next one is make directory.
It simply will make mkdir Game of Thrones one of the biggest show that we created this.
This is how the new director is created.
Make DVR now.
Let's try command, which is remove territory.
So remove directory.
If you want to delete one of these directories from your from your home directory, let's say I want
to remove Game of Thrones directory.
You just simply type our MDI are and Game of Thrones.
And it is gone.
This is one way to remove it, another way to remove it in order for us to remove it.
Let's recreate it again, hit up our key and you will get back to the same command, make the Game of
Thrones the directors created.
Another way to remove it is R.M. Dasch or Game of Thrones.
And it has gone.
All right, next come we have changed, group changing group is changing the ownership of the file,
changing the ownership of a group of a file, and the last command is changing the ownership of a file.
So if I wanted to change the ownership of file PUDI and I wanted to change it to a group called Root.
So we will do change ERP Route 30.
It's his operation not permitted.
Why?
Because we are we are ourself and who can make these changes?
If I want to assign something to root, I have to be root.
So let's become root.
Once you are rude, let's go back to our home directory.
And now will do change grb route and Putti, and this time it worked because we have all permissions
in the world we could think of now.
Next command change ownership to root off PUDI.
This will change the ownership of the file name Pudi to root as well.
Now if you wanted to do a both commands at once, the change owner you could do Afsal I absol Pertti.
So what this command will do, it will change the ownership as well as group ownership of the filename
pudi hit enter responsable tr and there you go.
You got your file back with the original permissions or original ownership permission.
So these are the file maintenance command.
Once again the recap KBE R.M. move mkdir remove Dyax Change Group Change ownership.
Soft links and hard links.
This is one of the important topics in Linux, before I tell you anything about what a soft link and
hard link is, have to tell you.
I know.
What I note is I note as basically a pointer or a number of a file on a hard disk.
So if I create a file call, let's say HOLC, that file name is Achu, L.K..
That is a name for me as a human for me to understand the name of the file.
But computer does not understand names, computer understand numbers.
So every time you create a file, computer assigns a number to that file on a hard disk and associate
that number to it.
That number is called ENCODE and every time you try to retrieve that file or read that file, it goes
and retrieve that number.
So now now you know that.
I know.
Let me tell you about a soft link.
Now, a soft link is a link that when created and it will be removed if a file is removed or renamed.
So if I create a file and I link create a link, a soft link to that file.
So once it created, it actually looks for that, I know through that file so that Chris is softening.
So if I remove the source file, it will remove the destination link.
We as hard link is ventilating or renaming the source file.
The hard link will not change.
It will remain the same as if you have copied it to create a hard link command you will run and as a
link to create a soft link, you will run the same command, but with the option minus s and I have
a picture right here which of course a picture speaks a thousand words.
So if you see on the right hand side, it's myself link.
It is connecting through my file to the eye node where as my hard link is connecting straight to the
eye node.
So if the middle part, which is my file dot text goes away, my soft link goes away.
However, in my hard link file, if middle file my file text goes away, it doesn't matter.
They'll file stays.
Let's get that log into our machine, a Linux machine, and I will explain you much better how this
links work.
By the way, one more thing I should mention, Link is just like a shortcut in a regular term, as if
you are creating a shortcut on your desktop.
In your Windows environment, you have a file located somewhere in Windows System 32, blah, blah,
blah, blah.
Of course, you have to go to the file all the time by navigating through that file system.
Click, click, click, click, click, click, click, click.
Hmm.
So much, Wordman.
So what do we do?
We create a shortcut to our desktop.
All you have to do is double click on Wolmarans.
Just like that.
We have Linux softening in hard link.
So without further ado, I'm going to log in to my machine and I'll explain.
You ain't this is our machine is going to drag a little more to the left, just wire to confirm again
it.
I am logged in as myself.
This is my name.
This is my home directory.
Perfect.
I want to create a file called Hope.
Everybody knows how great fun character, big giant character.
I like it like his movies.
OK, anyway, I created a file called Hulk.
Now I will like to create a link to that file.
Hulk, I will go to temp directory.
I am in temp, not in my home directory and I want to create link soft link to Hulk and Hulk file location
his home.
I have Zoll and the name of the file is Hope Boom.
It created the file link.
How do we verify your friendly command.
Lets myself tr and if you see right at the bottom it is telling you it has created a link and Linux
operating system.
Since we are running Linux with a Goydos changes some of the color, it changes it to blue.
So right here, the first bit it's telling you it is l what is L for L is for link.
What is D for D is for directory.
Yes, very good.
And what is a file that does not have anything.
Of course it's a file.
I already answered that.
OK anyway so it created a link.
Now I will go back to my home directly by just typing c d p W.D. to just confirm I am in my home, correct.
Yes I am.
And I will type something in my file call so I'll do Echo and the Hulk is a super hero.
OK, and I will I've put that to Hulk file and I do Cat Hulk.
It's there.
Right.
OK, now I'm going to go to my temp directory and I'll do cat this confirm I'm in my temporary.
Yes.
And I'm going to cat the Hulk.
And you see it has the same content that I just typed.
And so it's just a shortcut, just a link.
I will come back to my home directory and I will run.
Ls minus l i what is I I stand for I notes if I wanted to find out the I know of this file I will run
I so yeah it's there.
But since I didn't type I let myself tr it went into Middle's file type talismans.
al-Attiyah and then I so this way it will be at the bottom if you see that.
I know.
No, right here is the number that is associated with my file, Hulk Hogan, I know it is the number
that is remembered by your operating system and it is on your desk.
It does not remember, Hulk, when I go to temp and do it myself tr and right here, if I do that s
minus l tr i to find out the I note of this Hulk, it has a different I a..
Is it a different.
I'm not sure lisick.
That's minus l tr I and I'm going to home.
I have Sol.
Hulk, it has a different inroad, so this one is remembered as a different file and is remembering
and it's the link, it does not know that it is actually a file.
It just knows there is a link.
So this number is associated to a link.
Now, I will go to my home directory again, and this time I'm going to remove the Hulk.
Hulk is gone from my home directory right now.
I'm going to go back to temp directory and I'm going to see where my hulk is by the if I just type Hulk,
it will just give me Hulk Nachum.
So Hulk is there, but it's no longer blue or it's look crooked.
Why?
It looks crooked because the file is gone.
If I Dukat right now and do Hulk tell me what will happen though.
Such follow directory.
Of course there is no such flood because the link is removed, the source link is removed.
So the link will still linger around even though the source of the link is not there.
So it's better then I'll just remove the link as well and just verify it.
It's gone.
If I just wanted to do it myself here.
Just the Hulk.
Yeah, Sinophile.
So that's how the soft link works.
Now I will explain you how the hard link works.
Let's go and create our file again.
We'll call it Hulk Hogan and I will put something inside the file.
Echo Hulk is a super hero.
OK, I'll put that in Hulk.
I do a verified.
We'll just Dukat the file.
And yes, Hulk is a superhero.
The content is there now.
I will go into temp directories and I want to link to this file creating hard link.
You see, I'm not going with minus S option s stands for Link, so I'll do Link home.
I have TSOL Halk.
Link has created how do we verify you just run it, A.l, TIAR, and you will see at the bottom it's
telling me.
That the link is created now, the difference between this link, hard link and the soft link is that
there is no pointing to other file.
That is the difference of heart link, a soft link.
Now, if you are read if I read the content of this file, it says HOLC is superheros the same content,
everything the same.
Now, let me go back to my home directory.
I'm in the home directory.
Let's check that Hulk file and I will write down something else in it.
Now, Echo.
One, two, three, and then two, Hulk.
Let's read it, Hulk is a superhero, and then one, two, three in the line, I'll go back and to my
temp directory and Cat Hulk, and it is added here as well.
So what is telling us that you could modify the source file, you can modify the contents of the source
file, it will modify the destination link, which is perfect.
Now let's go to my home directory again, and this time I will remove Hulk.
All right.
Hulk file is gone.
He confirmed it.
It's not there.
Now, I will go back to temp directory and I will do it myself here again and you will see the files
still exist.
The link still exists.
And when we do Hulk and it does still have all the contents that we put it in.
Well, OK, so what is it telling us?
It's telling us that in the hard link, when you remove the source of the file, it does not remove
the destination.
So that's the basic difference is I'll go ahead and just remove this Hulk file as well.
The Hulk, the link as well.
So please do remember the difference between soft link and Hard Link Halfon.
Hello, everyone, and welcome back.
In this video, we are going to learn input and output redirects.
There are three different type of redirects and Lennix the first one is standard input, which in short,
as CTD in and it has filed the script a number at zero.
The second one is standard output and it has followed the script, a number as one and the third one,
a standard error.
And it has followed the script number as to please do remember everything in Lennix is considered as
a file, like a regular file as a file, a directory is a file and all those devices attached to your
learning system, for example, monitor, keyboard, mouse or any of those peripheral devices that are
considered are seen by the operating system as a file.
So when that file, when we actually write something on the screen from the keyboard that is coming
in standard input and it is actually knocking or knocking on the door for a while, zero file descriptors
zero.
And when we are showing that output on the screen, that output is actually going to the output descriptor
number one.
And two is if there is any error, it will show up as the file descriptor to.
We'll learn more about it in the next slide.
For now, we'll grab on to the output, which is a standard out one.
So by default, when running a command, its output goes to the terminal.
So we see that whenever you type anything on your screen as you are typing on your keyboard, IT output
shows on your screen.
So that's input is your keyboard and the output is your screen.
So the output of a command can be routed to a file using that greater than a simple sign.
So if you are typing something, let's say if you're typing a command, you could routt the output off
that that you see from the command to another file.
For example, let's say if you run ls minus L command and you run it on your screen, you will see the
list of files.
Right.
But you don't have to see it.
You can rotate to a file, save it to a file.
And for that you have to use a single uppercase sign which is called single redirect or the output.
Same way if you're running the command p W.D. then you could do the same thing without the output to
a file name, whichever file name that you decide to pick.
If using the same file for additional outputs or to append it to the same file, then use double size,
double symbols of greater signs.
For example, if you want one else minus L.A. and you want its output to also go to the same file name
listing's then use to greater than size.
And if you want to use a command, for example, Echo and you want to do Hello World, and you want
that output to go to the file name find path, which we used earlier for P WD, then you got to used
to greater than size.
Now the question is why can't you use one greater than signs or one redirect.
You can, but if you use only one and then it will overwrite your file, whatever, the content of the
file will be overwritten.
So if you don't want to get rid of the content of the file, you don't want to delete it, then you
use two grand sides.
So let me show you real quickly in my Linux machine how that works.
So I have my Linux machine right here.
I'm going to log in.
OK, so the first thing is, if I do this myself, you'll see all these files and directives that show
up.
Now, what if I want to move or a route this output to a file so I could do is this one cell output
with just a single output redirect and pick any name of your choice?
I'm just picking a listing's hit enter.
Now, you see, you don't get the output on the screen on the terminal because it has been rerouted
to the filename listing.
You could view the content of this file by using the command C.A.T., which is the command, is used
to read what's inside of a file.
So you Dukat listings and you'll see.
The contents of this file.
This is it's not actually the output of ellis' mysel, but now this has become the content of this file
now.
Similarly, if I wanted to use a command which tells me my path where I am right now, then I could
route that output as well so I could do a route that to a new file name find path.
Now you could do the same thing, cat find path and you will see it will give me the information that
output before which are routed to this one.
All right.
Now to redirect, which is to appending to the file.
So I wanted to run this command, Ellesmere's L.A. And by the way, when you run L'Esperance, L.A.,
it will give you all the contents of your directory, including the hidden files as well.
Hidden files are those that has dot in front of it.
You see right now, all those files are showing.
If I just simply run LSW, L.A., it will not show me the hidden box.
So in order to view the hidden files after use Ellis minus L.A..
Good.
Now I want to output this to the same file listing.
I could do this minus L.A. and a single redirect to listings.
If I do that, then the previous content that I had in listing will go away.
So if I wanted to keep those content as well as add these contents, then I have to use to redirect
it.
Now, if you go to Cadd on this thing, you're going to see a lot of output.
That's more the screen.
Let's go up, scroll up, see, the first content is still here, the second content are coming right
here, the both output into a single file because we use to redirect.
Let's say if I use one redirect, for example, I use less one redirect, rather less output is going
to look like this or else one redirect to Listing's.
And now, if I wanted to view the contents of listings, you'll see it only has those contents.
Everything else is gone.
That's why it is important that you use to redirect instead of one if you don't want to override the
content of the file.
Similarly, we have echo files.
So let's say I wanted to use Echo.
Hello, world, which is going to be which is going to echo back what I'm writing, so echo how the
world is going to echo back echo world.
If I wanted to write it to my file, I have to use to redirect it.
If I don't want again, if I don't want to overwrite that oil.
And I do find that that same file that I use hit enter.
Now, I could do find Pat and you'll see it has the part which I used it for.
This is the output of PWP and this is the output of Eckermann.
So that's the standard output.
Now, let's moving on to.
Input, which is standard input and the descriptor files, the script for this is zero input is used
when feeding files, contents to file or a script.
For example, let's say if you wanted to cat or view the foulest contents of a file listing, then you
could actually use Cat Command and you could specify the file name.
But in reality, if you just actually wanted to feed it bad, you could also do that by cat feeding
a bag the content.
Same thing.
If you want to use the mail program, for example, in order, Linux machine mail would give us this
option to to actually in indirect bring the content of a memo or a file into that program.
For example, if I'm using mail minus, it's like I'm sending email with the subject line office memo
and I'm sending it to all the users of the company, Ask.com.
Now, what is going to be the contents of that letter?
That content of the letter is actually written inside of the memo.
I could type all the content, but it's better I just redirect the content.
So that's what that input comes in.
OK, so let me quickly show you again by going back to L.A. machine right here, I did cat find pets,
right?
It shows me that TBWA Output and the Echo comment that we ran, the contents are in there now.
I could also do cat input, fine pet.
And it would give me the same information.
All right, moving on to the third one, which is the error, so it's just standard error and it has
a file descriptor of two.
So when a command is executed, we use a keyboard and that is also considered standard input, which
is zero.
And that command output goes on the monitor and that monitor is standard output one.
So if the command produces an error on the screen, then it is considered as standard error we can use.
It redirects to root those errors from the screen.
If we don't want to see those output of a command that has an error and we could route it to a different
file.
For example, let's say if I wanted to do what is the content of a root directory?
Now, of course, root directory is owned by a root, not by a regular user.
It will produce an error.
I could root that to a file, but I have to specify how am I wrong?
I'm only routing the standard error, not the entire output.
So that's why I specify to criticize and the file name of error file.
Similarly, I could use a program like Toweled Localhost and it's error message if it's not going to
be able to connect to that host.
I don't want to see that on the screen error.
Just wanted to go into the error.
Well, let's go back to our Linux machine and let's quickly take a look how we could.
Use the standard error.
All right, so first thing is, let's say if I wanted to run this minus El Slash route, this command
is basically what it's trying to do is is trying to list the contents of slash through directory.
And I am being logged in as who am I am logged in as I have TSOL.
So I'm trying to find what's inside of the actual directory, which is owned by route, by the way.
So let's see if I do this myself route.
See, it gave me permission denied.
This is standard error, the error that you see on the screen, which is telling you what would happen
when you ran that command.
Now, if you do not want to see that error message, then you could do is myself.
I'll put that to.
Aerofoil, that's just Tofile name I picked now that output is gone in there, if I wanted to view what's
in that file, I could do cat or file and you'll see that error message that was produced by the command
is actually routed into the error file.
Now, I would use another command, for example.
I wanted to tell that localhost is just a small program which actually allows you to connect from one
machine to another, just like S.H., which, by the way, will be covered later on.
So telnet localhost.
Which is my own host, if I hit enter, you'll see it's giving me that it is trying.
But then it says, hey, connect to address this connection, refuse, so this is actually the error
message, then it says it's trying again and it is trying the second time with this IP.
It produces the same message, connection, refuse.
Sorry, I can not connect you.
So it means from this output we have two errors right now.
I want to view these.
I don't want to see these errors on the screen.
For that I have to do is to let localhost.
I want standard error, which is file descriptor number two to output that to error file hit enter.
Now on the screen I'm only seeing trying one and trying one twenty seven zero zero one.
And the error message, where did it go to Arab file.
It went into that bar.
So please do remember these three input and output redirects.
These are very important.
You will be using them when you have to create scripts that are very useful in creating scripting and
automating tasks.
I'll see you in the next lecture.
Pipes, a pipe is used by the shell to connect the output of one command directly to the input of another
command, the symbol for a pipe is a vertical bar.
The command syntax is.
Command or the option or the argument, and then you pipe it to another command, whether it's option
or an argument, if there is any.
Basically, if you wanted to connect to commands together or if you wanted to take the output of the
first command and pipe it to a different output, then you could use a pipe in a Mac keyboard.
A pipe is somewhere the key all the way to the right that looks like that.
And a regular keyboard, you'll see the pipe option is right below the backspace and you could do,
I think, with the shift and pipe.
So the way it works is you have up, you have a command, it goes into a pipe and it comes out the output.
So let's say if you have less muscle, that's a command.
You run, you pipe that the exact same pipe character that you use and you put another command to it
to refine the output of your last command.
So let's look at the example in our Linux machine.
If we are in at directory, by the way, where we are, we are in our home territory, so if he if we
go into slash Etsy now, this directory has a bunch of files and directories, which you can have you
all in one page, it will display all at once, but everything will scroll up so fast that you wouldn't
be able to view one by one.
So when you do X minus Elter, you hit enter.
You see it went up so fast, what you could do, you can scroll up.
So of course when you do.
Scroll down slow, very slow.
You're going to see all those files, commands and directories that are inside of Etsy.
Now you want to view all of them one page at a time.
So how do you do that?
The way you do it, you put it in a pipe.
So you first you do a minus LTA, you pipe it.
And then there is a new command that I want you to learn, which is called Maw Maw, is the command,
which gives you the output of a file one page at a time.
So when you do that, a special TR pipe it and more it hit enter go.
Now you will see one page at a time of all the contents of Etsy directory.
And at the bottom it does tell you that it's more you hit spacebar to go down to the second page.
Space, Baragon Space Bar, again, wherever you are, you could quit out of it by hitting CU and you
will get your prom back again.
Let's do a Parakey hit, enter space bar spacebar space for space bar to go all the way down.
You could keep hitting the space bar and the your prom back.
So that's how you put in a pipe.
You could also do a pipe to have the output of command and change its output to a different way.
Let's say if you wanted to do Ellis', by the way, there's another command, which is a simple command,
if you wanted to learn is LML, which also give you the result as if you are doing a less mysel.
So you do L'il and you learn to command more, which give you one page at a time.
What if you want to get the last line of your output, then you run this mysel pipit and to get the
last line you would have to do till minus one.
It gives you the last line of your output.
Now tail is another command, which is also a cool command, which will give you the last line or lines
of an output.
So this is what the pipe is.
I want you to try a different command.