The name "computer science" is an accurate name in the sense that computers are heavily used in this science which is a science insofar as knowledge is being inquired into.
However, "computer science" should not be taken to mean "the study of computers" or even "the science of computers" because the computer, as it exists today, is a product of our creation. The computer is already built and thus there is no need to study it except to improve it.
There are generally 2 things that are being studied in computer science: computation and information. The fruits of this study can be demonstrated and applied by programming a computer, a robot, a car, or anything else that can perform a task based on a specific set of instructions.
One could say that computation and information are also being studied in mathematics and logic; there is also a lot of overlap between the knowledge that lies within these 3 domains. What makes computer science stand apart from mathematics and logic is an emphasis on time and space which constrains what can be computed and represented within a computer.
Computers rely on programs to operate. A program is a set of instructions that a computer can execute. The most important program that all computers have is an operating system. The operating system is a program (or set of programs) that directly controls the computer, this includes control of: the mouse, the keyboard, the monitor, the fan, the networking interface, and the file storage devices. The operating system controls every physical component that makes up the computer.
There are many brands of operating systems today, but the 3 most popular desktop operating systems are: Windows, macOS, and Linux. The 2 most popular mobile operating systems are: Android and iOS.
Operating systems directly control the computer on behalf of other programs known as applications (now today known as "apps"). Users (the ones between the keyboard and chair) use applications to: browse the web, play music, edit documents, collect and edit pictures, and play games among many other things applications can provide.
Most operating systems have built-in interactive functionality for file management and application management that the user can access through buttons, menus, and windows. This type of interaction is possible when the program provides a "Graphical User Interface" (GUI) to the user.
Many graphical operating systems provide a program known as a command shell. The command shell is a program that allows the user to access various operating system services through an interface known as a command-line interface (CLI). A CLI is an interface with a text-only display and a keyboard-only input where the input takes the form of commands entered line-by-line.
The most popular brand of command shell for macOS and Linux is known as bash and it can be accessed through a program called the terminal. The command shell for Windows is known as the command prompt.
The command shell is an important program used by computer scientists and other advanced computer users for detailed and automated control of a computer.
Before using a command shell, it is essential to have knowledge of the computer's file system.
Despite a lack of standardization for file system concepts, there is a common understanding of file systems and the following definitions will apply for this course:
If you've used a computer more than a few times, you should at least have heard of the term "file" and you should have the basic understanding that files store data even when the computer is turned off. You also should understand that there are different types of files, although not in the same way that will be presented here.
By different types of files, you might be thinking of the distinction between sound files, image files, and document files; or you might be thinking of the file extensions: .txt, .mp3, .png.
As far as this is concerned on a broader level in computer science, those are all the same types of files and they are known as regular files. A regular file is the most common type of file, a regular file can store an image, a song, a movie, a book, or any other thing that has significance to the user.
A regular file does not redirect to another file, or to a list of directory entries, or to an entire physical device or network connection.
The 2nd most common type of file is a directory. Directories organize files into a hierarchical fashion. Directories are containers for files and other directories, another term for a directory is a folder.
When you query the contents of a directory, either through a command shell or an application programming interface, you will receive a list of directory entries. Each directory entry refers to a file that is inside of that directory, including that file's attributes.
file attributes may include: the file size, file permissions, and the last modification time.
The term "file name" is often used ambiguously and interchangeably with "file path". To make things more clear in this course, file name refers to the name of a file as it is seen within the context of a single directory. Examples of file names include: "Untitled Document.txt", "index.html", "background.png", "data.csv"
The portion of a file name that begins at the last '.' is known as the file extension. ".txt", ".html", ".png", and ".csv" are all file extensions and they serve to indicate the type of data that a regular file stores. A file extension is completely optional for a file to have, you may sometimes encounter regular files that do not have a file extension and your operating system may ask you to choose a program to open that file with.
A file path, or just path is a sequence of file names and other components that help identify a more precise location of a file within the file system.
If your operating system is Windows, your user name is "Guest", and you created an untitled folder on your desktop, then the path of that folder would most likely be: C:\Users\Guest\Desktop\Untitled Folder. On macOS, the path would be: /Users/Guest/Desktop/Untitled Folder. And on Linux, the path would most likely be: /home/Guest/Desktop/Untitled Folder.
With the exception of Windows, the components of a path are separated with a forward slash and each component names a directory that contains another directory that leads to the relevant file.
More formally a path is composed of the following:
The root name is the name of the device, partition, or server that the file system resides at. A root directory is a directory that exists in the top most region of the directory hierarchy.
A path that starts with a root name or root directory is known as an absolute path and such a path unambiguously refers to the exact location of a file within a file system.
A path that does not start with a root name or root directory is known as a relative path, referring to a file relative to some directory on the file system which may not necessarily be known.
As mentioned earlier, bash is the most popular command shell in use, it is also the default command shell for macOS and many Linux distributions. It is important that you learn the basics of bash because this is the program that you will use to invoke other programs that are essential to this course and in your future endeavors as a computer scientist/engineer.
Although it is essential to know, this course is not primarily concerned with teaching bash, but for this first week we expect you to learn and practice bash because you will be using it for the rest of this course and your future courses here.
When you open the terminal to access bash, you will be presented with a prompt. The prompt can be customized but it usually defaults to an abbreviated path that represents the current working directory followed by a dollar sign.
The current working directory is a path to a directory that is used as the basis for any specified relative path.
Any bash command that processes or manipulates files will use the current working directory as a reference point for any file name or relative path that is supplied to that command.
A command in bash as well as many other command shells, usually takes the form of a sequence of words separated by spaces. The first word specifies the command and the rest of the words specify the arguments to that command.
The easiest command to execute is one that does not require arguments, just the command itself. Try executing the following command:
ls
To execute a command, you must type the command and it's arguments into the command shell and press Enter.
After executing ls, you may get output that looks like this:
Desktop Documents Downloads Music Pictures
This is a directory listing, the ls command by itself lists the files in the current working directory. If you want to get a directory listing for a different directory, you can change the current working directory with the cd command.
Assuming that our current working directory is our home directory, the command:
cd Desktop
will change the current working directory to the Desktop directory and from here, all the file system commands will be relative to that Desktop directory. What gets placed in the Desktop directory corresponds to what appears on your graphical desktop. Try the following command next and you will see a directory or folder appear on your graphical desktop:
mkdir test
mkdir stands for "make directory" it requires 1 arguments, the file name or path of the new directory to be created.
You should research and practice using the following commands to get a grasp on using bash:
Command | Description |
---|---|
cd | Change working directory |
pwd | Print working directory |
cp | Copy a file |
ls | List the files in a directory |
mkdir | Make directory |
mv | Move file |
rm | Remove file |
rmdir | Remove empty directory |
cat | Concatenate and display files |
clear | Clear the terminal display |