Now a lot of times in Linux,
we're going to have to do operations
on the files that we create
but the most common one is just to view them.
Now, in this example, we're going to use the log file
because we're going to tend to spend a lot of time there.
So we're going to test out two versions
of how to view these, the cat, which stands for concatenate
and the less command.
Now the original use of cat was to join two files
or put the contents on one file into another
but we typically use it to view small files.
So we go see what happens when we use it
with the larger type of file.
Now we say we see a lot of the file,
but we don't see all of it.
Now we can scroll up with a scroll bar
but there's more efficient ways to do this.
This time, we're going to go through this
by using the less command.
Now we see with this display
we can easily put everything on the same screen.
Now to scroll up and down, you can use the up down arrow,
or you can use d,
page up and page down, if you want to use full pages,
space bar also works.
Now you see this command prompt
a colon pretty much at the bottom left.
You can search through this as well.
So do /SELinux
and now we can search this file as well.
So less has a lot more features than cat
and is typically used more.
Now, if we want to go to the next instance
of the particular search results that we use,
I want to use d n.
So I'm just tapping in the n key
to go to the next result.
If I want to go back, I just use the capitalization,
So shift n.
To get out of this can use quit.
I'm going to press the q key.
Now, another thing that we can do is use the head command.
Now head and tail defaults to 10 lines.
So this is very useful,
if we know we only want to see the top portion of a file
typically want to use the head
for something that's repetitive,
so we don't really need to,
it gives us enough information to get the gist
of what we're looking at.
And the tail is usually used for logs
to see the most recent occurrence of something,
'cause that's typically when we're trying to
track something down.
So I'm try this really quick,
I'm going to do head /var/logs/messages
and see it gives us the first 10.
Now we can also set the amount of lines
that we're going to use.
So let's try this,
lets use sudo head,
use the n option,
I'm just going to do five lines.
So now we see that we only get the first five lines.
Let's try the same thing for tail.
So we get the bottom 10 there,
clear the screen to make it a little easier for us.
Let me try this one more time,
and we only want the first bottom five lines.
Okay, we can see how that works.
Next, I'm going to walk you through the process of moving files
from one location to another,
how to create a directory
as well as remove an existing directory.
So on this example, we're going to look at the options folder.
So let's view this really quick,
list up options go to linuxplus.
Now I have five different
acceptable use policy files in here.
And so we're going to copy these over
into our home directory folder.
So we're going to use the copy command
along with the r option that's for recursively.
And then remember we're going to use this tab
to make sure we're getting things together.
All right.
So we want to copy everything
in the linuxplus folder,
again that's what the recursively option is for.
We can just use the tilde symbol here
and create its own directory,
in our home directory,
we should now see a folder called linuxplus.
So we're already presently in our home directory
'cause you can see the tilde symbol
at the end of the prompt.
So we go ahead and list things out
and now you see the linuxplus about four files down
that directory was copied over.
So we can list that out, see what's in there.
Remember it's relative path,
we don't need to put the forward slash
and we can see successfully copied every file that was
in the options linuxplus into our home directory
and named it linuxplus as well.
It's going to automatically just use
the same naming convention
that was used prior when using the copy command.
So we're going to make a new directory,
we're going to name it policies.
Make sure that it got created,
Okay, we see that there.
So we're want to see into the linuxplus folder,
and then again, let's list this out.
It's clear, so we're going to move the
acceptable use policy V1,
we're going to move it to the policies folder.
So the two dots mean we're going to go back
to the parent directory,
which is going to be our home folder,
that's where the policies folder live.
We're going to do the same thing with version two.
Okay, so we list cd into the policies folder
and list everything out.
Okay, we see that was successfully moved over.
Now with the move command, is different from the copy,
It doesn't keep the existing object in place,
it actually deletes it from this current location
and creates it in this destination.
So if we list out the linuxplus
and we see we moved the acceptable use policy
version one and version two.
So again, the move command removes the current object
from its source and puts it a destination.
Any copy keeps the object in place,
but just makes a replica of itself
in the destinated location.
Now we're going to go through and create placeholder files.
So we're going to use the touch command.
'Cause remember this one allows us to create a file,
we'll just name it aup under score, we call it new.text.
We can create a few of those.
Okay, so list this up.
We can see those were added.
Okay if we use the concatenate
we'll see that they they're empty,
there's nothing in those, so.
Or again, we can list it out,
we just see zero bytes on them.
Okay, now what we're going to do next
is we're going to try to remove this linuxplus folder
'cause we no longer need it.
We brought it over just as a placeholder
and then we wanted to put everything to our policies folder.
So let's go back to that.
So going to cd, going to go parent directory, linuxplus,
all right so we're going to see that those
three files are still remaining,
and we're going to try to remove this directory.
Okay, so now there's a remove directory command
but it's only useful and only able enable us be used,
if the current directory you are in
or trying to target is empty.
So we're just going to test it out really quick to see.
So let's say tilde, that means our home directory,
do linuxplus.
And if you look at the error
it says failed to remove because directory is not empty.
So in order to do that,
we're going to have to use the remove
with the recursive option,
tilde, linuxplus, and we see that it went through.
So if we go through back to our home directory
and we list it out,
we should see the linuxplus folder is now gone.
So we're going to do a clean example of just showing how
if you make a directory, that's empty,
going to call it test directory, list this out,
we see the test directory about three from the bottom there,
and now we're going to use the remove directory command.
Again list it out, see it's gone.
So that sums up this walkthrough,
and I will see you in the next lesson.