In this lecture, we'll learn the basics
about the Matco S command line
interface, specifically the terminal.
So how can we interact with our Mac computer,
with the command line?
For this the first thing we'll do
is we'll bring up the command line interface
Mac computers ship with.
And this is the so-called terminal.
To open the terminal,
as basically for any program on Mac computers,
we can simply open the spotlight search with command and
space and there search for terminal.
With enter we can then open a new terminal window
Like this here.
And I'll use command plus to zoom in a bit to make it better
readable for you and maybe put it right here.
Now, before we dive deeper, one quick note.
As you saw, we just opened the terminal,
which is the command line interface, the Mac offers.
But you can also find this zat sh word up here.
Once the terminal is so to say the hardware.
So basically this thing here,
which allows us to run the commands in the end.
The zat sh, the zat shell
is the software inside the terminal.
That's basically how you can remember this.
So you open a terminal and the terminal runs the zat shell
software to then execute the commands we enter.
I don't want to dive too deep here
as it's not important
for the purpose of this course.
But if you select the terminal window,
you can see the terminal up here and the shell over there.
Therefore the differentiation between terminal and shell is
something you might come across.
Therefore, I wanted to mention this.
Talking about this menu options.
If you click onto the shell, you can see
that you have multiple options in here.
One interesting option is
while the option to open a new shell
or a new terminal window,
I use both interchangeably now.
And in here you can either open a new window
with the basic profile,
which will be this white one here,
or with any other default profiles
the Mac computer here ships with.
For example, if I select this Homebrew profile.
You see, I have this well, black
and green look doesn't change anything about the logic.
As you see, it's still the zat shell.
It just looks different.
If you want to close the terminal window, you can,
of course also go to the shell up here
and select the window you want to close
and then press close window.
So with that, we opened this terminal.
Now I also want to open a finder window to show you
the contrast between the CLI
and the GUI, the graphical user interface.
So let's open a new finder window.
Here we go.
And I selected Academind's Mac mini option here
on the locations.
There you should also find your computer.
If this is not the case, make sure to select the finder,
go to define their option and there to preferences.
There select the sidebar which I selected already.
And there under locations make sure to select your computer.
So tick this box next to your computer's name.
Then you can close this window
and then you should also find this option.
It's important to have this option
because if you selected,
you should see something like I have right here.
Maybe without the Scarlet option,
but you should find your well Macintosh HD,
and you can select this.
Now we have on top the CLI, at the bottom, the GUI
and whilst for the GUI,
we see that we are inside this Macintosh HD folder now.
I'll come back to this folder in a few minutes.
We have no idea where we actually are in our CLI.
Well, as its a command line interface.
This means we run commands to tell our computer what we want
to see or what we want to do.
We can run our first command to see well,
where we currently are.
The command I want to run first is PWD.
This stands for print working directory
and tells the machine to well print where we currently are.
So which path we currently follow
on our machine.
With enter we can confirm this command
and you see that we are currently
in slash users slash Manuel Lorenz.
Now this doesn't help us too much, I guess,
but if we go down to the GUI into this HD folder.
Then we also have this user's folder, which we can select.
And now this looks different on your machine,
but you should find your user name right here.
And if you click onto this user name,
well, then my assumption would be that we are currently
in the same folder.
We are in slash users in the CLI
and in the user's folder in the GUI.
The problem is that in the CLI we cannot see the folders
and the files, this folder contains.
Now that's actually the next command we could run.
So we could tell our computer, well,
please show me what this folder,
this user folder here contains.
We have a command for this.
And this command is LS. LS stands for list items.
And this lists all folders and files inside the folder,
where we currently are.
This is the folder.
With enter we can also execute this command.
And if we take a close look,
we can see that the folders we in our CLI are equal
to bonds in our GUI at the bottom.
And that's a very important takeaway already.
The logic or the way we interact with our computer
is the same for the CLI and the GUI.
So for the computer the commands are basically the same.
By clicking onto this user folder, I see the folders
it contains.
By entering LS, I see the files and folders it contains.
So it's the same logic,
but without the graphical user interface.
Which allows us to have this, well, nice clicking feature.
And also to get a nice overview of all the folders
in the hierarchy and so on.
But it doesn't make a difference
from a system point of view.
We can have the same access with the CLI that we get
with the GUI.
Talking about access.
Let's come back to this Macintosh HD folder
or option that we have right here.
Because if we select it we see
that we have different folders in here.
And at least this applications library system
and user's folders should be the same on your machine.
This directory, this folder, is the so-called root directory
of your computer.
So it's the top level directory.
So to say on your hardest drive.
And if we look at the so-called (indistinct)
that we had up here.
So this slash users slash user thing.
We see that the working directory printing logic
always starts from this root directory.
Because basically here we are in Macintosh HD slash users.
And then so on Manuel Lorenz.
We can also navigate to this root directory easily
in our CLI at the top.
We can simply enter CD for change directory.
Now, a space, and now a slash.
This brings us to this root directory.
If we press enter.
And you get the hint that we are in the root territory
by this slash right here.
And now I've been running PWD again, you see,
we are in slash.
This means we are in the root directory.
I can prove this to you by again, running LS so list items.
And there you see, besides some hidden folders,
which are displayed in the CLI, but not in the GUI.
We have the applications folder, the library folder,
the system folder, and the users folder.
Just as we have these folders down here
in our graphical user interface.
Besides this root directory or this root folder,
we also have another very common directory,
and this is the directory of the currently active user
of this MacBook. In my case, myself.
And that's the so-called home directory.
The home directory for my username is this one here.
So if I click onto my username,
that's the directory you are navigated to
by default when opening the terminal.
And we also have a shortcut to navigate
into this folder in the CLI.
And here, the shortcut is simply CD.
So change directory without any additions.
If I do this, you'll see that we have
this tilde symbol here.
Which indicates that we are in the home directory.
And (indistinct) again, type LS you'll see
that we have all the folders that we see
in the GUI also in our CLI.
So these are some more basics,
root directory and home directory to easy to understand
where you are in the terminal.
We also had a look at this CD command now.
Now, besides navigating into the root directory
or into the home directory.
We can also navigate one level up
by entering CD in the space. And now two dots.
We can leave the home directory in our case,
we are currently in this directory.
And with that move up one level to slash users.
Now we are in here.
To make this better readable,
by the way, we can also run clear like this.
If you confirmed this, you see
that all previous commands are no longer displayed,
But you can scroll up
and still see all the previous commands are there.
It just clears the current view of your terminal.
Now we've CD dot dot. We navigated one level up.
If I print the directory,
you'll see we are indeed in slash users.
If I type L S again,
you'll see that we have the same folders
that we can see in the user's directory
in the graphical user interface,
Besides navigating to the root directory,
the home directory, and navigating one level up.
We can also use C D to navigate into a specific folder,
starting from the current folder.
This means, in my case, we are in the user's folder here.
So I could enter M and now hit tab.
And now I get the options we have.
Now I see that I can either navigate
into my user folder or max user folder.
I use my folder. So I'll type an A now.
Now, an A is unique in this folder structure.
No other folders start with M A
therefore, if I hit tab once again.
I can confirm this with enter.
And now I am back in my home directory.
Now, inside this directory, I could see what I have
in there.
So we see we have plenty of folders.
We could say we navigate into the documents folder now.
So this one. Let's do this by entering C D once again.
Now enter D O C because we also have two downloads folder.
So D O C again, is the documents folder. And a tab.
And now we are inside this document's folder.
We could also add another folder.
Like test here slash and so on to navigate
into this folder too.
We don't have such a folder here.
Therefore, we'll just go into the documents folder.
Let's do this.
Now we see that we are currently in the documents folder.
And there we could also list our items once again.
And now we get a warning that our terminal would like
to access this documents folder.
So we can confirm this.
Therefore we see in this folder, well,
we only have one folder in one file at the moment.
We can, again, also confirm this in our GUI.
So many Lorenz documents, only this folder.
So this is the navigation part.
But as we don't have any files and folders,
besides this adult folder, in my case.
Why don't we add a new folder and then a new file
inside of this folder as a next step.
We could do this with the GUI.
But it's also possible from the terminal.
To create a new folder inside the current location,
you can simply type M K D I R,
make or create directory.
What you then have to enter is the directory name.
So we could call this
WEB DEV minus course, maybe.
And with this, you already see the confirmation in the GUI.
We created this new folder.
Now we can navigate into this folder with well CD.
And now we type web, and now with tab we can complete it.
Confirm it with enter.
And now we are inside the WEB DEV course folder.
Now let's add a file to this folder, maybe.
And we also have a command for this.
The other command is simply touch now a space.
And now we add the file name, including the file extension.
I would like to make things easier.
So I would simply create a dummy dot text file.
Let's run this command.
And with L S now we should see
that dummy dot text was created.
And indeed it was.
We can, again, confirm this in the WEB DEV course folder.
There. we see this file.
Let me now clear this once again.
And besides creating folders and files, we can,
of course also delete folders and files.
A little warning here. This is just a quick introduction.
Therefore, I will not dive too deep into this deletion part.
But if you delete files or folders via the CLI,
you have no trash or anything like this.
So you barely have a chance to recover any deleted items.
So you should be sure what you delete.
Therefore, I'll show you the command,
how you can delete files and empty folders.
So in case the folder contains any files,
the command I show you now
for deleting the folder won't work.
Let's first delete the file though.
For this, I am still in the WEB DEV course folder.
I now type R M for remove, then a space.
And then I refer to the file I want to delete.
So in my case, dummy dot tex.
That's the file inside this folder.
If we run this command, we don't get any confirmation
that the deletion was successful.
But in the GUI again, you see, well, the file is gone.
If I would now create another file
with touch test dot text, maybe.
This would be here again.
And now if you use CD space dot dot to move one level up
in our folder hierarchy.
Then I could also try to delete this folder.
Deleting folders works also with the RM command.
But here we use R M dir for directory.
Now we can enter the name of the directory
that we want to delete.
So in our case, WEB DEV.
With tab we can complete this.
We don't need to slash though.
And now if I run this, you see, this is not working.
This is what I was mentioning a few seconds ago.
For the purpose of this course,
I will only show you this deletion commands
to make sure you can't delete directories
that contain any files or folders.
Therefore right here we should navigate
into the WEB DEV course folder
with CD like this.
Now run RM for remove test dot text and remove the file.
Now again, use CD dot dot to move one level up.
And now we can run RM dir.
So to remove the directory
and remove the WEB DEV course directory.
Slash doesn't play a role here.
If we do this now, you'll see
in the GUI at the bottom that this was deleted.
And this is actually more than you actually need to work
with, get and get up from the terminal.
Therefore we're done with the terminal introduction
on Mac OS systems.
If you also want to find out what the windows command prompt
looks like, feel free to dive in to the next lecture.
Otherwise please skip the following lecture and continue
with the lecture afterwards,
where we will finally dive into (indistinct).