Hi, this is Gary with MacMost.com. Let's take a basic look at the Mac Terminal.
MacMost is brought to you thanks to a great group of more than 1000 supporters.
Go to MacMost.com/patreon. There you can read more about the Patreon Campaign.
Join us and get exclusive content and course discounts.
So the Terminal is an app that you can find on your Mac. It's part of the system. If you
want to see where it's located just create a new Finder window and go to the Applications folder.
Then go all the way down to the Utilities folder and it's in there. You can just run
it by double clicking on that or you can use any of the normal ways to launch it. Like Spotlight
or Launchpad. When you launch it you get a window that looks like this. You basically type into it
and press Return to execute commands. What you actually have here is called a shell.
It's a Unix-like command line interface that allows you to interact with your Mac just by
typing and reading text. There are no windows. There's nothing to click and drag. You don't
even have to use your Mouse or Trackpad at all. While you may be tempted to think that this is
what's happening under the hood of your Mac that's not exactly true. This is just
another way, besides the graphical user interface, to control your Mac.
So when you're working in Terminal you are always at a certain location. A Folder on your hard
drive. You can find out where by using the command pwd. You see I'll just type that, press return,
and it will show me I'm in my User's Folder in my Home folder which is called MacMost. You can list
the files that are there with the ls command. It will show me everything that's there.
Now let's compare that to the Finder. In the Finder if I go to my Home folder
and then I look at what's there you can see these folders that are there.
That's the same thing that is listed here. I could list this another way by doing ls and then
dash l. The dash and then a letter or word is a modifier by the command. The command here is ls
and dash l is the modifier. Now it's going to list things like this. Putting each thing, in this case
folders, on a separate line with information about each one. So you can see how it is basically the
same as in here. If I want to navigate around I could use CD for change directory. So cd and
if I want to go down I just type the name of the folder. Let me go down into the documents
folder and now when I do ls -l I see the list of everything that's in there. I can
see now the graphical interface actually has the document and Desktop folders in iCloud.
So I don't see them listed here. But if I go to my Documents folder
I can see exactly the same things here. Even the 1 that is actually a file and not a folder.
Now in addition to actually looking around at things you can actually do things like
Launch Applications. So, for instance, to launch an application I would type
Open and then I would do dash a and then type the name of the app. So if I wanted to do TextEdit I
can just type TextEdit and it would launch the app here ready for me to open a file.
So the applications, they are still graphical applications with windows and all of that.
But launching them is something I could do here in Terminal. Now if I wanted to
open a file I could use Open instead of -a for application I'll just use the name of the file.
So in this case test.rtf. You could see it opens it up and does it in its default app.
I could have specified the app name by doing open -a and then the name of the app like that.
Then the file and it would do the same thing in this case. But I'm being very specific
about which app I want to use in case there were several apps that could open that type of file.
What happens if there's a space in the name. Spaces are very important in Terminal because
they are divisions between commands and other parts of what you're trying to do. So if I were
to do something like cd and then App Dev you could see it can't figure out what I'm trying to do
because it thinks app is the thing I'm trying to go into not App Dev. So to include spaces in
names you could do one of two things. One is you can use a backslash before every space. Backslash
space is a substitute for an actual real binding space between the words. The other thing you could
do is you could put quotes around things. So I could do it like this and go into that folder.
Now let's look at what's in here. You could see there's a bunch of different images in here.
Let's say I wanted to open one of those images to take a look at it in the default app which would
be Preview. I don't have to type the entire name. I can actually use the Tab keys as shortcut. So I
could do Open and then start typing the name so I'll do Col and then I'll use the Tab key and
notice how it completes the entire thing. Since I started with Col there is nothing else there that
I could have meant besides the Colorado Lake.jpg file. So now I could hit return and it will open
it up in Preview. If there was some ambiguity to it, like I do Open Co and I do Tab it would
just stay there. But underneath it would show me the problem. That there were two files that this
could mean. So I could put one more letter and try Tab again and then it would open that file.
Now if it seems like it's going to be a lot of trouble to type out every command,
well there are a lot of ways that it is made easier for you. One thing you could do
is use the up arrow to go through a history of your command. So if I use up arrow right now
you could see the last command I issued. Another up arrow goes before that and another
before that. Very often you're using the same commands over and over again. Like you might be
doing something like ls -l and then going into a subdirectory, another subdirectory,
moving somewhere else and then want to do the same ls -l again. Instead of typing it
you can use up arrow a few times until you find that command and then use it again.
Also if this window ever gets a little crowded you can always use Command K to clear it out.
A lot of times you hear about something useful you can do on your Mac involving a Terminal
command and it always starts with the word defaults. What that means is you are going to
use the Terminal to actually change a preference either for the system or for an application.
Defaults command is just a way to get into the Preferences file to either look at the settings or
make a change. You could do the same thing using normal files in the Finder but these files are
usually hidden, sometimes deep in Library files or Application files, and are hard to deal with.
Doing it in the Terminal is often the easiest way. An example would be doing this. So what
this does is it is going to write to the preferences for com.apple.finder, in other
words Finder Preferences, and set something called AppleShowAllFiles -bool value TRUE. When I issue
this nothing happens right away. If I restart the Finder, which could be done with another
Terminal command called killall Finder, which will basically stop the process and something like the
Finder is automatically going to restart when it is stopped. So I do that. Now the Finder restarts.
Now if I bring up a Finder window like this one and I look at say the top level
you can see lots of hidden files because I said Show All Files, so hidden files will be shown.
I can use up arrow to go back two commands and change True to False and now use up arrow again
to use this command again and now when we restart the Finder and you could see all the hidden files
are now hidden. So there's just one example of how you may use Terminal to change a setting.
It doesn't have a little control, a checkbox, a pop-up menu, or anything like that in System
Preferences. The setting exists just there is no built-in way to access it outside of Terminal.
Another thing you do in Terminal is run apps that are only command line apps. They only work here
inside Terminal. They don't have a graphical user interface for you to access elsewhere. An example,
and a really cool one, is called Top. When you do that it's just going to show you this
list that updates the top processes running on your Mac. Now unless you're a developer or a
systems engineer you're probably not going to be able to use this for much but it's kind of neat
to look at and see everything that changes. It's something you could bring up if the boss is coming
and you want to look busy. When you're running an app like this there are various different ways the
app has for quitting it. In this case the top app could be quit by just pressing the Q key.
Another example would be to use the app bc which is a Calculator app. So now notice that
the prompt here is different. Instead of having this here at the beginning, my user account name
and computer name, it's actually just a plain prompt. It can actually do math here. But it is
a more advanced calculator so you can do things like this and you could do things like this.
Like most things you could just do a quick internet search to find the gnu bc app and
get complete documentation for all it can do. To Quit we will execute the command and the app.
Quit. Now we're back to the regular prompt.
You can edit text files with commands like vi to go into the VI Editor or Nano
to use the Nano editor. Lots of good ways to deal with text files. There are a ton of 3rd
party apps that you can install from outside the App Store that add more apps to Terminal.
So Terminal actually has an extensive set of preferences. There's a lot you can do in here.
You can see under General here you could use the Default Shell. Because there are different
types of shells. They are kind of like different languages. The Default in Catalina on is something
called Z shell and it is abbreviated zsh. Before Catalina the default was something called Bash.
There are actually other ones that you could use if you're familiar with using shells.
There are profiles for all the colors and the look of the Terminal window. You could do things with
window groups. You could do things with encodings. Its a pretty comprehensive Terminal app.
But it's not the only one you could use on your Mac. In fact The App Store has a bunch of third
party Terminal apps with special features that you can use. So if you going to be using Terminal
you don't necessarily have to settle for this Terminal. You can go and do a third party app
as well. So now that you know what Terminal is, the question is what do you need it for.
The answer is that for 95% of Mac users they never need to use Terminal. It just isn't something that
a typical user needs to use. But there are some users, many developers for instance,
that do need to use different apps that only run in Terminal. So they need to be very familiar with
it. In between that there are people that don't necessarily need to use Terminal but like to
use it. If you like to just type on the keyboard but want to navigate around in the file system,
moving and copying, and renaming files. Finding things and organizing things.
You could do all of that in Terminal if you know the right commands and you practice at it.
There are a lot of users that prefer that and some users, like myself, that prefer kind of a hybrid.
Sometimes going to the Terminal for some things or when they are in a certain mood.
Another times using the Finder and the graphical user interface of your Mac to do other things.
So that's an introductory look at the Terminal. Hope you found this useful. Thanks for watching.