Viewers: in countries Watching now:
Unix for Mac OS X Users unlocks the powerful capabilities of Unix that underlie Mac OS X, teaching how to use command-line syntax to perform common tasks such as file management, data entry, and text manipulation. The course teaches Unix from the ground up, starting with the basics of the command line and graduating to powerful, advanced tools like grep, sed, and xargs. The course shows how to enter commands in Terminal to create, move, copy, and delete files and folders; change file ownership and permissions; view and stop command and application processes; find and edit data within files; and use command-line shortcuts to speed up workflow. Exercise files accompany the course.
In the last movie we saw how we can use the ps command to be able to view a list of the Unix processes that are running. But the problem with it is that sometimes we don't just want a snapshot in a moment in time. We actually want to be able to watch the processes. We want to be able to monitor them as the CPU and memory usage goes up and down, whereas processes start and stop. So to do that we need something that's a little more interactive that will keep refreshing and showing us the state of things as they change. The tool for doing that is called top. So if you simply type top and hit Return, you will get a list of the top processes.
Now, top processes depends on what order you've sorted it in. By default, it's sorted by the Process ID. So the most recent processes are at the top. You will see above that that we actually have a list of some summary information, the CPU usage, the memory usage, that kind of thing that's going on, and then we get that information for each one of these as well. So we can see how much memory usage it's using up and how much of our RAM it's using up. Now perhaps the most important thing you need to know about top is that you can hit the Q key to get back out of it. So Q will exit out and take you back to your command line. So there are some options that we can pass in when we launch top. We can say top -n to specify the number of processes to show.
By default, it shows however big the window is. But we can say, all right, we only want to see the top 10. We can specify the sort order. There are some special keys that we used to say the sort order and I can show you those in the moment. For now let's just say CPU. We're going to sort it by CPU usage and we can set the refresh rate. We will use the -s for seconds. By default, it's set to 1 second refresh. Let's set it to 3. So every 3 seconds it will refresh and then we can also pass in a capital U for user showing filter by user. So we are going to see only the user that we specify, Kevin in this case.
So we will see the top 10 processes of Kevins, sorted by CPU, refreshing every 3 seconds. So there you go! Now, every 3 seconds it will re-update, but you can see the thing that's using the most CPU is Snapz Pro, which is the program I'm using to record this video. We have some interactive commands that we can issue as well, the most important of which is the question mark. That's the same thing as sort of help. It displays this Help screen. Notice here that it gives you sort orders. Right now, I have it sorted by CPU. That's what it's telling you here. The current state. We can pick a different thing, we can sort by time, we can sort by size.
That's the resident memory size, which refers to the RAM that it's using up, and we can sort by user and so on. The man pages will detail what each of these actually does for you. We can also change the delay just by using s followed by the delay. So let's try that. Hit any key to continue. Now, we are back here again. Let's change our delay back to 1. I will hit s and 1, hit Return, and now it updates every 1 second. If we want to see all the users, we type a capital U and then I can just hit Return and that will show me all users now, not just Kevin. But one thing that we can't do from here is change the In value, the number of processes that it's showing.
That's not available. But the o, s, and capital U options are all still available from here. Now, there are some differences between top and different Unix versions. This is the way it works on the Mac. The Mac is a little bit limited in the interactive options that you can type. Something like Linux the version of top actually has a lot more options and shortcuts that you can use from that interactive page. So check the man pages, check that help page, and it will help you out with all the different commands that you can use. Let's launch it one last time and I just want to show you if I go ahead and I launch Firefox, and we can see it pop up and we can see the memory that it takes up and so on, all right? You can see it up here and then we come back to Firefox and we quit out of it again.
You can see that it goes away. So this is a nice little tool. You can just leave it open and watch the processes come and go. In the next movie we will actually take a look at how we can stop these processes from running.
Find answers to the most frequently asked questions about Unix for Mac OS X Users .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
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.