Imran: Each file or directory in Linux
has detailed information,
or, in operating system language, properties,
associated with each file or directory.
In this video, we are going to look
at Linux file or directory properties.
Now, what are the properties?
Let's look at the example of our Windows,
so to understand what properties are we talking about.
So in Windows, we have this folder.
How do we know it's a folder?
Because it looks like a folder, right?
In Linux, you're not gonna be able to tell
if it's a folder or not.
So if you go inside of this folder by double clicking it,
and there's another folder called data.
Now, when you do right click on this data folder
and go to properties, you will see all that information
associated with this folder.
It tells you it's a type, it's a file folder.
Where's it located, the size,
who created it, when created it?
Sharing, security information, who owns it?
Previous version, customize all those information
that is associated with the folder data.
Same way, if you go inside of the data,
you see there are two more files.
How can I tell these are files?
Because it doesn't have the shape of a folder.
So it's so easy to tell in Windows.
So you right click and you do properties.
You find the same information,
the location, the name, it's a text file, it's a notepad,
zero size because nothing in there, when it was created,
when it was modified, and so on.
So much information.
All these and associated information
to a file or a directory is called its properties.
That's what this whole lesson or this whole video is about.
Now, in Linux, when you run the command ls -l,
you get these list of columns.
Now, on the very right, you'll see the name and a directory
of a file, or of course, the name of the directory.
Now, each directory or file
has all these associated properties to it.
The very first column tells you the type of a file.
Now, anything that starts with D, it means it's a directory.
Now, as I was telling you,
when you are in Windows environment,
you could tell that it's a directory
by looking at its image, right?
It looks like a folder.
But in Linux, you cannot tell.
Then, the only way to tell if it's a directory,
if it has this D in front of it.
Then you could tell, ah, the var is a directory.
Similarly, if you see anything in the type column,
which is the first column, it starts with L,
it means it's a link.
The bin file is a link to another file.
And when it comes down to the third one,
where it starts with nothing here,
then it means it's just a regular text file,
and this is the name of that regular file.
There are many different file types in Linux,
which, by the way, I will cover later on,
and it is included in this course.
But for now, I'm just going over the properties
of a file or a directory.
Now come down to the second column.
Second column is the number of hard links to the file.
For a directory, the number of hard links
is the number of immediate subdirectories it has
plus its parent directory and itself.
So all the directories that it has
and its parent directories.
Combining all of that, it tells you the number here.
But if we want to know more about links,
links is another topic,
another video that I'm covering later on.
Now, the third column.
Third column tells you who owns this file or directory.
Right here, it tells you root is the one who owns it.
Group, which group owns this file or directory?
Right here, root.
If I am the user, like iafzal,
then it would show here iafzal.
The size of the file or directory,
when it was created, the month, the day,
what time it was created,
and of course, the name of the file or directory.
All right, so let me go log into our Linux system,
and then we will run the command to view all the properties.
So I have my Linux machine right here.
I am logged in as myself.
When you run this command, who am I?
It means you are asking the system,
give me the username of the person who is logged in.
All right, now which directory are you in right now?
You do pwd.
It tells you you are in /home/iafzal directory.
All right, how many files and directories
do I have in my home directory?
Let's do ls, and it will tell you,
these are the files and directories you have
in your home directory, which is /home/iafzal.
Now, what if I wanted to know all the properties
associated with all these files and directories?
Then I will do ls -l
Beautiful.
Now you see it's telling me that right here,
this is the type of the file, these are the link,
who owns it, which group owns it, the size of the file,
month, date, and time the file was created
or directory was created, and here is the directory.
How do we know it's a directory?
Because it has this D in front of it.
Excellent.
Now you see all of these directories right here
are listed here except this one.
There is a file called somefile.
It doesn't have a D in front of it,
so it means it's not a directory.
So if you try to go inside of this file,
even though it's not a directory, what will happen?
Let's see.
cd somefile.
It will tell you, hey, it's not a directory,
so you cannot go inside of this directory.
You got it?
Now, let's say if you wanted to do same thing,
cd to desktop right here.
This is a directory, right?
cd desktop, hit enter.
It lets you in because it is a directory.
Now you wanted to see what's inside of this directory,
you do ls.
There's nothing in there,
and if you wanted to come back to this directory,
you could do cd dot dot, come one step back.
Anyway, these are the navigation commands
that we have learned.
But anytime you wanted to see the properties
of a file or a directory,
you will have to run the command ls -l,
and it will list all the properties,
and through the properties, you could tell
that what you need to do with the file or directory.