Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this chapter, we are going to be looking at useful commands that we can use in Unix, and I want to start us off by looking at useful system information commands. The first one we'll look at it is probably the simplest, which is just simply date and that tells you the current date. That's a nice handy thing. If you want to know what the current date is, you just type date and it tells you. Keep in mind that this value is the date that the computer has been set to, which is not necessarily correct. Hopefully, we did set our Mac up to have the correct date, but it's essentially the same date that you would see up here on your Mac if you had a clock display. You would set this value via the system preferences and the date and time settings.
So that's what it's telling you. This is the date the system thinks it is. We also have uptime. That's going to report to us the time that it's been turned on. You can see that I've been up for three hours. So for three hours I've had Unix up and running. That's the time since I booted my computer. It tells you also the time here. Don't need to worry about the load averages here. That's letting you know just sort of how well the system is performing. You won't need to worry about that. Notice that it says 2 users. You may be thinking, well, wait a minute! 2 users? Why are there two users? Well, we can actually use a couple of other commands.
Let's use users and that shows you just one user. So wait a minute, so that doesn't seem to match. Or who. who shows us a list of all users and what they're doing and it doesn't de-dupe it. users de-duped the 2. There is actually two Kevins logged in. One of them is the Terminal program that I am using now when I open up a new bash shell. But keep in mind that I also have the Finder running here, which is also interfacing with Unix. So it has to be logged in as Kevin as well. So those are the two users, the one that's sort of outside here in the Finder and the one that's inside this window.
I am going to actually open up a new Terminal window and then from here you will see now we have a second one. We can type who. You can see now we have three. There is ttys000, which is this other one over here and the other one has been called ttys001. So that's how it keeps them straight. So who shows you each of these occurrences every time that I log in, whereas if you just type users, it just shows you the one user, Kevin. It doesn't care the fact that there are several of them. So those are useful commands. uptime, users, and who. We also have uname, which returns the operating system name.
Now, you may be like "Wait a minute! Darwin? I thought I was using Mac OS X." Remember when we talked about back, when we said what is Unix? Darwin is the name that Apple gives to their version of Unix with all the extra code that they've added in on top of it. All the proprietary stuff as well as the open-source stuff altogether is called Darwin. So that is the version of Unix that we are running. OS X is running on top of that. We are talking about the Unix name. That's the u in front of it. uname is Darwin. We also can pass in some options here. uname, dash, and the options are mnrsv and p and that will return all sorts of information to us, not just the operating system but you can see it tells me 10.6 is what I am running.
It gives me real specific information about the release that I'm running. It tells me my processor, the hardware that I'm running on, and actually a shortcut for all of those. For everything except the P is the A option. That does mnrs and v altogether. P is the processor, and that's the second. You can see that those are actually the same, the last two entries there but that will do the same thing for you. You can check the man pages to see what all those are but that just gives you a little more information about the system that it's running on. We also can use hostname and domainname. Those are more useful when you're in a networked environment.
The hostname would be the host that we are on and domainname for me is not set to anything but on a web server or some kind of a shared Unix work server, those might return something more useful to you. So together those commands make up some tools that we have to find out some basic system information.
Get unlimited access to all courses for just $25/month.Become a member
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.