Introduction to Linux (I) - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to Linux (I)

Description:

Title: Chapter 1 Subject: Basic Concepts Author: Kip Irvine Last modified by: user Created Date: 5/30/2002 2:31:33 AM Document presentation format – PowerPoint PPT presentation

Number of Views:177
Avg rating:3.0/5.0
Slides: 36
Provided by: kipir
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Linux (I)


1
Introduction to Linux (I)
CS1103 ????????
  • Prof. Chung-Ta King
  • Department of Computer Science
  • National Tsing Hua University

(Contents from ??? (http//yenjinc.info), Dr.
Sven Hessler, Prof. Cédric Notredame)
2
Outline
  • Overview of Unix System
  • Basic Commands
  • Relative and Absolute Path
  • Redirect, Append and Pipe
  • Permission
  • Process Management
  • Install Software
  • Text Editor
  • Foreground and Background Jobs

3
What Is Linux?
  • Linux ????????????????
  • ???? (open source)??????? Linux-?????????????????
  • Linux???
  • UNIX1970???Bell Lab????,?????????minicomputers?wo
    rkstations?
  • ???? UNIX???????????,????????
  • Andrew Tanenbaum??OS???,?? UNIX????????PC??????Min
    ix (1986)
  • 1991?Linus Torvalds???Minix??Linux
  • GNU??Linux kernel????????

4
Linux Distributions
  • ??Linux???? SuSe, Gentoo, Fedora, Debian,
    Ubuntu,
  • ????Linux kernel,?????????GNU ??????????? (Open
    Source Software)
  • ???????????????????

Linux Distribution ?????
??????????????????,??????????????,?????????
Applications/Open Source Software
????/??????
Linux Kernel
5
Why Linux?
  • Used in many servers and embedded systems
  • Web servers, mail servers, firewalls, printer
    servers, wifi access points, disk servers
  • Google phone (Android), OpenMoko
  • Note Many do not have GUI, but text mode
    interface
  • Penetrating into desktops and notebooks with
    easy-to-use GUI eeePC, OS X

6
Installing Linux
  • Traditional way installing Linux from CD ROM on
    hard disk partitions
  • Use virtualization software VMware, QEMU,
    virtual box, XEN
  • x86 virtualization the method by which x86-based
    "guest" OS are run under another "host" x86 OS,
    with little or no modification of the guest OS
    (wiki)
  • For example on Windows
  • ubuntu (http//www.ubuntu-tw.org)
    ubuntu-8.10-desktop-i386.iso
  • virtual box (http//www.virtualbox.org)

7
Linux????
  • Linux??????????????

???????????????????????????????X-window
??,??????????????
Applications
X-window Apps
Server Apps
??????????????
OS Utilities/Applications
Kernel
???????
Hardware
????
8
Linux from Users Perspective
  • Underneath the windows GUI system, users interact
    with Linux kernel through shell
  • Shell interprets users input as commands and
    pass them to kernel
  • Operates in a simple loop
  • accepts a command
  • interprets the command
  • executes the command
  • displays a prompt, to notify userthat it is
    ready to accept the next command
  • ???????

9
Directory Structure
  • Linux???/ (root)?????,????????????/ ??
  • ????????? (partition),???/ ??,??mount
    (??)???,??????
  • Windows???C\, D\???????
  • All directories are in a hierarchical structure
    (tree structure)
  • Users have the own directory (home directory)
  • The path is the location of a file or directory
    within the tree, e.g. /usr/sbin/bzip2,
    ../../john, /home/john
  • Support access control by defining permissions
    for read, write, and execution

10
Directory Structure
11
Important Directories
  • /bin contains files that are essential for
    correct operation of the system
  • available for use by all users
  • /home stores user home directories
  • /var stores files which change frequently, and
    must be available to be written to
  • /etc contains various system configuration files
  • /dev contains various devices as files, e.g.
    hard disk, CD-ROM drive, etc.
  • /tmp temporary files

12
Other Things to Know
  • Normal user and super user
  • There is one special user for administrator,
    which can do anything and is called root or
    superuser
  • Case sensitivity
  • Linux is case-sensitive
  • Multi-user and multi-process
  • Many people can use a machine at the same time
  • File and process
  • Almost everything (data, directory, process, hard
    disk) are expressed as a file
  • Process is an running program identified by a
    unique id (PID)

13
Basic Commands
  • When you interact with shell, you will sees the
    prompt, something likeking_at_my_pc
  • A command consists of three parts, i.e. command
    name, options, arguments
  • king_at_my_pc command-name optionA optionB
    arg1 arg2
  • Options always start with -
  • Examplecd ..ls l .bashrcmv fileA fileB

14
Basic Commands
  • ls show files in current position
  • cd change directory
  • cp copy file or directory
  • mv move file or directory
  • rm remove file or directory
  • pwd show current position
  • mkdir create directory
  • rmdir remove directory
  • less,more display file contents
  • man display online manual

15
Basic Commands
  • su switch to superuser
  • passwd change password
  • mount mount file system
  • umount unmount file system
  • df show disk space usage
  • ps show current processes
  • shutdown reboot or turn off machine
  • grep XXX show lines matching pattern XXX in
    File

16
Relative and Absolute Path
  • Path means a position in the directory tree
  • Two ways to express a path
  • Relative path expression the path depends on the
    current directory
  • . the current directory
  • .. the parent directory
  • pwd gives the current path
  • Absolute path expression the path is defined
    uniquely from the root /home/linux/ /linux (
    home directory/linux)

17
Other Features of Shell
  • Take bash as an example
  • It supports history, command line editing,
    customization
  • Start up .bashrc, .cshrc
  • Environment variables PATH, PS1, SHELL,
    TERM, EDITOR, HOME
  • Moving around ?, ?, Home, End
  • Previous commands ?,?, !!, !1, !2, !x
  • TAB ? shell ?????????
  • ??????????,????,shell ???????????????????
  • ????????

18
Other Features of Shell
  • Wildcard
  • ? a single character
  • zero or more characters
  • b-d either b, c, or d
  • fconf, locg either conf or loc
  • Examplels -d /etc/b-h??.conf,loc??
  • c (ctrl-c) kill the command
  • d (ctrl-d) end the input

19
Redirect and Append
  • Redirect and append
  • Output of command is displayed on screen
  • Use gt to redirect the output from screen to a
    file
  • Use gtgt to append the output to bottom of the
    file
  • Three types of input/output
  • Standard input ??? 0,??? lt ? ltlt
  • Standard output ??? 1,??? gt ? gtgt
  • Standard error ??? 2,??? 2gt ? 2gtgt
  • ????????
  • ????????????
  • ??????? ?,?????????
  • ?????? ???,?????????

20
Pipe
  • Pipe
  • Some commands require input from a file or other
    commands
  • Use to use output from another command as
    input to the command
  • Example ls /etc/ sort nl gt file1.txt

21
Permission
  • All of files and directories have owner and
    permission
  • Three types of permission readable, writeable
    and executable
  • Permissions are given to three kinds of group
    owner, group member and others
  • Example
  • ls -l .bash_profile
  • -rw-r--r-- 1 cnotred 191 Jan 4 1311
    .bash_profile
  • rreadable, wwritable, x executable

22
Permission
  • Command
  • chmod change file mode, add or remove
    permission
  • chown change owner of the file
  • Example
  • chmod aw filename
  • add writable permission to all users
  • chmod o-x filename
  • remove executable permission from others
  • chmod ax
  • Gives permission to the user to execute a file
  • u user (owner) g group o others a all

23
Process Management
  • Process is a unit of running program
  • Each process has some information, like process
    ID, owner, priority, etc
  • Example Output of top command

24
Process Management
  • kill stop a program
  • The program is specified by process ID
  • killall stop a program
  • The program is specified by command name
  • ps show process status
  • top show system usage statistics

25
Foreground and Background
  • Running job has two modes, foreground and
    background
  • Background job the program keeps running even
    after your session was closed
  • Foreground job
  • ctrl-c stop program
  • ctrl-z let program go into background
  • To run programs in background mode king_at_my_pc
    command
  • To get background job back into foreground
    king_at_my_pc fg

26
Remote Login and File Transfer
  • rshd, telnetd, ftpd, sshd are server program to
    provide remote login and file transfer
  • Remote login and file transfer are based on
    server and client model. Client program on your
    machine ask sever program certain service remote
    machine.
  • Sample client programs
  • WS FTP FTP client
  • Internet Exploror HTTP client
  • Eudora POP, SMTP client

27
Text Editor vi
  • vi ???????
  • ????
  • ????
  • ???????

28
Text Editor vi
?? (??) ?? ?? (??) ??
i ???????????
I ?????????
a ???????????
A ?????????
o ??????????
O ????????????
ESC ?????????
29
Text Editor vi
???? ????
0 ?????
1G ?????
?????
G ?????
w ????????
x ??????????
X ???????????
30
Text Editor vi
???? ????
NUM ???NUM??
y ??
y y ?????
d ??
d d ?????
d 0 ???????
d ???????
31
Text Editor vi
???? ????
d 1G ???????
NUM .. .. 3 d d ????
.. NUM .. d 3 w ?????
r ????????
x ?? / ??
p ??
u ?????????
32
Text Editor vi
????? ?????
e ????
w ????
w q ??????? (?x???ZZ?)
w q ! ???????????
q ?????
q ! ?????????
33
Text Editor vi
????? ?????
/ ???? (n ????)
s/old/new/g ???? old ??? new
1,30s/old/new/g ?????????????? old ??? new
1,s/old/new/g ???????? old ??? new
1,s// /g ??????????????
34
Install Software
  • Unix system has a de facto standard way to
    install a softwareconfigure ? make ? make
    install
  • Typical software installation procedure as
    following
  • Download source code Usually, its archived with
    tar command and compressed with gzip command
  • Configure command creates Makefile automatically
    which is used to compile the source
  • Program compilation is written in Makefile

35
Install Software
  • gzip compress a file
  • gunzip uncompress a file
  • tar archive or expand files
  • configure create Makefile
  • make compile and install software
  • Example
  • gunzip software.tar.gz
  • tar xvf software.tar
  • cd software
  • ./install OR make all OR
Write a Comment
User Comments (0)
About PowerShow.com