Upload
buidang
View
257
Download
3
Embed Size (px)
Citation preview
Linux Distributions • Debian GNU/Linux (Xandros, Knopix,...)
– a free operating system that provides almost 4000 software packages for six architectures (Intel, Motorola, Alpha, SPARC, PowerPC, ARM) and is developed entirely by volunteers over the Internet
• Fedora/RedHat – a Red-Hat-sponsored and community-supported open source project. The goal of The Fedora
Project is to work with the Linux community to build a complete, general purpose operating system exclusively from free software. Development will be done in a public forum
• Mandrake Linux – a friendly Linux Operating System which specializes in ease-of-use for both servers and the
home/office. It is freely available in many languages throughout the world • Slackware
– a long running Linux distribution that descends from the SLS Distribution • SuSE Linux
– an extremely popular distro that features excellent documentation, thousands of applications on a DVD/CD-ROM set
• Gentoo Linux – an optimized GNU/Linux distribution featuring 5 different pgcc-optimized builds, including Intel
Pentium, Pentium Pro/II/III and AMD K6 optimized
BSD Versions
• FreeBSD - Focusing on features and ease of use
• Darwin (OS X) - Focusing on the desktop and multimedia with use of the Apple's Aqua Interface
• NetBSD - Focusing on portability
• OpenBSD - Focusing on security
• PicoBSD - Focusing on size (extremely small)
• DragonflyBSD - Focusing on new computing paradigms
Citi brīvi pieejami Unix
• Solaris 10 – x64/x86
• % isainfo -v
• 64-bit amd64 applications
• 32-bit i386 applications
– SPARC
• Darwin
• Minix
Essential Unix Architecture Applications
System Libraries (libc)
System Call Interface
Hardware
Architecture-Dependent Code
I/O Related Process Related
Scheduler
Memory Management
IPC
File Systems
Networking
Device Drivers
Mo
du
les
Kernel services • Border between kernel level and user level code is supported by the
hardware protection • Kernel is working in completely isolated address range and it’s
impossible to get access to that address space from user level • Any interaction between user level code and kernel possible only by
means of system call, which are strictly controlled by the kernel • In most cases system calls are synchronous for user level application. • But it is possible that kernel will make some work sometimes after it
returns results to the user level. • In most cases system call is implemented by the means of hardware
exception, that change CPU working mode and current virtual memory content
• Kernel is controlling system call arguments very strictly before executing the system call.
• Every system call arguments will be copied to the kernel address space in order to garantee, that arguments will not be changed during the system call
• The addreses, where the result of the system call will be placed, have to be owned by the process, who called system call (checked)
• If system call got an error, it returns -1 and sets global errno variable.
System Calls
• System Calls for process control – fork() – wait() – execl(), execlp(), execv(), execvp() – exit() – signal(sig, handler) – kill(sig, pid)
• System calls for low level file I/O – creat(name, permissions) – open(name, mode) – close(fd) – unlink(fd) – read(fd, buffer, n_to_read) – write(fd, buffer, n_to_write) – lseek(fd, offest, whence)
• System Calls for IPC – pipe(fildes) – dup(fd)
• Total ~270 System Calls in Linux kernel v2.6 – Portable Operating System Interface
(POSIX) – ISO/IEC 9945 – IEEE 1003 – Single UNIX Specification (SUS) – Linux Standard Base
System Calls for Memory Management
• s is an error code
• b and addr are memory addresses
• len is a length
• prot controls protection
• flags are miscellaneous bits
• fd is a file descriptor
• offset is a file offset
System Calls for File Management
• s is an error code
• fd is a file descriptor
• position is a file offset
System Calls for Directory Management
• s is an error code • dir identifies a directory stream • dirent is a directory entry
System Calls for File Protection
• s is an error code
• uid and gid are the UID and GID, respectively
System Calls for Process Management
s is an error code pid is a process ID residual is the remaining time from the previous alarm
httpd
lpd
Processes
/etc/init
kernel Process 0: Kernel bootstrap. Start process 1.
Process 1: create processes to allow login.
inetd
/etc/getty
fork
exec
/bin/login
exec
shell
exec
/etc/getty
fork
exec
/bin/login
exec
shell
exec
condition terminal for login
check password
command interpreter
kernal mode
user mode
Different Shells
• Bourne
• C Shell
• Korn Shell
• BASH Last login: Tue Sep 21 07:58:17 2004 from 81.198.226.108
[root@unix root]#
[root@unix root]# ps
PID TTY TIME CMD
20879 pts/7 00:00:00 bash
20905 pts/7 00:00:00 ps
[root@unix root]#
[root@unix root]# ls -l
total 64
-rw-r--r-- 1 root root 1204 Sep 20 16:11 anaconda-ks.cfg
-rw-r--r-- 1 root root 49872 Sep 20 16:11 install.log
-rw-r--r-- 1 root root 2306 Sep 20 16:11 install.log.syslog
[root@unix root]#
[root@unix root]# pwd
/root
[root@unix root]#
Ieejot sistēmā, lietotājam automātiski tiek iestādītas dažas “environment variables”. Lai tos aplūkotu, jāizpilda komandu env. Piemēram:
• PWD=ceļš #kur atrodamies
• TZ=(EET) #laiku zona (East European Time)
• PAGER=(less, more) #lasītājs pēc noklusēšanas
• LOGNAME=vārds #lietotāja vārds
• HOME=/home/vārds #lietotāja mājas katalogs
• HOSTNAME=resursdators #resursdatora vārds
• LD_LIBRARY_PATH=:ceļš #dinamiskās bibliotēkas
• MANPATH=:ceļš #ceļš, kur meklējas “manual”
• ENV=/etc/bash_common #kur ir “environment variables”
• LESS=-fdeiMQw #atslēgas lasītājam pēc noklusēšanas
Environment variables.
• EDITOR=/usr/local/bin/joe #redaktors pēc noklusēšanas
• TERM=vt100 #termināla tipa uzstādīšana (lietotājam)
• PS1= \u@\h (\w) #aicinājuma formāts
• Machtype=mašīnas_tips #mašīnas tips (aparatūra)
• MAIL=ceļš #fails, kur noliek ieejošo pastu
• RHOST=hosta_adrese #kādā datorā mēs esam
• SHELL=ceļš #lietotāja komandinterpretators
• HOSTTYPE=hosta_tips # resursdatora tips
• OSTYPE=OS _tips #OS tips (solarisN.N, utl.)
• PATH=ceļš:jauns_ceļš #meklēšanas saraksts. Ar to palīdzību tiek meklēti izpildāmi faili
• LESSCHARSET=latin1 #attēlu kodētājs
• _=ceļš #kur atrodas atbilstošais fails (env)
Environment variables (Turpinājums).
Environment Variables
[root@unix /]# env
HOSTNAME=unix.mii.lu.lv
TERM=vt100
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=::ffff:81.198.226.108 1289 22
SSH_TTY=/dev/pts/3
USER=root
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:
USERNAME=root
MAIL=/var/spool/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
INPUTRC=/etc/inputrc
PWD=/
LANG=en_US.UTF-8
SHLVL=1
HOME=/root
BASH_ENV=/root/.bashrc
LOGNAME=root
SSH_CONNECTION=::ffff:81.198.226.108 1289 ::ffff:159.148.108.245 22
LESSOPEN=|/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES=1
_=/bin/env
OLDPWD=/sys
[root@unix /]#