Getting to know UNIX

Table of Contents

Interface overview

Typically, there are two major ways of interacting with a computer. One can do so via a graphical user interface (GUI). This typically means refers to using some kind of pointing device (mouse, trackpad, touchscreen, etc), and interacting with the computer by pointing at things and activating them (clicking, tapping, etc.) The other approach is to use a command line. A command line means that you use the keyboard to type commands into the computer to tell it what to do.

A major advantage of using a GUI is that it is easier for beginners to use, because you can kind of figure it out by playing with it. A major disadvantage is that it is slow to use, especially if you have to issue a complex operations repeatedly.

A command line approach, on the other hand, requires more initial knowledge to use than a GUI, because you have to learn what commands are available to typing in. On the flip side, once you have had some practice and are good at using a command line, you can use your computer much more effectively than using a GUI. Another major advantage of using a command line is that it gives you a way to issue commands to remote computers. I regularly connect to web servers that I configure in different parts of the world, and can quickly use a command line to change things as I need to.

In this course, we'll be using a command line for running our Python programs. So, in this lab, you will learn how to use a command line.

UNIX overview

UNIX is a family of computer operating systems that was created way back in the 1970s. MacOS is a UNIX operating system. Linux is as well. (Ok, technically there's a trademark issue going on, so people say Linux is a "UNIX-like" operating system. Whatever) Microsoft Windows is not a UNIX or UNIX-like operating system (though there are ways of retrofitting UNIX onto it.)

UNIX operating systems typically provide a command-line environment called a "shell." (More precisely, they a choice of shells. We're going to use the shell known as Bash.) You can think of the shell as the language that you're using to interact with the operating system. In this lab, we're going to learn how to use the (Bash) shell. Bash is the typical default shell that you use for interacting with nearly UNIX or UNIX-like operating system, including MacOS, Linux, and a number of other lesser known ones.

Sadly, Microsoft Windows is not a UNIX operating system, and its default shell is not Bash. Even if you own a Windows computer yourself, you should learn how to use Bash because you'll undoubtedly need to sometimes use our lab machines. Moreover, if you end up with a job in computing, it is very likely you'll need to communicate with UNIX computers, and a working knowledge of Bash can be very helpful.

UNIX lab

Go to one of the CS labs (CMC 102/304/306) and choose a computer. All of the CS computers are set up to allow you to boot into either Windows or MacOS. For this class, you will be using MacOS. If the computer you choose is showing a Mac login screen, go ahead and log in using your usual Carleton user name and password. Otherwise, restart the computer and choose Mac when you're given a choice.

Once you have logged in to your Mac account, open up a Terminal window. To do so, look in your dock: there is hopefully an icon there that says Terminal. If it's not there, you can find it by clicking the Applications folder in the dock, selecting Utilities, and then Terminal. If you still can't find Terminal, ask for help. Once you've gotten your terminal open, work through Typographical Conventions, Introduction to the UNIX Operating System, and Tutorials 1-4 of this Unix tutorial. This tutorial was originally written at the University of Surrey (note the British spellings of "behaviour" and "customise," for example), and has been lightly edited to match what we do at Carleton.

Here's one minor difference between our Macs and the UNIX tutorial, that you should keep in mind. On our Macs, right before you start typing, you'll see a $ as a prompt. For example, working in my home folder, here's what I see:

cmc304-08:~ dmusicant$

In the tutorial, they show a % as a prompt, not a $. Different variations of UNIX use different prompts. At any rate, the key point is that in the tutorial, when you see a % at the beginning of a line, don't actually type it in yourself. Just type the text that comes after it.

Bring questions to class.

WHAT YOU NEED TO SUBMIT

Once you have completed the lab, submit via Moodle the file list1 that you created in Tutorial #3.

(Completely optional epilogue for Windows users)

If you own a Microsoft computer and enjoyed the above lab, or if you intend to use your computer for assignments, I'd recommend also learning how to use Windows via a command line. You've got multiple approaches. I'll list the ones I'm familiar with below, which some links on learning more about them.

  • The classic command-line approach for Windows is often referred to as "the DOS prompt," and has been around since the 1980s. Here is a tutorial on using the DOS prompt. This is perhaps the most popular approach for interacting with Windows via a command line, though much of that is due to history and familiarity for some folks. It is automatically included as part of Windows.
  • Windows PowerShell was released in 2006 as an upgrade to the DOS prompt to provide more capabilities. I assume that it is still less commonly used than the DOS prompt, but can do more and is preferred by some. Here is a tutorial on using PowerShell. It is automatically included as part of Windows.
  • Cygwin was released in the mid 90s as a way to be able run bash and other UNIX-like programs on Windows. Here are instructions for installing Cygwin. Once you've installed it, you should be able to start up a bash prompt, which you can use for interacting with your system.
  • The Windows Subsystem for Linux (WSL) was released for Windows 10 in 2016. It allows you to install an Ubuntu Linux system directly hooked into your Windows install, and so you can then open up a Linux Bash prompt from within Windows. If you want to use it, you need to install it separately. Here are instructions for installing WSL and starting Bash. Once you've done this, you've got Bash, which means you can use the same approach for interacting with your computer as you can for UNIX systems (mostly).

The simplest easiest approach to get started with, by far, is just to use the DOS prompt, so you might want to start there. If you really want to run bash on Windows, Cygwin has been around for a long time and is pretty stable, so you might want to try that (though WSL looks pretty cool too).

Author: Dave Musicant

Emacs 24.5.1 (Org mode 8.2.10)

Validate