Join Kevin Skoglund for an in-depth discussion in this video What is Unix?, part of Unix for Mac OS X Users.
To start things off let's begin by getting an understanding of what Unix is and how Unix got to the point where it is today. Unix is an operating system. It was created during 1969 to 1971 by AT&T employees working at Bell Labs. A lot of these Bell Labs employees have been involved in designing a mainframe operating system called MULTICS, which was short for Multiplexed Information and Computing Service. Back then, mainframes were expensive so users were granted time-sharing slots to do their work and to use the power for the mainframe, often by logging in from a remote terminal that had far less computing power.
MULTICS was designed to manage that remote login time-sharing process. But MULTICS became such a huge and complex project that Bell Labs decided to pull out of it. The Bell Labs employees who'd worked on MULTICS still like the project's goals and so, almost as a side project they worked on building a smaller and simpler version of it. Originally, their version only supported a single user, so that as a play on the name they called it UNICS, Uniplexed Information and Computing Service instead of Multiplexed. Very quickly though it became able to support multiple users and so they renamed it Unix with an X, which doesn't actually stand for anything anymore. It's just Unix.
Now at this point Unix is just another mainframe operating system being used internally by Bell Labs. But two important events give Unix a big boost in popularity. First, in 1972 Unix was rewritten in the C programming language. Up until that point, operating systems were typically written in Assembly language. Assembly was a very low-level programming language that required the code to be written for specific computer hardware. It's very fast, but it's not portable. If you wanted to port an OS to a new computer type, then you have to rewrite major portions of your code to do it.
The C programming language was a programming language originally designed for the Unix operating system to write programs for the Unix operating system. It's a low-level programming language but not as low-level as Assembly, and so C makes writing programs easier than Assembly and also makes them hardware-independent. So the important development here is that not only do they write programs in C, but they took the additional step and said, "Hey, what if we rewrote the entire operating system in C, so that then Unix becomes portable too? We don't have to rewrite the operating system whenever we want to take it to a new type of hardware." The next important event is the spread of Unix outside AT&T. Because of a court order in an antitrust case AT&T had been forbidden from entering the computer software business.
So therefore they could not sell the Unix operating system. They can only give it away. So that's exactly what they did. If you wrote to them and asked them for a copy of Unix, they would give you a free license and send you all the source code for it. That made it very attractive to government agencies, universities, and corporations who had these mainframe computers because now they could get a free license and all the source code to be able to run on their mainframes. Perhaps the most important of those three is actually universities. Because if you think back, in 1975 this is a point when computer programming is really beginning to take off and there are a lot of people at universities who are learning about computers for the first time, getting access to mainframe computers for the first time, and what are they using? They are using Unix.
So Unix becomes the first thing that these programmers learn. So they go on to find all these software companies throughout the 80s and 90s and the thing that they first started working with was Unix. So the first time release in 1975 is often referred to as System Five and that's kind of the first public version of Unix. But over time more branches and improvements are released and that keeps going even today. The most famous of these is probably the Berkeley Software Distribution, also just called BSD for short. That came out in 1977 and then there've been other ones that are either open source, closed source, or mixed source.
Linux is open source. Closed source versions, each major software company seems to have their own. Sun Oracle has Solaris, IBM has AIX, and Hewlett-Packard has HP UX. And of course the mixed source version, mixture of open source software and closed source software, is Apple's Mac OS X. So it's gotten to the point now with all these branches and improvements that no one is really using Unix, the pure System Five Unix that originally came out. So Unix now really means a Unix-like system. There are all these different versions, they all have their quirks and peculiarities, they are a little bit different, but they all work according to the same principles and are very, very similar.
So if you hear Unix now, it really can mean all of these things. In fact mobile devices now are Unix too. iPhone, the iPad and Android are all based on Unix. They are Unix like systems. Now of course the version that we're most interested in is going to be Mac OS X Unix. Mac OS X is based on BSD Unix, the Berkeley Software Distribution. But in addition to that there is code that was developed at NeXT. NeXT is a software company that Steve Jobs founded after leaving Apple and they created code that they called NeXTSTEP, which went on top of BSD Unix. When Apple bought NeXT they got all of that code and took it and added more improvements to it and called the combination of those three Darwin.
So if you hear anyone refer to Darwin, that's what it is. It's BSD Unix plus NeXTSTEP's code plus Apple's continued improvements to it that make up Darwin, which is the Unix that sits underneath Mac OS X. Mac OS X includes a lot more than that. It's the Finder and all these other things as well. But Unix is under the hood. The Finder and system preferences interact with Unix. Now we can interact with Unix directly by using the Terminal application and we'll start doing that in the next movie. The command line is going to allow us to type the commands that we want Unix to do, instead of using the graphical user interface that you're familiar with, with your typical Mac operating system. So why do this? Why use Unix directly when you have this graphical user interface? Well there is a lot more power in the command line.
Imagine this scenario and think about how you would do it in the Finder. Search your hard drive for every file whose name contains invoice and which was created after a certain date. Then remove the file extension from each filename and save that list to a text file. Now with Unix that type of data intensive task is very easy to do. It's not the answer to everything. You could never do in Unix what you do in Photoshop for example and it's nice to be able to just drag and drop files into folders with the mouse instead of having to type the command into the keyboard. But as a general rule when working with data, non-data elements can get in your way.
I think of it as being very similar to the difference between car transmissions. If you have an automatic transmission you give up control for having the convenience. You don't have to worry about shifting gears. It just does it for you. But you're not necessarily getting the best shifting possible or exactly what you want. With a manual transmission you give up the convenience but instead you get control. So essentially what we are going to be doing in this training title is learning to drive stick. Now one final note before we do that. Most of all we cover in this course is going to apply to any flavor of Unix.
All Linux distributions, Red Hat, Ubuntu, DBM, Solaris, AIX, each flavor of Unix may require a few modifications. Maybe the options to a command won't be exactly the same or maybe there are some new commands that exist on one of those distributions but not on another one. But you'll have enough knowledge that you should be able to quickly adapt to those systems and that makes this course useful not just for Mac OS X users, but also for web developers who plan to deploy their website to a remote LINUX server.
- Moving around the file system
- Creating and reading files
- Copying, moving, renaming, and deleting files and directories
- Creating hard links and symbolic links
- Understanding user identity, file ownership, and sudo
- Setting file permissions with alpha and octal notation
- Changing the PATH variable
- Using the command history
- Directing input and output
- Configuring the Unix working environment
- Searching and replacing using grep and regular expressions
- Manipulating text with tr, sed, and cut
- Integrating with the Finder, Spotlight, and AppleScript
Skill Level Beginner
Q: The exercise files for the following movies appear to be broken:
Is there something wrong with them?
These exercises include one or more "dot files", whose file names start with a period. These files are normally hidden from view by the Finder. So that they would show up in the Finder, the period has been removed from the file names. Additionally, "_example" has been added at the end of the file name to make it clear that the file will not work as-is.
To make the dot files usable, either:
1) Open the file in a text editor to view its contents. Note that it may not be possible to double-click the file to open it because there is no file extension (such as .txt).
2) Resave the file under a new name (usually by choosing File > Save As), adding a "." to the beginning of the file name and removing "_example" from the end.
1) Copy and rename the file from the Unix command line using the techniques discussed in this course. Rename the file by adding a "." to the start and removing "_example" from the end. Include the "-i" option to prevent overwriting an existing file unexpectedly.
Example: cp -i ~/Desktop/Exercise\ Files/Chapter_07/07_02_files/bashrc_example ~/.bashrc
The instructor uses the UNIX program 'units' to convert 72° Fahrenheit to degrees Celsius. The returned value of 40 is incorrect. The correct result should be 22°C. What's the reason for this discrepancy?
The problem is that units does the 5/9 calculation but does not have the ability to subtract 32. So you'll need to subtract (or add) the 32 degrees yourself.