In this lesson,
we're going to go over entering commands in shell.
Now, a shell surrounds the core portion
of the operating system, which we call the kernel.
It allows the user to pass commands
and information to the kernel,
and the kernel also responds back to the user via the shell.
Now, the shell can be thought of as an interpreter
between the human and kernel languages.
So it pretty much it translates our commands
into something that the computer can recognize and use.
Now, the first command we're going to go over
is the echo command.
The echo command only repeats
exactly what it's been told to repeat.
So for example,
I'm going to do echo.
"Hello,
world!"
Voila.
Typically, you're going to use echo in the script.
So for example, whenever the script is going through
and completing all these processes,
sometimes you want to displace something to the user.
Just say, "Update complete, update successful."
You're going to use echo and put the information in
after the results are complete.
Next, we'll use the present working directory.
That's simply PWD.
It just lets the user know
which directory there is currently working in.
So for example, me,
I'm currently working in my home directory
under my profile.
Next, we're going to go over the list command.
What this simply does is print out a list
of the files and folders
that are currently in your present working directory.
So as you see, right now, we just have
just a skew of folders that are currently
in the working directory now, desktop, documents, downloads,
music, pictures, et cetera.
If we want to see more information, we're going to do ls -al.
Now, the A portion of it stands for the hidden attribute.
So whenever you use the A option, pretty much,
it lets you see any file or folder that's hidden.
Now, most of these folders aren't hidden
because of security features.
It's more just to keep the folders looking clean
and remove the user from things
that they typically won't be using.
Now, the L, which stands for the long,
what that does is gives us more information, as we can see,
and so if we look at this screen right here,
we'll see a lot of information to the left.
For example, if we look at the top line, we'll see drwx.
Now, the D stands for the directory,
R is read privileges,
W is write privileges,
and X is executables.
Now, going from left to right,
we'll see that there's multiple sections in the fields.
So in the first section, again,
it's going to be either directory.
Now, if you see a dash there, that means that it's a file.
The first set of rwx's, that's for the owner of the folder.
The next set will be for the group.
If there's a group associated to the file,
those are the privileges that the group will have,
and then the last will be for any other user,
so anyone that's not part of the group
and that's not the owner.
The next field's going to be the links,
the amount of links associated to the file or folder.
After that's going to be the owner.
After that's going to be the group associated with it
'cause, typically, when you create a user profile,
they just all automatically get created as a group as well.
Then you're going to see the amount of bytes
and then the date it was last modified or created,
and then, of course, the name of the directory or file.
So the next command we go over
is the change directory command.
Let's simply cd.
We'll go to the etc directory,
and we'll confirm that with the present working directory.
Now, you can see that we're in the etc directory.
Another one that's very useful is the var log file.
Now, this is where all of these system logs
are typically stored, and if we want to list them out,
of course, we know ls,
of course, for more information to see the hidden files
and more information about 'em.
We add those modifiers.
The next command we're going to go over is the touch command.
Now, if the file already exists,
it will update the modification on it,
but if not, it will just create it.
So we'll do touch myfile.
Oh, see, now, we're in the wrong directory.
So we don't have permissions for that.
So let's go back to my home directory.
Touch myfile.
And then we're going to ls it out,
and we can see the myfile was added.
Now, the next command I'm going to go over is the cat command.
Now, it stands for concatenation,
and what it does is print a display of the information
that we're trying to see.
So for example, we're going to look at a host name.
So this file etc/hostname,
it prints everything out on screen.
That file is very small,
and so it shows only what's in that text,
and it's only one line so it's not too much.
Now, there's going to be examples
where we're going to have files that are very long.
So we're going to use the less command,
and we're going to try the var log file, dmesg file.
Now, this file, again, is very long.
So when we use the less command,
it allows us to use the space to scroll entire pages
or we can use the up and down arrow
just to go one line at a time
or, again, the space changes everything
or to do one at a time,
and we use Q to get out of that,
and, again, if you want to see it with the cat,
you'll see that
we can't see everything on there.
It'll just go to the very bottom
of the screen and only show one page.
So the less command, again, is used for longer files.
I'm going to use Q to quit.
Next thing I want to do is go over the vim command.
Now, the vim allows us to edit a file.
So I'm going to use the same file that I had earlier, myfile.
Now, in order to insert information,
we're want to press the I key,
and for this example, we're just going to say,
Hello, this is Jamario.
Okay, now, to get out of there,
we're going to press the escape key,
and to save, we're going to hit the colon,
write, that's wQ, quit,
and using the command from earlier,
we're going to use cat myfile,
and now, we can see the file displays,
"Hello, this is Jamario,"
and that's what I just wrote into the file.
Now there's other text editors
that we can use another one being nano.
So we're going to do the same thing,
but we're going to create another file called myfile2.
Now, with nano, you just go right into insert.
So do Hello, I am nano
for this...
Simple enough.
Now, to save your information,
you're going to do Control + O
or you'll confirm that with inner file name to write to,
and to get out of here, we're going to do Control + X,
and again, we're going to view the file.
We want to see, "Hello, I'm using nano for this file."
So it's saved and everything was successful.
Clear the screen.
Now, there are going to be times that we need access files
that a regular standard user won't be able to access.
So then we're going to have to switch to the root user
to get that information.
So let's try this out really quick,
cat/var/log/boot.log.
Now, we see that we can't do this as a standard user.
So what we need to do is switch to the root.
So we're going to use the command su - root,
and the su stands for substitute user.
So here, we're going to put in the root password,
and now, we're root,
and now, we're going to try this command again.
So we're going to do cat /var/log .log.
And now, in this example, when you first enter,
that means the command was executed.
If there's no feedback, you know it executed correctly,
but for this example, the boot.log file is empty.
So let's see which file is not empty,
and now, we can see another boot log
with a date stamp to it,
boot log 20220517
var
log-20220517.
And now, we can see the information
that's associated with that boot log,
and next, we want to exit out of this.
Exit switches back to our regular user account.
So the next thing we want to do
is to leverage the tab completion command.
We'll use the example by creating a long file name.
So I'm going to name this
thisisalongfilename.
All right, we'll verify that created.
Now, the tab command autocompletes
any type of command or file name.
So we're going to ls this out,
and all we're going to have to press is the th,
the first two characters of the file name and press tab,
and it'll autocomplete.
Again, this is just another convenient feature Linux
which makes type of commands very efficient.
Next thing we want to do is to use the history command,
but we're going to tab that out,
and the history command just shows you a list
of all your most recent commands.
So it'll be easier to jump back to a command.
Maybe you forgot, but we also know that we can just arrow up
and arrow down as well for those commands.
So again, just want to note,
tab completion works on commands,
file names, and directories.
Last thing want do is reboot the system.
It's going to be a common feature.
Okay.
All right, we're back to our home screen.
So thank you for walking through this lesson with me
on entering shell commands
and I'll see you in the next lesson.