11. Appendix 2: Unix¶
11.1. Unix: A Brief History¶
The Unix operating system was one of the most influential software systems ever created. It was developed in the 1970s by Ken Thompson, Dennis Ritchie, and others. Versions were then implemented by academics. Berkeley’s BSD Unix was a popular version in Universities. Starting in 1985, the Mach Kernel was developed at CMU as a replacement for BSD Unix. It is the foundation on which the Mac’s OSX operating systems was built. So you can really think of OSX as Unix on steroids. In 1991, Linus Torvalds released the first version of Linux, an open source version of Unix. Linux has become the most popular operating system for software development and running web and related servers around the world.
Microsoft windows has a different lineage that the Mac. When Bill Gates, an early computer whiz, learned that IBM needed an operating system for its new “PC”, and that the developer of the then-popular CP/M OS wouldn’t license the software to IBM, Gates an operating system called QDOS from a company called Seattle Computer Products. He renamed it MS-DOS 1.00 and licensed it to IBM. Thus sprang up what eventually grew into the Microsoft emprire.
The bottom line for our purposes is that OSX is, for all intents and purposes, a version of Unix, but Windows is not. If you’re developing software on Windows, you will therefore probably want to download and use a Unix “emulator”, by which we mean a piece of software that makes your Windows machine behave like a Unix machine. Git Bash provides the necessary capability: a Unix-based terminal window. There are alternatives. One is that Windows 10 now allows you to install a full Linux subsystem. “Google” it if you’re interested. MSYS2 is another popular Unix emulator for Windows. The simplest solution for us is Git Bash.
11.2. Command-Line Commands¶
Unix was developed in the days before graphical displays were popular. Consequently, it provides rich capabilities for working in a “terminal” window. Mac and Windows graphical user interfaces are really just intermediaries between you and the underlying operating system. That is, the GUI on your machine interacts with you and then just dispatches command-line commands to the underlying operating system. GUIs are good for non-technical users, but programmers often need to issue command line commands directly to the operating system.
A terminal window running a “shell” program, usually bash, is the mechanism for doing this. To be an effective software developer, you really must know basic Unix command-line commands. The rest of this appendix lists some of the most important commands that you need to know. Each command has many options. To learn about a command, such as ls (for listing the contents of directories), use the man command. The command, man ls, for example, will give you the “man page” for the ls command.
- pwd: print the current directory
- cd: change to a different directory
- ls: list directory contents
- rm: remove (delete) a file
- mv: rename a file or move it to a different directory (or both at the same time)
There are many Unix command-line command tutorials online. We suggest that you go off on your own and learn how to use your Unix (or OSX or Git Bash or MSYS2) shell and the command-line commands supported by essentially all Unix-based and Unix-like systems. Here’s one tutorial that looks pretty good. We have not studied it carefully. Check it out and let us know what you think. https://www.learnenough.com/command-line-tutorial/basics