Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now I want to just talk a little bit more about what's happening when we launch Terminal. Notice here this first line, Last login. That's telling us the time and date that we last logged into Unix. Every time we open a new window it logs us into Unix again as a new Unix session. We can have several of those open at once. I'll use Command+N to open a new window and now you can see that I have a different Last login time. There is no problem having several of these open once. Each one is a Unix session and each time I'm being logged in as Kevin. I'm being automatically logged in on the Mac.
Other Unix systems don't automatically log you in. You'd put in your username and your password for it to know who you are. But your Mac already knows who you are. Now if you are using your Mac as a single-user environment, that may come as a bit of surprise to you because you may not even think about the fact that you are logged in as you. But if you go to Apple menu and down to System Preferences and into Accounts, you can see that we can manage different user accounts. Now you may only have one or you may have been taking advantage of this feature and you may have family members or co-workers or people like that who have accounts on the machine as well.
But for a lot of people they just use a single-user account and under Login Options you may even have Automatic login set to True. In which case you don't even enter your username and password then. It remembers that it does it for you. So your Mac is completely turned off, you turn it on, and it automatically logs you in with your username and password, and voila, you are logged in as you. It's very much the same user experience that you would've had with OS 9 which was a single-user system. But once we moved OS X with this Unix underneath, Unix is fundamentally a multi-user environment.
Even if you're only using it for just you, it still has all those multi-user features and that's going to have some applications later on that we'll need to talk about. So realize this: that when you first fire up your Mac you are being logged in as a user. Even if you don't explicitly put in your username and password, and therefore when you start your Unix session using the Terminal you're also being logged in as that user. So the next I want is to look at the second line and see what's going on here. What we have to begin with is what we call the command prompt. This is prompting us for some action, and we'll see how to configure this later on.
Right now by default, it's going to be configured to the host name, the directory that we are in and then the user that we're logged in as and then this dollar sign here which is the prompt. Dollar sign space and then my cursor is here waiting for me to type something. It's prompting me to give it some commands. So I am going type a simple command, echo and then a single quote followed by Hello World and another single quote. I'll hit Return. That tells that all right, I'm done typing, take this command and execute it and it does. You'll see the response it gives me back and then I get the command prompt again saying, "Okay, I've done what you asked and now I'm ready for more input." Let me go ahead and just type a few more commands in here just so we have them.
echo 'Hello', echo 'World' and then I want to show you that you can use the up arrows and down arrows to go back to previous commands. So you can access those previous commands using that and that's an indispensable tool. You are going to be using that all the time, up and down. You can even then use the forward and back arrows to go in and edit the line and make changes. So it can save you a lot of typing. You say, oops! You know what? I meant to do that command but I meant to have three exclamation points after it. Well you don't have to do the whole re- typing. You just go back, make the change you want and then hit Return again.
There are some other useful shortcuts for working with command line that I want to just take a look at. But before we do I just want to show you that you can use Exit to exit a session or you can just simply close the window. That does the exact same thing; it exits you out. So if I hit exit, you'll see now it says logout and now it doesn't take any input from me anymore. I can then go up and close the window and whenever I want to log back in, I just open a new window and now it's ready to take my input again. I am logged back in. All right, let's look at some other shortcuts. As I said we've got the up and down arrows to review previous commands. Ctrl+A will move your cursor back to the start of a line.
So if you've got a long line of 50 characters and you want to make a change at the beginning or the change you want is closer to the beginning, Ctrl+A will just shoot your cursor back to the beginning. Ctrl+E will go to the end. So I remember it by thinking A is the beginning of the alphabet, E stands for End and that will shoot me to the end of the line. On the Mac, inside Terminal, you can also Option+Click a point on a line and it will take your cursor to that point. I find that that can be a little buggy sometimes. It doesn't always work exactly like I expect, but it can be a really quick way to get there.
So try that first. Option+Click the spot on the line where you wanted to go to and it should just move your cursor back along. Another very useful tool is Auto Complete. If you're in the middle of typing something and then you hit Tab it'll try to guess what the rest of it is, based on the available commands or the available filenames. So that's really useful if you want to type a whole filename. You don't have to type the whole thing; you can just type enough that it can tell the difference and hit Tab and it will finish it for you. Tab+Tab can be used whenever the Auto Complete doesn't work, because it's not sure what the matches are.
So let's say here's five files that are all very similar. You type the first few letters and it can't tell from that which one you want. Tab+Tab will show you a list of what all of those possible matches are. And then the Command key plus the Tilde key will cycle between Terminal windows if you have several windows open and Command+K as I mentioned before will clear the screen and scroll back.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98482 Viewers
61 Video lessons · 85764 Viewers
71 Video lessons · 69669 Viewers
56 Video lessons · 101993 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.