Let me start, guys, by explaining you Structure of Linux file system.
Linux files and directories are located in a tree like structure at the root.
There is a root directory that is represented simply by forward slash.
Then this root directory has some subdirectories like bin as bin and so on.
Those subdirectories may have own subdirectories and also files.
It means that every directory could be considered as a branch of this tree and every file is a leaf.
And again, all those branches and leaves start from root directory represented simply by forward slash.
When any user logs into Linux system, he or she actually logs into own home directory.
And the home directory of every user is represented by tilde sign.
That's why we see the sign here after logging into Linux system.
All right.
Next, you could find the current directory you are currently in by entering the following command.
P.
W.
D.
That stands for print working directory.
Let's press enter.
And now I see that I am located in slash root folder.
Please notice that absolute paths in Linux start from forward slash and here we see actually absolute
path to a specific folder to a specific directory.
If I go to other ubuntu virtual machine and type p w here, I will see that home folder for this.
Bogdan user is different here and it is slash home slash Bogdan.
And this path differs from this path and difference here appears because here we are logged in as root
user into Linux docker container and in this case I'm logged in as regular user and home folders for
all regular users are located in the home folder located in the root directory.
All right, next command.
You are able to CD to root of the file system in Linux computer using following command CD and forward
slash forward slash represents root directory in any Linux operating system.
Let's see DB2 root directory and notice that the command prompt here was changed and now see forward
slash instead of tilde sign.
And if I type p.w.d. here now I'll see that now I'm located in root directory.
You could always go back to your home directory for your logged in user by entering simply CD like this.
And now I'm back into home directory and if I type PWD, I see path to my home directory.
For this root user it is simply slash root.
All right.
That's how you could change directory and move either to home folder or to root folder.
Next, let me demonstrate you how you could move into specific folder.
For example, if I list the files and folders here in home folder for this root user, I will see actually
empty list.
And that means that there are no files and folders inside of the home directory for this user.
And if I go to root folder like so and list files and folders here, I'll see such folders as home media
and so on.
If you want to go into specific folder, for example, let's go into run folder.
You could type, CD and type I is a relative path or absolute path.
If you are already located in specific folder, you could use relative path.
And in this case I could simply type run like so.
And now I'm inside of the run folder and if I enter P.w.d. now I will see that now I'm inside of the
slash run folder and this path that starts with forward slash is absolute path and you are always able
to go into specific folder using absolute path to this folder.
Let me show you that.
For example, let's list folders here and let's CD into mount folder like So here again I'm using relative
path and now here if I'll enter CD forward slash boot, I'll go into the boot folder located in the
root directory enter and now I'm inside of the boot folder.
That's because I have just used absolute path.
All right.
That's how you could move into specific folder using relative path or absolute path.
Also, let me show you now what is the meaning of dot and two dots here.
When you use CD command, If I type simply CD and dot, nothing will change because Dot represents current
working directory.
This directory CD in this case slash boot.
But if I type CD and two dots, I will go one level up to the parent directory and in this case I will
go to root directory CD two dots, and now I'm inside of the root directory represented by Slash.
All right.
Let me now show you how to use Tab in order to autocomplete names of the directories and files.
If I type here, CD slash and press tab twice, I'll see all possible directories and files that are
located in the root folder.
And if I type for example M and press tab twice, I'll see all possible directories and files that start
with M.
If I add additional letter here and press tab only single time, I'll see that this folder name will
be autocompleted to media.
That's because now there is just a single option that starts with M.
All right.
If I press tab twice now at this moment of time I see actually empty list.
And that means that the media directory does not have any subdirectories.
Let me remove media from here and let's go into folder like so and if I press tab now twice I see all
possible options of file names and directories that I could use after e.t.c..
And for example, here I see as l folder.
And if I type here esky and press tab, I'll see that the directory name will be autocompleted to L
if I press tab.
Now here I see that there are only files called dot bash log out, dot bash RC and dot profile and there
are no subdirectories inside of the SRC directory.
All right, let's suppose that I want to go into this directory for this.
I'll remove this last dot that was autocompleted and press enter here and now I'm inside of the src
directory.
Let me clear terminal and if I enter PWD, I will see this absolute path that starts always with forward
slash.
All right.
If I want to go out from this SRC folder, I could simply type CD and two dots.
It will go one level up to directory.
Let me go back to CD here.
I could use relative path because I'm already located in directory and press enter here and let's suppose
that I want now to go to another sub directory of directory.
For that I could simply type CD two dot, then forward slash and if I press tab twice here at this moment
I will see all possible directories and files inside of the folder.
And for example, let's go to dpkg directory.
Let's start typing d p press tab.
Yes it was autocompleted.
Let's press tab twice here and I see that this dpkg directory contains origins sub directory.
Let's go into it.
I could type simply o and press tab.
It will be autocompleted and let's press tab twice here and I see several files.
Notice that at the end of every directory there will be forward slash.
And that's how I recognize that this is directory and this is also directory.
But this is file.
And now I see that this origins directory contains only three files Debian default and ubuntu.
All right, let's press enter.
And now I'm inside of the origins directory.
That's how you could use two dots in order to go into parent folder and go into some sub folders of
that parent folder.
Great.
Let me type simply CD and I have returned back to my home directory and type CD.
I'll see that now I'm again inside of the slash root folder.
And again this directory is a home directory for root user and please notice that there is difference
between slash root directory and simply slash directory.
Slash directory is a root directory for all files and folders in Linux.
It is a root of file system in Linux, but slash root is sub folder that is located in the root of file
system in Linux and it represents home directory for root user.
Please keep in mind that.
All right, that's all what I wanted to explain you here in this lecture and now you understand what
is the difference between root directory, absolute path and relative path and how to locate the current
directory you are currently in.
That's all for this lecture.
And next, let me explain you how to manage files, how to create new files and how to list files.
I'll see you in the next lecture.
Bye bye.