Thao tác cơ bản với hệ thống... Thao tác cơ bản với hệ thống• Shutdown [options] [alert] – -r: Reboot right after system shutdowns – -h: Halt officially right after system shutdowns – -
Trang 1UNIX & LINUX Operating System
Thanh-Hai DANG Information Systems Dept -VNUH
Email: haidt82@yahoo.com
Trang 2“UNIX is user-friendly, but
UNIX also choose her friends very carefully”
Trang 3Course statement
• Goal
– Usage, entire administration
– Not principles of OS
• Perspective
– A friend of UNIX
– Linux in place of Windows in your mind
– Curious for the principles of OS (Go inside into it)
• Materials
– UNIX/LINUX curriculum of Asoc Prof Thuy HQ,– Linux Complete Command Reference by J.Purcell – Securing and Optimizing Linux, Gerhard Mourani
Trang 5UNIX OS.
Some characteristics
• Written in a high level language (C)
• User interface simple but powerful enough
• Good file system
• Simple connection to peripherals
• Multi User and Multi Process
• Relative independence between data and hardware
Trang 6Unix Chronology.
• Ken Thompson at Bell Labs (1969)
– Withdrew from MULTICS project
– Written in assembler for a GE-645 machine– Dennis Ritchie
– First Release in 1971
Trang 7– Bourne shell included
– Kernel largely rewritten to be more portable to other machine architectures
Trang 8Chronology (Cont.)
• The 80’s
– /usr/group established in 1981
– X/OPEN (From many EU computer companies)
– IEEE from 1984 (enhancement of POSIX)
• 1984 : the birth of 3 versions
– System V from AT&T ( System III from 82)
– 4.2 BSD of Berkeley Uni, Base for many OS: Sun Microsystems (SunOS), Digital (Ultrix)…
– XENIX of Microsoft for PC (Compatible with System V)
Trang 9Chronology (Cont.)
• At the end of 80’s, 2 organizations said hello
– UNIX International (UI)
• The agreement between AT&T and Sun : SVR4
(System V Release 4), The converged Edition of System V and BSD
– Open Software Foundation (OSF)
• IBM, Digital, HP, Bull, Siemens, Apollo, Nixdorf
Trang 10Chronology (Cont.)
• LINUX OS came into our world (1991)
– Written by Linus Torvald at Univ of Helsinki
• For the Intel i386 family of processors
• Derived from MIMIX, one of the most successful version of PC UNIX
Trang 11LINUX OS.
Some characteristics
• A typical OS for UNIX
• GUI thru X-Windows
• Many network protocols supported
• Real-time supported
• Parallel computing and PC Cluster
• Multi languages
Trang 12Free Software, Linux & Open Source
• 1984 : Richard Stallman, The Father of GNU
(Gnu is Not Unix) found Free Software
Trang 14Free Software, …(Cont.)
• 1993 : Rémy Card invented ext2 file system for Linux
• 1994 : Linux ported to the other CPU not Intel: Alpha, ARM, PowerPC, RISC, Sparc,
• 1995 : Apache Group built Web server Apache
Trang 15Distributions Linux
• Distribution = A collection of all or some programs
altogether around a Linux kernel which allows to install a collaborative system, operating perfectly
– Include one or more CD ROM
– Easily installed,
– May be other softwares not GPL or OpenSource
included
Trang 17Live CD Linux
• Distro Linux on one CD
– GNU/Linux OS Plus with necessary softwares
– Not affect the current status of PC, HD not required!
• Some typical distro
– Knoppix
– DemoLinux
– Mandows
– FreeSBIE
Trang 18UNIX architect
Trang 19Unix kernel architect
Trang 20Shell system
• The command interpreter
– Show a prompt ($) and wait from keyboard
– Receive user’s commands
– Analyse commands: Name, option values and parameters
– Use kernel to initialize a process
– Wait for process to finish
• Programming language also
Trang 21Shell …(Cont.)
• Bourne shell (sh) ($): Steven Bourne, AT&T
• Korn Shell (ksh) : David G Korn, AT&T
• C_Shell (csh) (%) : Bill Joy, UC Berkeley
• Tenex Shell (tcsh) (>) : extend of csh
• Bourne Again Shell (bash) (#) : Brian Fox, FSF (Linux)
Trang 22Environment Variables
• Used by shell and some facilities (X11, mail, )
– $HOME: home directory of user
– $MAIL: mail name
– $PATH: List of path where commands are looked for( separated by :)
• Initialize after login
– script: bashrc, bash_profile
– echo <Var_Name>
Trang 23• GNOME, KDE / X-Window (XFree86)
Trang 24Command common structure
• # <Command_Name> [<options>] [<Parameters>]
– <options>:
• Reduced : #date –d <string>
• Full: #date –date=<string>
– Eg #ls –l test.cpp matrix.cpp
• Wild Card *, ?, [abc]
• #ls –l g*
Trang 25Man Page
• Command man <command> :
– Show explanatory document for command
<command>
– Syntax + Options description + Examples
– <command> = command, library function, system file
• Note :
– Type ‘q’ to quit
– Command name exact
• Command man -k <keyword>
Trang 26Man Page (Cont.)
• COMMAND(1) Linux Programmer’s Manual COMMAND(1)
Trang 27• The scheme of inter-connecting between processes: cache memory + synchronization scheme
– read: wait if pipe empty
– Ghi (write): wait if pipe full
Trang 28pipe-line (Cont.)
• Indicated by “|”
• Usefulness: Combine some simple tools to do complex functions
– Fast, right and simple
– Re-use concept in Software Engineering
• Eg
– Count the line of C sources in directory
$cat *.c | wc -l
Trang 29Thao tác cơ bản với hệ thống
Trang 30Thao tác cơ bản với hệ thống
• Shutdown [options] <time> [alert]
– -r: Reboot right after system shutdowns
– -h: Halt officially right after system shutdowns
– -f: Quick reboot and abort disk checking
– -F: Reboot and check hard disk
– <time>: set shutdown time
• hh:mm or +<minute number>
Eg shutdown +1 shutdown after one minute!
Trang 31Thao tác cơ bản với hệ thống
Trang 32Thao tác cơ bản với hệ thống
• Start and work in graphical model
– Allow to customize working mode of system
– Enumerated in /etc/inittab
# 0 – halt (Do NOT set initdefault to this)
# 1 – Single user mode
Trang 33Thao tác cơ bản với hệ thống
• Start and work in graphical model
– Id:3: initdefault: Id:5: initdefault:
– Use command $startx
Trang 34Thao tác cơ bản với hệ thống
• Command for Showing and setting date and time
– Show: date [options] [+format]
– Set: date [options] [MMDDhhmm [ [CC]YY]
• Options
– -d, date=<string>: shows time in <string>
parameter, not show the current system time
– -f, file=<text_file>
– -I, iso-8601[=‘date’ | ’hours’ | ‘minutes’ | ‘seconds’]: Shows according to the standard ISO-8601 (2000-11-8)
Note: -I ~ iso-8601=‘date’
Trang 35Thao tác cơ bản với hệ thống
Trang 36Thao tác cơ bản với hệ thống
• [+format]
– %%: show character %
– %a: Abbreviated weekday name in the locale (Wed for wednesday)
– %A: Full weekday name in the locale
– %b: Abbreviated month name (Mar for March)
– %B: Full month name
Trang 37Thao tác cơ bản với hệ thống
• [MMDDhhmm[[CC]YY] used to set the current time of system
– MM: Two numbers indicate month
– DD: day index in month
– hh: hour in day
– mm: minute
– CC: Two numbers indicate century
– YY: Two number indicate year
Trang 38Thao tác cơ bản với hệ thống
Trang 39Thao tác cơ bản với hệ thống
– -y: Display a calendar for the current year
Trang 40Thao tác cơ bản với hệ thống
• Gets name and information about the current kernel
– uname [options]
• [options]
– -a, all
– -m, machine: processor architect
– -n, nodename: Computer name
– -r, release: OS kernel
– -s, sysname: Name of OS
– -p, processor: processor type
#uname –a
Linux linuxsrv.linuxvn.net 2.2.14-5.0#1 Tue Mar 7 21:07:39 EST 2000 i386 unknown
Trang 41Thao tác cơ bản với hệ thống
• Shell prompt
– $PS1: when entering command ($ or #)
– $SP2: when waiting for input data from keyboard
• How to change:
– # PS1=‘ <char_sequence>’
– # PS1=‘ < char_sequence>’
Trang 42Thao tác cơ bản với hệ thống
• \! Display the command index in history
• \# Display the command index
• \$ Display $, for super user, that is #
• \\ Display \
• \d Display current date
• \h Display machine name
• \n New line character
• \s Display shell file name
• \t Display current time
• \u Display user name
• \W Display current directory name
• \w Display current directory full-path
Trang 43Thao tác cơ bản với hệ thống
• Sample on changing $PS1 variable
– root@may1 /hda1]# PS1=‘[\h@\u \w : \d]\$’
[may1@root /mnt/hda1 : Fri Oct 27 ]#
Trang 44THIS LESSON ENDED
&
SEE YOU NEXT WEEK