September 26, 2019

## What is a computer?

• Is a general purpose device
• that can read, process and write numbers
• (and things that can be represented by numbers)
• to and from the memory
• following a program stored also in the memory
• many simple steps
• Changing the program changes the purpose of the machine

## One byte = One character

For technical reasons modern computers handle memory in bytes

• memory big enough to hold a single character
• like W or @
• Or a small integer number (0 to 255)
Byte = Integer between 0 and 255 = One letter

## Floating point

Numbers with decimals can be represented using scientific notation 1.8466 * 1019

In the computer we write 1.8466E19

Notice the meaning of E inside a number

## This has some limitations

We have a fixed number of digits

Not all numbers are represented exactly

For example $\frac{1}{3}=0.33333333\cdots$ cannot not be represented exactly with 10 digits

## Example: Sound

• Sound is transformed into electricity by a microphone.
• The voltage is measured 44100 times each second
• Each sample is stored as a number in a CD

Two steps: sampling (in time) and discretization (in voltage)

## Example: Greyscale Image

• Each “point” has a value between 0 (black) and 255 (white)
• correct name is pixel picture element
• they are stored line by line

## Structure of secondary memory

The disks store a huge amount of data

To organize it we use files

To organize the files we use folders
also called directories

## Files

Like the main memory, a file is just a list of bytes

The meaning of the file depends on the context

You can decide to change their meaning

Most of the times, the name of the file suggests a context

For example, an MP3 file is probably audio

## File attributes

Besides the data itself, files have metadata

That is, data about the data. For example

• Files have a name
• Files have a modification date, maybe other dates too
• Files have a size
• Files have permissions

## File names

The names of the files are “words”: a series of letters, numbers and some symbols

Technically, a filenames is a String or list of characters

Maximum length of a filename is 250 characters

Avoid /, :, +, |, <, *, >, " and '

Use letters (A-Z, a-z), numbers (0-9), ., -,   and _

## File names

In some systems small caps and BIG CAPS are not equivalent. Be systematic and coherent

If the filename includes ., the text after it is called extension

In Microsoft Windows (c) extensions are usually 3 letters

• EXE, JPG, DOC, XLS, TXT, CSV
• These are hints on how to interpret the file

## Kinds of file

At low level there is only one type of file

For us, it is useful to separate in two:

Text Files
each byte is a character, we can read it
Binary Files
bytes are grouped in binary numbers, representing images, sounds, etc.

Among binary files we have EXE files, which are programs for Windows

## Text Files are good

• They are universal
• They are easy to read and write from a program

Also

• They do not have any style like bold or italic
• They are like books without figures

Microsoft Word files (doc or docx) are NOT text files

## Text files are for humans and computers

• Binary files are hard to read
• unless you have the correct program
• Text files can be read by humans
• Each byte is a letter
• Text files can be read by computers
• Data must be recyclable
• The output of one program is the input of another program

## What is UNIX?

UNIX is an operating system

• invented in 1969 at Bell Labs (AT&T)
• developed in the 1970s
• under constant development ever since
• multi-user
• system for servers, desktops and laptops.

## All UNIX systems have a text interface

UNIX systems also have a graphical user interface (GUI)

• similar to Microsoft Windows
• easy to use environment

However, command line interface is also used

• for operations which aren’t covered by a graphical program
• when there is no windows interface available
• for example, using a cloud server

## Types of UNIX

There are many different versions of UNIX they share common similarities

Each company had its own version: HP/UX Solaris, Minix, Ultrix, AIX, DG/UX, Irix and Unix

It was easy to adapt a program from one machine to another: “Open architecture”

Today the most popular varieties of UNIX are MacOS X and Linux

## The origin of Linux

On 1991, Finish student Linus Torvalds decided to write a Kernel that did the same as commercial UNIX Kernel did

Doing the same but without using any of the original code

This way he could avoid copyright issues

## Open source

This project is one of the best examples of on-line collaboration enabled by the Internet

No company is owner of the system. Instead, thousands of voluntaries help with small parts

Instead of starting from 0, you find something 90% as you want, you add 10%, and give it back

Then someone else adds another 10%, and so, and so

## Stone soup legend

Some travelers come to a village, carrying nothing more than an empty cooking pot.

Upon their arrival, the villagers are unwilling to share any of their food stores with the hungry travelers.

Then the travelers go to a stream and fill the pot with water, drop a large stone in it, and place it over a fire.

## Stone soup legend

One of the villagers becomes curious and asks what they are doing.

The travelers answer that they are making “stone soup”,

which tastes wonderful and which they would be delighted to share with the villager,

although it still needs a little bit of garnish, which they are missing, to improve the flavor.

## Stone soup legend

The villager, who anticipates enjoying a share of the soup, does not mind parting with a few carrots, so these are added to the soup.

Another villager walks by, inquiring about the pot, and the travelers again mention their stone soup which has not yet reached its full potential.

The villager hands them a little bit of seasoning.

More and more villagers walk by, each adding another ingredient.

## Stone soup legend

Finally, the stone (being inedible) is removed from the pot,

and a delicious and nourishing pot of soup is enjoyed by travelers and villagers alike.

Although the travelers have thus tricked the villagers into sharing their food with them, they have successfully transformed it into a tasty and nutritious meal which they share with the donors.

Wikipedia

## Most scientific software is Open Source

Science has always been about sharing. Scientific knowledge is for everybody.

That is why UNIX is good for academia, and vice-versa

Big companies did not like Open Source. It was against their business

But today even IBM and Microsoft support Open Source

## Handling big collaboration projects

To handle open source projects with hundreds of people around the world, Linus Torvalds and others developed a system called Git in 2005

It is one of the important tools in modern projects

In 2008 a website called GitHub was created, to store open source projects

Most of scientific programs are distributed through GitHub

On June 4, 2018, Microsoft announced its trying to buy GitHub for USD 7.5 billion

## Kernel + Programs = Distribution

Linux is really only the kernel

Most of the programs, including the shell, were developed by GNU project at MIT

The selection of which programs include in a system is called a distribution

## There are many Linux distributions

Literally hundreds. Some of the most known are:

• Red Hat
• Fedora
• CentOS
• Debian
• Ubuntu
• Mint
• Lubuntu
• Ubuntu MATE
• openSUSE

## Delete everything?

The best way to use Linux is to replace Microsoft Windows™ completely

But that can be painful if you have used windows for a long time

Some tools allow you to split your disk in two halves

• One for Microsoft Windows™
• One for Linux

## We can use a server for this course

If you cannot install Linux in your computer, you can use one of the servers in our University

You are legally responsible for your account. Be careful

To connect to the server you need only one program: PuTTY

## Operating system

Set of programs which make the computer work.

The UNIX operating system is made up of three parts:

• the kernel
• the shell
• the programs

## The kernel

The kernel of UNIX is the hub of the operating system:

• it manages time and memory for programs
• handles the disk and secondary storage
• handles communications and networking

The kernel wraps the different hardware. No other software can interact with the hardware.

Programs have to ask to the kernel to access the hardware

## The shell

### Interface between the user and the kernel

When a user logs in

• then starts another program called the shell
• a command line interpreter (CLI).
• it shows a prompt $ • It interprets the commands the user types and executes them • The commands are programs • When they finish, the shell gives the user another prompt $

## The Directory Structure

All the files are grouped together in the directory structure

• The file-system is arranged in a hierarchical structure
• like an inverted tree
• The top of the hierarchy is called root
• written as /

## The Directory Structure

In the diagram above, we see that the home directory of the user ee51vn contains two sub-directories (docs and pics) and a file called report.doc

The full path to the file report.doc is /home/its/ug1/ee51vn/report.doc

## ls (list)

To find out what is in your home directory, type

## Commands can have options

ls is an example of a command which can take options: -a is an example of an option.

The options change the behaviour of the command.

There are online manual pages that tell you which options a particular command can take, and how each option modifies the behaviour of the command

## How to know the options?

In the old times, people looked it in the “Manual”

Later people realized that you can have the manual in digital form, inside the computer

To see the manual page of ls, use the command man ls

## The shell

### Interface between the user and the kernel

When a user logs in

• it shows a prompt $ • It interprets the commands the user types and executes them • The commands are programs • When they finish, the shell gives the user another prompt $