Tải bản đầy đủ (.pdf) (101 trang)

Hệ điều hành Linux cơ bản

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.2 MB, 101 trang )

Linux Fundamental
(For ICT)
By : ICT/BA
Date : Aug, 2008
Duration: 3 hours
Revision : 1.0
17/09/2009Confidential2
Course Objectives
At the end of this course, you can
Understand basic about Linux System
Install Linux
Can work with most of Linux commands,including basic administration
tips for network service and Apache, Mysql, Oracle … )
Has basic background to study more if you want to become an expert
At the end of this course, you can
Understand basic about Linux System
Install Linux
Can work with most of Linux commands,including basic administration
tips for network service and Apache, Mysql, Oracle … )
Has basic background to study more if you want to become an expert
17/09/2009Confidential3
Course Outline
Introduction
Basic concepts
Installation
Linux System Construction
Boot sequence
File system
Basic Administration
Basic commands
Install/uninstall software


Enable/disable services
Linux in practice
References
Introduction
Basic concepts
Installation
Linux System Construction
Boot sequence
File system
Basic Administration
Basic commands
Install/uninstall software
Enable/disable services
Linux in practice
References
17/09/2009Confidential4
Acronyms
•GNU: General Public License
•KDE: K Desktop Environment
•GNOME: GNU Network Object Model Environment
•FS: File System
•CLI: Command Line Interface
•LILO: Linux Loader
•GRUB: Grand Unified Bootloader
•GNU: General Public License
•KDE: K Desktop Environment
•GNOME: GNU Network Object Model Environment
•FS: File System
•CLI: Command Line Interface
•LILO: Linux Loader

•GRUB: Grand Unified Bootloader
Supplementary
Slide
17/09/2009Confidential5
Section 1: Introduction
Unix and Unix-based OS
Unix is a computer operating system originally developed in 1969 by a
group of AT&T employees at Bell Labs
Unix-based OS: Solaris(Sun), HP-Unix(HP), BSD…
Refer to References number 1 for Unix history
What is linux?
Unix-like system
Linux was initially developed by LinusTorvaldsin 1991
Linux family: refer to References number 5 detail of Linux distributions.
Here, talk about: Debian, Red Hat, Fedora, Ubuntu …
Unix and Unix-based OS
Unix is a computer operating system originally developed in 1969 by a
group of AT&T employees at Bell Labs
Unix-based OS: Solaris(Sun), HP-Unix(HP), BSD…
Refer to References number 1 for Unix history
What is linux?
Unix-like system
Linux was initially developed by LinusTorvaldsin 1991
Linux family: refer to References number 5 detail of Linux distributions.
Here, talk about: Debian, Red Hat, Fedora, Ubuntu …
17/09/2009Confidential6
Basic Concepts
17/09/2009Confidential7
Basic Concepts
Kernel:

Central component of most computer operating systems(OS).
Manage system's resources and communication between hardwareand
softwarecomponents.
Shell: interface for users access to services of a kernel.
Graphical (GUI) shell
•GNOME
•KDE
Text shell (CLI: Command line interpreter)
•sh
•Ksh: KornShell
•Bash: Bourne-again shell
Kernel:
Central component of most computer operating systems(OS).
Manage system's resources and communication between hardwareand
softwarecomponents.
Shell: interface for users access to services of a kernel.
Graphical (GUI) shell
•GNOME
•KDE
Text shell (CLI: Command line interpreter)
•sh
•Ksh: KornShell
•Bash: Bourne-again shell
17/09/2009Confidential8
Installation
Prepare installation CD.
Download .iso files:
/> /> />Burn CDs.
BIOS boot: CD first.
Installation by CDs.

Swap partition: at least, should equal RAM (flexible).
Boot partition.
Root partition: mounted to main hard disk.
Select components.
Install and setup right things for IP address, domain,…
Prepare installation CD.
Download .iso files:
/> /> />Burn CDs.
BIOS boot: CD first.
Installation by CDs.
Swap partition: at least, should equal RAM (flexible).
Boot partition.
Root partition: mounted to main hard disk.
Select components.
Install and setup right things for IP address, domain,…
17/09/2009Confidential9
Boot sequence
BIOS
Master Boot Record (MBR)
Boot loader: liloor grub
•load kernel (image=), or
•load partition boot sector (other=) (dual boot)
kernel
initialize devices
mount root FS
run /sbin/init, PID 1
Init
Reads /etc/inittab
Runs scripts defined (/etc/rc1-5.d/…)
BIOS

Master Boot Record (MBR)
Boot loader: liloor grub
•load kernel (image=), or
•load partition boot sector (other=) (dual boot)
kernel
initialize devices
mount root FS
run /sbin/init, PID 1
Init
Reads /etc/inittab
Runs scripts defined (/etc/rc1-5.d/…)
17/09/2009Confidential10
System state
System state
0 -Shutdown
1 – Single User Mode
2 – Basic Multi-user Mode
3 – Full Multi-user without X
4 – Not Used
5 – Mutli-user with X
6 –Reboot
System state
0 -Shutdown
1 – Single User Mode
2 – Basic Multi-user Mode
3 – Full Multi-user without X
4 – Not Used
5 – Mutli-user with X
6 –Reboot
17/09/2009Confidential11

File System
17/09/2009Confidential12
File System –File Permission
User/Group:
Super user: root
Normal user: annt
User info stored files:
$ cat /etc/passwd
root:x:0:0:Super-User:/:/sbin/sh
annt:x:100:1::/export/home/annt:/bin/bash
$ cat /etc/group
root::0:
annt::100:
#cat /etc/shadow
root:8gdaU2QTUw4cI:6445::::::
User/Group:
Super user: root
Normal user: annt
User info stored files:
$ cat /etc/passwd
root:x:0:0:Super-User:/:/sbin/sh
annt:x:100:1::/export/home/annt:/bin/bash
$ cat /etc/group
root::0:
annt::100:
#cat /etc/shadow
root:8gdaU2QTUw4cI:6445::::::
17/09/2009Confidential13
File System –File Permission
Character 1 is the type of file:

• d = directory
• l = symbolic link
• s = socket
• p = named pipe
• -= regular file
• c= character (un buffered) device file special
• b=block (buffered) device file special
Character 1 is the type of file:
• d = directory
• l = symbolic link
• s = socket
• p = named pipe
• -= regular file
• c= character (un buffered) device file special
• b=block (buffered) device file special
777
17/09/2009Confidential14
File System –File type
Regular files
Text file
Executable files
Directory
Directory
Mounting point
Device file
Special file provide interface to device
Link file
Hard link
Symbolic link
Regular files

Text file
Executable files
Directory
Directory
Mounting point
Device file
Special file provide interface to device
Link file
Hard link
Symbolic link
17/09/2009Confidential15
File System –Permission Example
Type "ls-l" and a listing like the following is displayed:
total 10
drwxrwxrwx4georgeteam1122Dec 12 18:02Projects
-rw-rw-rw-1georgeteam11873Aug 23 08:34 test
-rw-rw-rw-1georgeteam11234Sep 12 11:13 datafile
Which means the following:
Type and # ofFiles'sFile'sSize in Date of last Filename
Permission field FilesOwnerGroupBytesmodification
|||||| |
drwxrwxrwx4georgeteam1122Dec 12 18:02Projects
Links: The number of directory entries that refer to the file. In our example, there
are four.
The file's owner in our example is George.
The group the file belongs to. In our example, the group is team1.
The size of the file in bytes
The last modification date. If the file is recent, the date and time is shown. If the
file is not in the current year, the year is shown rather than time.
The name of the file.

Type "ls-l" and a listing like the following is displayed:
total 10
drwxrwxrwx4georgeteam1122Dec 12 18:02Projects
-rw-rw-rw-1georgeteam11873Aug 23 08:34 test
-rw-rw-rw-1georgeteam11234Sep 12 11:13 datafile
Which means the following:
Type and # ofFiles'sFile'sSize in Date of last Filename
Permission field FilesOwnerGroupBytesmodification
|||||| |
drwxrwxrwx4georgeteam1122Dec 12 18:02Projects
Links: The number of directory entries that refer to the file. In our example, there
are four.
The file's owner in our example is George.
The group the file belongs to. In our example, the group is team1.
The size of the file in bytes
The last modification date. If the file is recent, the date and time is shown. If the
file is not in the current year, the year is shown rather than time.
The name of the file.
17/09/2009Confidential16
File System (cont.)
/etc: contains all system related configuration files in here orin it's
sub-directories. No binaries should be or are located here.
/etc/fstab: lists file systems mounted
/etc/hostname: contains the hostname of your machine.
/etc/inittab: boot-time system configuration/initialization script.
/lib: contains static/shared libraries needed to boot the systemand
run the commands.
.a: static library
.so: shared library
/home:

Contains home folder for users.
/root:
home directory of the System Administrator, 'root‘.
/etc: contains all system related configuration files in here orin it's
sub-directories. No binaries should be or are located here.
/etc/fstab: lists file systems mounted
/etc/hostname: contains the hostname of your machine.
/etc/inittab: boot-time system configuration/initialization script.
/lib: contains static/shared libraries needed to boot the systemand
run the commands.
.a: static library
.so: shared library
/home:
Contains home folder for users.
/root:
home directory of the System Administrator, 'root‘.
17/09/2009Confidential17
File System (cont.)
/tmp:
Contains mostly files that are required temporarily.
Do not remove files from this directory unless you know exactly what
you are doing!
/usr:
Contains the largest share of data on a system.
•All user binaries, their documentation, libraries, header files,etc
•X and its supporting libraries.
•User programs like telnet, ftp, etc
/var:
Contains variable data like system logging files, mail and printer spool
directories. Variable data are files and directories that the system must

be able to write to during operation.
/tmp:
Contains mostly files that are required temporarily.
Do not remove files from this directory unless you know exactly what
you are doing!
/usr:
Contains the largest share of data on a system.
•All user binaries, their documentation, libraries, header files,etc
•X and its supporting libraries.
•User programs like telnet, ftp, etc
/var:
Contains variable data like system logging files, mail and printer spool
directories. Variable data are files and directories that the system must
be able to write to during operation.
17/09/2009Confidential18
Getting Started
Section 2: Basic Administration
17/09/2009Confidential19
Login -Putty
Notes: Puttyjpsupport Japanese
17/09/2009Confidential20
Login –Teraterm
Note: VNC client/server is very good tool also
17/09/2009Confidential21
Shell Basic
17/09/2009Confidential22
Shell types
Commonly used shells
/usr/bin/shPOSIX shell
/usr/bin/kshKornshell

/usr/bin/cshC shell
/usr/bin/tcshC shell with auto completion and
command line editing
/usr/bin/bashGNU Bourne Again shell
Commonly used shells
/usr/bin/shPOSIX shell
/usr/bin/kshKornshell
/usr/bin/cshC shell
/usr/bin/tcshC shell with auto completion and
command line editing
/usr/bin/bashGNU Bourne Again shell
17/09/2009Confidential23
Pipe
Pipe is a way to connect the output of one program to the input of
another program without any temporary file
Example
$who | sort
$ps-ax | grephttp
Pipe is a way to connect the output of one program to the input of
another program without any temporary file
Example
$who | sort
$ps-ax | grephttp
17/09/2009Confidential24
I/O Direction
Send output of command to file or to read input from file
Command > filename: output result of command to file
Command >> filename: append result of command to file
Command < filename: command get input from file
Standard input: 0 (keyboard)

Standard output: 1 (monitor)
Standard error: 2 (monitor)
Ex: command > log 2>&1
Send output of command to file or to read input from file
Command > filename: output result of command to file
Command >> filename: append result of command to file
Command < filename: command get input from file
Standard input: 0 (keyboard)
Standard output: 1 (monitor)
Standard error: 2 (monitor)
Ex: command > log 2>&1
17/09/2009Confidential25
Vi editor
Vim: Vi IMproved
Operation mode:
Insert mode (typing “i”)
Command mode (pressing the escape key)
Reference doc: vi_quickref.pdf
Vim: Vi IMproved
Operation mode:
Insert mode (typing “i”)
Command mode (pressing the escape key)
Reference doc: vi_quickref.pdf

×