Welcome back everybody. Let's just continue. So the last time we used the change
directory command, and there were a few tricks to it. One of them is
basically using this this markation, so if I type in this, and if I press ENTER, okay,
I'm already in that directory. But, let's say that I was in root/boot/grub2, I
don't know, whatever. ls, yep, I am there. Anyway, how would I get back to my
home directory where my username is? What would I do? What would I need to type in?
Well, one of the first things that comes to mind is cd /home/RandomGuy
and I would be there. And if I want to go to the Downloads folder, I would
have to type in /Downloads. So this whole command I would need
to type in in order to go back to my home directory. Is there a shorter way?
Yes. So, basically, there is a shortcut. I know it doesn't seem too significant
here, but when you are deep somewhere in the system, deep in the file tree, typing
in these commands to go back and forth can be a tedious task, and knowing these
shortcuts can help you a great deal to, well, basically, preserve your nerves and
save time. So just type in a tilde there, you go, slash, and if I type in downloads,
there you go. I'm gonna go straight into the Downloads
folder from here, or I could just type in this. There you go.
If I type in pwd I indeed am in my home directory off the current user. Keep in
mind that the cd ~ will only take you to the current home directory off,
sorry, not to the current home directory there is no such thing, to the home
directory off the current user. So it won't take you to the, for example, you
had, let's go back a step, let's do an ls. So this is my user, but you can have
practically an infinite amount of users here. And if I typed in cd ~, it would
take me back, it would basically take me back only to this folder, as that
is my current user name. This is my host name. So this is the host name here, and
this is my user name. Just so you know what is signified here, and this is my
current directory so to say. The entire path is not listed, but the current one,
the name of the current directory, is, which is very, very nice.
Let's go ahead and clear the screen, and let's go back to the ls command. Now the ls
command has a large amount of arguments. So what are arguments to commands?
Basically, it's an additional instruction that you give to a command, which
modifies the way that particular command behaves. So, if I just type in ls, oh well
let's change the directory to root because I'm gonna have more stuff to
list there. And if type in ls in here, okay, so you see what
happens? I get a list of directories in this fashion, but that's that's about it.
I get a list of not just directories, I get a list of everything that is within
this directory which is root. But, so what? It doesn't tell me any information.
It doesn't tell me the size, it doesn't tell me the last date when it was modified, it
doesn't give me the permission, it doesn't give me the ownership, nothing. Okay,
let's try to change that. Let's type in ls space -l. So this -l is an
argument to a command which will modify its behavior. Press Enter, and there you
go. You can see how this particular listing,
this particular listing is completely different from this listing. Why? Well, the
lower listing, or the later listing, is far more verbose in
comparison to the first one. It gives you a lot more information, and it's really
useful. So this is basically the owner, this is the ownership group,
size, last date when it was modified. How do you
know is this a directory, or is this a text file, or something of a kind? A
file, or a directory, or whatever. So it says here, basically, the first letter
says directory, d. The first letter, l, it's a link. Do we have anything that's not a
link or directory here? No, I'm afraid we do not. Let's go into var,
ls -l. Do we have anything here, no. log? There's bound to be something here,
and there we go. So if it's just a -, basically like this, it says secure. Then you
can go ahead and open it. It's basically a text file. It's basically a file. It
doesn't necessarily have to be a text file. Everything is a file in Linux, but
it's not a directory which contains other files. Let's put it so. Let's open
it up. There is another command which you can use, it's called less. I'll
speak more about text editing commands and text display in the commands which
you can use for text displaying, but here I just want to demonstrate how you can
confirm that indeed it is not a directory. Rather,
secure, instead it's for...oops. What does it say? Permission denied. Hmm...
what could that be? What could the reason be that it doesn't actually allow us to list
the contents of the file name secure? What is the problem?
Well, let's take a look. The owner of this file is root, root group that is, and the
root user. Because this column here tells you who the owner is, which
user is the owner, and this colon here actually tells you to which group
group does own that file. Two different things. Let me just explain this further to
you. Let's say that a company has a Linux system running, and that you have within
that company a management department, and you have an
accounting department. So there will be users in the accounting department which
would belong to an accounting group, and there would be users in the management
department that would belong to the management group. So you would have, I
don't know, Kevin Smith who belongs, where it says root here it would have, I don't
know, Kevin Smith that belongs to the group accounting. You also have this group
which I have explained here which is root, that is fundamentally for control
of all things on the system. Root is pretty much is almighty, there is
nothing that is beyond the grasp of root. Anyway, let's just go ahead and
clear the screen here. As I said, I will deal later on more with text editing
commands, and how you can create files, edit them, and less. For the time being, I
just want to show you ls and explain it further. So, ls -lha,
excellent! So what has changed? What can you notice that has changed in the
output of this file? It says 4 kilobytes, 4 kilobytes again, 12
kilobytes. These files are pretty small, there's nothing in megabytes here to
show, but it doesn't matter. This is basically a human readable format of the
file sizes. Look at the difference. Okay, so how easy is it to read this? You
have to compute, basically, to figure out the file size. I mean, you know it's pretty
small here so you can say it's 4 kilobytes, but I mean imagine if it was,
I don't know, 4.5 gigabytes were represented in
kilobytes. That would be hilarious because you would have a huge number
here, and you would basically need to compute how much is that in gigabytes
which is absurd. Rather instead, you can just add h to the LS command, the
argument h, and you will immediately get the file sizes for pretty much all of
the files here. One more thing, you have a which enables you to list pretty
much everything. If there are some hidden folders they will be
listed, rest assured. You can also say that it emits these two, if you want, but
that's not a big deal. Rather instead, this is your current directory,
it represents your current directory, and this one it
represents the directory which precedes this one. So, dot and double dot. I've
shown that with the CD command. Anyway, let's go ahead and clear the screen now,
and type in ls - -help. This is a universal way to get more
information on what a particular command does, and what sort of arguments can you
actually pass to that command. You can also try typing in -h but that's not
gonna work for LS. You see just prints things. Rather instead, just type in - -
help. Most of the commands will accept -h, but - - help is more
universal. Let's put it so. If I press ENTER, I don't have a listing of the
current directory, rather instead I have a help menu which pretty much
gives me the list of all arguments. It tells me what each of those arguments
does, and on top, let me just show you, on the top it gives me the example of usage.
Very nice, right? So LS, and then I pass in the option which is one of the arguments
below, and you might notice that there is also a file here. So, what could this mean?
Let's have a look. But before we do, I would strongly recommend to all of you,
these are these things are pretty simple, just feel free to read through this,
through some of them. You don't have to read through all of them. The ones that
you will be using on daily basis will be the -a, the -h of course,
the -h which is right here. Also, you have the long version of the
argument. So instead of -h you can also pass this long version of it, but I don't
think that there is ever a need for such things. It doesn't have to print out group
names to shorten the output if you want. Okay, so what else are we going to need
to do? Let's see if there's anything else.
There is definitely something. Ah, there
we go, I knew I was looking for something that
I wanted. -R is basically recursive, so lists subdirectories recursively. Now
we're going to try to use that as it's gonna come quite in handy. Look at what
I'm going to do. So, clear. If I type in from here ls ~/home,
sorry, I don't need hope I'm already there. Let's go to downloads. Yeah, there
we go downloads, and there is literally nothing
there. Okay, forget about that. Let's go ls, just off the root directory, and then type
in /var. Okay, so I have just told it to list the contents of the
directory var, press Enter, there we go. Even though my current working directory
is var/log, I have stated that I want the directory to be a list, that
the contents of some directory should be listed, so here you
can actually specify a path direct to the directory you wish to see. So you can
see the contents of any directory on the system, from any location on the system,
as long as you have the proper permissions to do so. Let's try something
else, let's try ls -R /boot/
This is gonna give you a lot of information. Where is it,
where is it? It should be around here somewhere, there we go.
So, there we go, ls -R, for recursive output, space path to the file,
path to the directory. Okay, the first thing that it does, it gives me the
listing of /boot. Second thing that it does, it gives me the listing of /boot/
grub2, and then it shows me what is in that
directory. And then you see the directory grub 2 has a sub directory of
fonts. The next thing it does, it does boot, grub2, and then fonts, and then it
shows me the listing of that particular directory, and so on and so forth, as
long as there are sub directories to the current directories. It shows the entire
listing of pretty much everything. A fantastic way to go about things and you
are able to see pretty much anything, anywhere. Anyway, I shall call the
tutorial here, and then we will continue in the follow-up.