What is a computer in fact?
Main characteristics of a computer:
Several levels between the machine and the user:
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:
(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'.
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.
Paths:
/... : 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:
- 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).
Directories are files.
An important principle in Unix: EVERYTHING IS A FILE!
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 directorymkdir : make directory
ls -l gets long list
ls <file_names> lists the given files or directories
ls -R lists recursively the subdirectories
etc.Always list the directory you have just done something! Check yourself after every step!
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.)