Introduction-To-Unix-And-Linux-Introduction-To-Unix-Operating-Systems
Introduction-To-Unix-And-Linux-Introduction-To-Unix-Operating-Systems
Objectives
Learners will be able to…
1. Identify what tasks/functions an operating system does.
1. Describe the history of Unix systems
1. Use the appropriate commands on the terminal to change directories, list
the contents of a directory, and list the contents of a file.
What is an Operating System?
The operating system (OS) is the software that sits between the computer
hardware and the applications running on a computer.
You should see Welcome to Unix print out below the command you
typed.
You can try printing out other phrases by replacing the text in the
double quotes like so: echo "Are you ready?".
Operating systems allow users to multi-task - for example, you can watch a
video and receive texts at the same time - by carefully managing a wide
range of system resources.
What does an operating system do?
Manage memory allocation for running applications
Process scheduling; managing CPU (central processing unit) allocation
for running processes
Manage data storage
File management
Manage Input/Output (I/O), specifically process input from devices such
as keyboards and touchpads, send output to a display
Manage peripherals such as printers and scanners
Unix is a multi-user operating system. Under Unix, each user can access
and share system resources such as memory. In contrast, other operating
systems, like Windows, start a new session with distinct resources for each
user.
The UNIX operating system
The first implementation of UNIX was developed at Bell Labs, a division of
AT&T, in 1969. It was first developed for the PDP-7, a mini-computer from
Digital Equipment Corporation (DEC). It was then rewritten in assembly
language for the DEC PDP-11.
Also, because C was written with the idea of using it for implementing the
UNIX kernel, it was designed to be small and efficient, ideal features for an
operating system.
Expanding out
AT&T was deemed by the US government to be a monopoly, and one
consequence was that they were not allowed to sell the UNIX operating
system. Since they could not sell UNIX, AT&T leased the OS, including the
source code, to universities. With access to the code, computer science
students could learn about the operating system and experiment with
modifying it. Many of these students carried this knowledge with them into
the professional world and contributed to the expanding popularity of
UNIX.
With the breakup of their monopoly in the early ’80s, AT&T was free to
market their version of UNIX to commercial vendors. They employed
developers to enhance UNIX and also incorporated some of the BSD
features. AT&T released System V of Unix in 1989 and it formed the basis
for many commercial implementations of UNIX such as Solaris for Sun
workstations and Ultrix for Digital computers.
Standardization
With some UNIX implementations based on BSD and others based on
System V and the variability of added features provided by computer
vendors, UNIX needed standards so that applications could be shared
across platforms. The first step in standardizing UNIX began with the
movement towards standardizing the C language in 1989. The
standardization guaranteed that a C program that just used the C libraries
could run on any computer, using any operating system.
There are two UNIX standards, “Single UNIX Specification (SUS)” and
“POSIX”. Those that pass conformance tests for the SUS are granted the
right to be branded “UNIX” by the holders of the UNIX trademark. The
POSIX standard was developed by the Institute of Electrical and Electronics
Engineers (IEEE). Apple’s macOS follows the POSIX standard.
Linux
Linux is an open-source version of the UNIX operating system. Open
source means it is developed by a community and anyone can view or
modify the source code. The open source nature of this operating system
has led to many different versions of it. These versions are called
distributions, often abbreviated as distro. There are different distributions
of Linux tailored for different hardware systems from the Raspberry Pi to
versions that run on supercomputers. Linux is considered mostly POSIX
compliant but is not POSIX certified.
There are dozens of Linux distributions, but some of the more popular ones
you will hear are Debian, Red Hat, Fedora, and Ubuntu. Different
distributions may differ in which applications are included, whether they
are completely open source, and how often a stable version is released.
The distribution of Linux you will access through the terminal in this
course is Ubuntu 18.04.6 (which is based on the Debian distribution of
Linux). You can see this version at the very top of the message of the day
(the message printed when you start the terminal):
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
For the rest of this course, we will automatically clear the message of the
day so you have more screen space.
When people refer to the Linux operating system they mean the kernel as
well as the accompanying set of tools and libraries that is actually called
GNU. Some people refer to this combination as GNU/Linux (as you see in
the message of the day) but we will just refer to the kernel plus the utilities
as Linux. For the most part the utilities that are packaged with Linux are
functionally equivalent to the utilities with the same name in UNIX, but
they have been rewritten.
The Command Line Interface
The Command Line Interface, better known as CLI, or Shell is one way to
interact with your computer. The command line interface which you see in
the terminal window on the left is called Bash. It is the default login shell
for most Linux distributions. It is considered very portable and is widely
used on many UNIX implementations as well as on other operating
systems.
codio@matrixrudolf-trustgame:~/workspace$
/home/username1
/home/username2
While you can see the relative working directory after the : in the
command line prompt, sometimes it’s helpful to print the working
directory.
pwd
The shell will print the working directory directly below the command:
cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.6 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-
policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
The general syntax for cat is:
Type man bash in the terminal window on the left and use
the information provided to answer the question below.
Scroll the manual page by using the up and down arrow keys or the
scroll wheel on your mouse
To exit the manual, type the letter q.
Listing Directory Contents
ls
ls -l
ls -a
ls -m
ls -R
When you get a full listing of the directory contents you see each line start
with something like -rwxr-xr-x. This is a topic we will cover extensively in
the Processes, Services and Privileges but in short, these are the
privileges for the file. The r stands for read, the w stands for write, and the
x stands for execute. The three sets are associated with the owner, the
group and everyone. Where you see a d as the first letter, that means it is a
directory.
Did you notice how the argument to the ls command changed the output?
| Command option | Output |
|———|———-|
| (none) | A regular sorted list of files in the directory |
| -l | A more complete list with permissions |
| -a | Hidden files were included |
| -m | A comma-separated list |
| -R | Included directories and their contents |
Can you guess which are files and which are directories?
As you can see, bash sorts files and directories alphabetically starting with
the dots.
info
Dots in bash are useful utilities that help with navigating the file
system using the CLI.
In an ls -a listing…
There are a lot of arguments you can pass to ls, to see them all type man ls.
Navigating the File System
We learned about the home directory when we discussed the command
line prompt, there is another important directory to mention, the root
directory.
pwd
/home/codio/workspace
ls /
This command shows you all the directories and files that are in the root
directory.
info
## Terminal Tips
1. Cycle through all the commands you have entered using the up and
down arrow keys
2. Position your cursor at the beginning and end of the command
prompt by using ctrl-a and ctrl-e
3. Use the tab key to complete directory and filenames
Changing Directories
The command to change directories is cd as in “change directory”. To try it
out we’ll switch to the directory test.
### Type the following command at the prompt:
cd test
Now you can type in ls to see what is in that directory and then cat
followed by the name of the file that is in there. You have now explored the
test directory!
challenge
cd test
We are already in the test directory and there is no test directory inside
it.
To back out of the test directory, you could use absolute file paths (cd
/home/codio/workspace) or you can use the relative path. Earlier we
discussed the single and double dot files you see when you type the
command ls -a. The double dot file is very useful.
cd ..