Tekstmanipulatie, week 9

General Introduction

What is a computer in fact?

Main characteristics of a computer:

Software: you can enter it as easy as data, and it changes what the computer does. (Before, you had to rebuild the whole machine.)

John v. Neumann - Herman Goldstine (1948): binary system + controlled by a software program

Several levels between the machine and the user:

Why using PC's at post offices or for typing simple letters? The advantages of this kind of modularity are: ... therefore wider market to sell them, so they are cheaper.


Unix as an operating system. And also a culture, a way of thinking. Starting at AT&T, in 1969... standards and plenty of variations (Linux).

(Miles Osborne's Unix slides .)

Elements of the Unix philosophy:

Unix shells

A shell is really the envelope around the computer: it receives the commands and executes them. How does it work? Different types of shells [different kinds of prompts]: Korn shell (ksh) [%], C-shell (Csh) [$], Bourne shell [$], Bourne Again shell (bash) [>]

(Additional information possibly before the prompt.)

We most often use the Bash-shell. It is practical, saves you typing a lot:

- cursur up: previous commands
- TAB: fills in the file names, if there is only one possibility
- TAB TAB: if there are more possibilities, you can get a list of them by typing TAB a second time

The User

Logging in, login name, password, changing password ('passwd'), logging out ('logout', 'exit', ^d)
A user is given:

- a user name (login name)
- a password
- a home directory

When you log in (login name + password), a shell is launched. This shall looks after you, waits for your commands, and executes them. Finally, you can exit the shell ('logout', 'exit', ^d), but then who takes care of you? If nobody, then you are logged out.

Root privileges vs. 'regular users'. 

The UNIX file system

What is a file? ...
Finding the needed file out of thousand ones...
Everything is a hierarchical tree: root + branches (= directories) + leaves (= files)

Actual working directory: where you are now.

Home directory: each user is given a home directory. This is where you get when you log in.


/... : the root directory
.../... : subdirectories (cf. \ in DOS!)
~ : home directory (crucial border between the system and the user)
. : the actual working directory
.. : the parent directory of .
../.. : grand-parent, etc.

/abc : a file in the root directory
~/abc : a file in my home directory
./abc : a file in the actual working directory
../abc : a file in the parent directory of the actual working directory.

'pwd' : print working directory
'ls' : list
mkdir : make directory
cd : change (working) directory
cat: catenate (concatenate) (lat. catena = 'chain') : use now this to create the simplest files.

A few important remarks about file names:

Different types of files:
- data files: not executable, but programs can read and / or write (re-write) them.
- program files: executable files (see also permissions )
- directories (yes, even directories are a special type of file)
- links , and other special types of links (e.g. the peripherals, like the floppy disc, the keyboard or the screen, are also files).

An important principle in Unix: EVERYTHING IS A FILE!
Directories are files.
Drives are also files (directories) within the same hierarchy (e.g. /media/floppy/) (unlike DOS, like Windows).
The "screen" is also a file (e.g. /dev/tty1 or /dev/pts/1).
This principle will be very important when speaking of pipes .

Unix commands

Commands are program files that you can launch from the shell.

The general syntax of them is:

command [-options] [arguments]

Remark: [...] always means that this part is optional. What means e.g. abc [de [fg]] ?

Getting help / information about a given command:

man <command's_name>
<command's_name> - -help | more

To scroll down in either `man' or `more', just press <SPACE>. To leave these programs, press Q.

Basic commands

Getting help / information about a given command:

man <command's_name>
<command's_name> - -help | more

We will use the command 'cat' to create and to read files, although we will discuss it only next week:

cat > file_name puts the text we are typing into the file, and we finish the file by typing ^d (where ^ refers to CTRL)
cat file_name gives us the content of that file.

passwd : change your password

logout : logging out (on Linux graphical terminals: use the logging out button instead)

exit : quit the shell (practically speaking, it means very often logging out)

cd : change (working) directory
Going home with 'cd' or 'cd ~'

pwd : print working directory

who : who are logged in?
'whoami' or 'who am i'

date : gives the actual date and time

cal [month] year : gives the calendar of that given month / year. Try 'cal 9 1752', and remember what you know about the Julian and the Gregorian calendar!

ls : list

ls lists the actual working directory
ls -l gets long list
ls <file_names> lists the given files or directories
ls -R lists recursively the subdirectories

Always list the directory you have just done something! Check yourself after every step!

mkdir : make directory

mkdir <dir_name> [<dir_name>...]

rm, rmdir : remove files and directories

rm -r : removes the subdirectories recursively
rm -i : asks for affirmation

cp : copy
mv : move

cp / mv [options] <origin> <destination>
The destination can be both a file name or a directory

A very very important rule : if a file has been removed, there is no possibility forever to recover it, unlike in the case of DOS!!! (Remember, Unix is designed for multiple users working parallel in the same file structure.)

Bíró Tamás:
English web site
Magyar honlap

Last modified: Thu Jul 3 11:39:17 METDST 2003