In this lesson, we're going to learn about the terminal in the most basic navigation commands used
in it, if you have terminal experience.
Feel free to skip this section to be an effective Macintosh Systems administrator in the enterprise.
You really need to utilize the terminal in the terminal.
You can typing commands that perform actions on your Mac.
Now, entering a single command isn't necessarily faster than using a gooey, but you can string as
many commands together as you want what's called a script to perform complex functions much faster than
you can perform manually.
A single script can be sent to dozens, hundreds or thousands of Macs simultaneously to completely automate
Mac management.
Now, in this course, I'm going to show you lots of commands and scripts.
You'll see, however, that I use a lot of the same commands over and over again.
So if you're a beginner, you should be able to start automating your environment fairly quickly.
Now, it's never a good idea to copy and paste commands and scripts into your production environment
unless you know exactly what they're going to do or contest machines and look up commands you're not
familiar with.
All right.
So when you open a terminal, you are going to be in the home folder of the user in which you're logged
in.
And how you can verify that is with the WD command.
So I'll type W.D. and you can see I'm in forward slash user's forward slash administrator, which is
the administrators home folder.
If I'm in the home folder, then inside the home folder of every user's eight documents folder and a
desktop user.
So let me go ahead and go into my desktop.
Now, what I'm going to do is I'm going to use the tilde key, which represents home, and then I can
go to desktop.
Now I'm going to type disk and then hit the tab and that does an auto completion.
And then I'm going to hit enter and now I'm in my desktop folder and you can see over here, it shows
the folder that I'm in.
Now, if I type WD, you can see that I'm in user's administrator's desktop.
All right, so another basic command is creating a directory, so let's create a directory called Folder
one.
Now you can see I'm putting a backslash and a space.
And when that and when I hit enter, I'm going to get folder space one.
Now, I could also do with quotes folder space two and get a similar effect.
So it's up to you on how you would want to handle that.
Now I can create multiple directories at the same time.
I could do folder three and folder.
And folder for and create multiple folders at the same time.
Now, if I want to delete a folder, I have to hit R.M. for remove and then I can hit F four folder
and I can hit tab.
And you can see that when I hit tab it types and folder and then backslash and then a space.
Because everything in this directory is named folder backslash space and then there's a number.
Now of course it doesn't know which folder I want to delete.
Now if I hit the tab key twice, it gives a listing of all the choices that are out there.
So I'm going to go ahead and I'm going to get rid of three and I'm going to get rid of four as well.
Now you see that it says folder is a directory, so that's sort of an error.
All right.
Well, you've got to think there's got to be a way that you can delete folders with or remove command.
Well, if you ever are unsure or forget about certain syntax and syntax is basically options that you
can apply to a command.
Every command has a manual so you can type man for manual and then the command you want to get help
with and then hit enter.
And then basically it brings up a manual for the command.
Now, if I scroll down with my arrow keys, I can see that I'm passing a command that's hyphen R and
it says attempt to remove the file hierarchy rooted in each file.
So that's basically will get let me get rid of directories and subdirectories.
So I'm going to hit the Q key to get out.
And so what I'm going to do is I'm going to do an R.M. Dash R and then I will do folder three folder
for and then that gets rid of both of those folders.
All right, now I'm going to go ahead and open these folders.
Just so we can see things visually at the same time, but there's a command called touch and what touch
does is it creates files if they don't exist and it will change the modified date on a file if it does
exist.
So what we're going to do is we're going to use it so we can create a file.
All right, so if I do touch and then I say file that text, then it would go on to the desktop because
that's the folder I'm in.
Now, if I hit remove file, it will go away.
And I don't get an error because it's not a directory.
If I wanted this file to go into the folder one folder, then I could say touch folder one and then
file dot and then oh OK.
I see what I did.
So what that did is it basically touched folder one and then it touched file dot text separately because
I have a space there.
So let's see the difference when I do what I actually intended on doing.
So folder one.
But now I need a forward slash because it's part of a path and now so that's a complete file name with
path included.
And this will appear in folder one.
All right.
So let me go ahead and delete file, text dot file that text from the desktop.
Now, if we want to put text in the file, then we could say echo and then quotes say test and then
I'll say I'll type in the full path desktop folder one.
File, dot text.
And then.
You need to echo that test.
All right, so it's echo test, so it's going to print text, too.
And then the path of where I want it to go to.
Now, there's also a command called CAT and that will print the output of a file so I can do the same
thing.
And you can see that it says tests and that would be the same thing as opening up the file.
All right, so what if I want to copy that file, so right now I've been doing everything from the desktop
folder, but I could change my directory to folder one.
And then if I do in else, which is a listing's, it's similar to directory or dear windows.
You can see that I have filed that text.
Now what I can do is I can type c.p file dot text, but I'm in a folder one.
So if I want to copy to folder too, there will be a couple of ways I could do this so I could say I
want to go up one level and then go to folder two and then that would copy it.
And then the other way, I could have done it.
Well, let's go ahead and get rid of it.
So we'll go up a folder to and then file tax.
We'll get rid of it.
And then the other way I could have done it is copy file text.
And then I could have said desktop folder to.
And it would have copied it that way as well.
So that's basically the difference between your relative path and what's known as an absolute path.
So if I type till the desktop folder, too, that's an absolute path.
That is a path from the route of the file system.
I mean, likewise, I could have said, let's go ahead, I'm going to hit the up key up shows me all
the commands I've typed up and down so I could go ahead and delete that file again.
And to illustrate my point even further, I'm going to copy file text, but I'm going to say users,
administrator, desktop and then folder too.
And that will copy it as well.
Now, that's a real, absolute path.
So remember, the tilde basically is a substitute for your home folder.
So users administrator desktop folder too.
It's basically the same thing.
It's just a shortcut, but it is an absolute path.
All right.
So another thing that we could do is we could move a file.
So let me go ahead and let's remove from folder one file dot text.
And then what I want to do is I want to move.
From folder to.
File dot, text to folder one, now I'm in folder one, we can see that here.
And so if I want to move the file dot text from folder to to folder one and I'm in folder one, I don't
have to type of path.
I can just type at DOT and then basically you can see it moved it from folder to to folder one.
So moved folder to file that text to folder one that I just use the dot because that's the directory
and now it was in folder dot one.
OK, so let's go ahead and close all this and so that.
Like I said, those are really the most basic of commands and I'm going to use these commands throughout
the whole thing.
So what happens?
I said that by typing in a bunch of commands together equates to a script.
So if I do, I just created a simple script to illustrate my point.
And so if I do an essay test, I'd say it created all the folders on my desktop and then I have it putting
those two folders into a single folder.
And then basically it created a backup folder.
And then it copied everything from folder one to my backup folder, and then it's going to delete everything.
So now everything's gone.
So that's an example of how you can string a bunch of commands together in a script to perform complex
functions.
And these scripts can be sent out to, like I said, dozens, hundreds or thousands of computers, all
at the same time in one building or multiple buildings.
And that's what makes it possible to automate your entire enterprise.