Unix - part 1
-
invented - USA - Bell Labs - 1970 (written mainly in C)
-
1991 - Linus Torvalds wrote part of LINUX (Unix on PC)
Key Concepts
-
multi-user
-
group working
-
pipes
-
powerful shell scripting
-
software tools
O S Structure
+---------------+
| shell |
| +---------+ |
| | kernel | |
| | | |
| +---------+ |
+---------------+
The kernel deals with
-
scheduling processes (switching between programs)
-
low-level IO
-
interrupts
The shell sits on top of the kernel, and uses it. Shell provides
-
file system (names, folders..)
-
command-line interpreting
-
shell scripting
On top of all this, there are several GUI systems we can run, which give it windows, mouse facility.
Linux
Many components for a PC version of Unix were created before Linus arrived.
But he wrote the kernel, resulting in a PC open-source version of Unix for PC was available - Linux.
Filing System
Allows 'proper' sharing of files. Each file can have 3 categories of protection
-
read/write .......(unsafe)
-
read-only .......(safer)
-
execute .........(even safer)
There are also 3 categories of user
We can combine these to produce a range of levels of protection for each file and/ or folder, e.g:
-
file1: everyone can execute only
-
file2: friends and you can read (you can choose your friends)
-
file3: only you can do everything to a file.
I.O. redirection and pipes
We can use > to redirect the output of a program into a file
If we type the ls command , it displays our file names, as in:
ls (we type)
fred.java (displayed by the ls command)
test.txt
Now we type:
ls > myfiles
nothing is displayed - what would have been displayed is placed in the new
file named 'myfiles'
Now we will use the wc (word count) tool, which counts the number of lines in its input data.
We use < to send a data file to it.
wc < myfiles
We can also send the output of one program to the input of another program, without using a file. We use
the pipe |
ls | wc
Both programs appear to run at the same time, in RAM. A pipe is a queue of characters held in RAM.
Data flow:
characters in transit
ls ------>---------------------->--------- wc
queue back queue front
behind the scenes, the kernel switches between ls and wc.
Q: when must ls and/or wc wait?
Summary
-
Had advanced facities early
-
command-line important
-
I/O redirection and pipes taken up by DOS
-
tool-building by connecting together existing programs
-
Linux is a PC version of Unix.