SlideShare a Scribd company logo
1 of 52
Ch1 Linux Basics

            Jianjian SONG
            Software Institute, Nanjing
            University
            Sept. 2004
Content
1.   What is Linux?
2.   Linux/UNIX Overview
3.   Installation
4.   Using the System
5.   Linux Programming Prerequisite
1. What is Linux?
   A free Unix-type operating system
    developed under the GNU General
    Public License.
       Open source
       Popular
       Support most of the platforms available
A Short History of UNIX
   Multics, AT&T Bell Lab, GE, MIT
   1969, UNIX, Ken Thompson, Dennis Ritchie
   1973, Rewrite UNIX with C
   Berkeley UNIX(BSD UNIX)
   1983, System V
   Commercial products
       SunOS, Solaris, HP-UX, AIX, SCO UNIX
   Standards
       SVID, IEEE POSIX, X/Open XPG4.2
A Short History of Linux(1)
A Short History of Linux(2)
GNU & Linux
   GNU/Linux System
                               GNU software/library
       Linux kernel
       GNU software/library      Linux kernel

   Distributions :
       Red Hat, Debain, SuSe,
        Mandrake, Redflag…
2. Linux/UNIX Overview
   早期的 UNIX
       一个简单的文件系统
       一个进程子系统和一个 Shell (命令解释
        器)
   内核和核外程序
用     用       用          用
         户     户       户          户

                    Shell
核外程序
              高级语言和实用程序


                   系统调用


                                      进程间通
        文件子系统                           信
                            进程
                            管理        调度程序
内核                          子系统
              高速缓存
                                      存储管理
            块设
       字符设备
             备
       设备驱动程序

                   硬 件 控 制

                   硬        件
Programmer’s Viewpoint
3. Installation
   Distributions :
       Redhat
       Debian
       SuSe
       Mandrake
       ……
   Live CD
       KNOPPIX
   Using virtual machine
       VMware
Installing Linux
   Boot system from bootable media
   All installation programs need to perform essentially
    the same steps:
       Choose language, keyboard type, mouse type
       Create partitions
       Setup a boot loader
       Configure network
       Configure user and authentication
       Select package groups
       Configure X
       Install packages
       Create boot disk
Partitioning Theory
Disk Partitioning
   At a minimum, create
       /, 750MB (1.5G or more recommended)
       Swap, size equal to amount of memory
   Recommended: /boot (16MB)
   May need/want to create other partitions:
       /usr, /usr/local, /var, /tmp, /opt, /home
   Default partitioning program under Linux is
    fdisk
       Distributions may add their own partitioning
        programs
Boot loader
   A boot loader loads and starts the Linux
    kernel
       Can pass boot parameters to the Linux kernel,
        such as device information
       Can optionally load an Initial Root Disk
       Can boot other operating systems as well
   Common Boot loaders:
       LILO: Linux Loader
       GRUB: Grand Unified Boot Loader
   Generally configured in /dev/hda, unless
    other boot loader is used.
Boot loader (cont’d)
   LILO
       Program to set up the MBR
       Syntax: lilo [-v] [-v] [-C config-file] [-t]
       Configuration file /etc/lilo.conf
       Configures MBR according to configuration file
   GRUB
       Program stored in MBR (first stage) and in /boot/grub (1.5th
        and second stage)
       Understand file system structure; no need to activate a
        configuration as with LILO
       Configuration file /boot/grub/grub.conf
       Installed in MBR with grub-install
Linux Startup Flow
  power on         BIOS
                        Checks memory, loads options from non-
                         volatile memory, checks for boot devices,
                         loads MBR of boot device and executes it
    BIOS           MBR
                        Contains a “boot loader” and the partition
                         table
 boot loader            Traditionally set up by LILO/GRUB
                   Boot loader
 Linux kernel           Loads the compressed kernel image into
                         memory
                        The kernel uncompress itself and starts…
     init
                   Init process
                        Configuration file /etc/inittab
                        run levels
 system ready
4. Using the System

   Basic Knowledge
   Working with Files and Directories
   Working with Processes
   Linux Documentation
Multi-user and Multi-tasking
   Linux is a multi-user, multi-tasking operating system
       Multiple users can run multiple tasks simultaneously,
        independent of each other.
   Always need to “log in” before using the system
       Identify yourself with user name, password
   Multiple ways to log in to the system
       Console: Directly attached keyboard, mouse, monitor
       Serial terminal
       Network connection
Virtual Terminal
   In most Linux distributions, the console
    emulates a number of virtual terminals
   Each virtual terminal can be seen as a
    separate, directly attached console
       Different users can use different virtual terminals
   Typical setup:
       VT 1-6: text mode logins
       VT 7: graphical mode login prompt (if enabled)
   Switch between VTs with Alt-Fn (or Ctrl-Alt-
    Fn if in X)
Linux Commands
   Everything on a Linux system can be done by
    typing commands
       the GUI (X-Window) is not needed for running a
        Linux System
   In order to type commands in X-Window you
    need to start a terminal emulator
   Command Prompt
       Can be configured yourself
       $ - “logged in as a regular user”,
       # - “logged in as root”
Command Syntax
   Linux commands have the following
    fomat:
    $ command option(s) argument(s)
   Examples:
    $ ls
    $ ls –l
    $ ls /dev
    $ ls –l /dev
Some Basic Linux Commands
   passwd: Change your password
   mkpasswd: Generate a random password
   date, cal: Find out today’s date and display a
    calendar
   who, finger: Find out who else is active on the system
   clear: Clear the screen
   echo: Write a message to your screen
   write, wall, talk; mesg
   ……
Working with Files & Directories
   What is a file?
       A collection of data;
       An object that can be written to, or read from, or
        both. A file has certain attributes, including access
        permissions and type. (susv3)
   File structure
       Generally: byte stream, record sequence, record
        tree
       In Linux: byte stream
File Types
   regular file
       Text or code data; no particular internal structure
   character special file
   block special file
       Special files: represent hardware or logical devices
       Found in directory called /dev
   fifo
   socket
   symbolic link
   Directory
       A table of contents; a list of files in that directory
File System
   What is File System
       操作系统中负责存取和管理文件的部分
       A collection of files and certain of their
        attributes. It provides a name space for file
        serial numbers referring to those files.
        (susv3)
   File System in Linux:
       VFS
       EXT2, EXT3, FAT32, …
Directory Structure
   All Linux directories are contained in
    one, virtual, “unified file system”.
   Physical devices are mounted on mount
    points
       Floppy disks
       Hard disk partition
       CD-ROM drives
   No drive letter like A:, C:, …
A Example of Directory Structure
Main Directories in Linux




   Linux File System Standard:
     http://www.pathname/fhs
Basic Commands(1)
   Commands used with directories:
       pwd: print working directory
       cd: change directory
       mkdir: make directory
       rmdir: remove directory
       ls: list the contents of directories
            -l, -a, -R, -d options
Basic Commands(2)
   commands used with files:
       touch: update the access and/or modification time of a files
       cp: copy files
       mv: move and rename files
       ln: link files
       rm: remove files
       cat: concatenate files
       more/less: display files page by page
       od, strings: display binary files
       split: splits files
File Permission
Changing Permissions
Changing Permissions (cont’d)
Default File Permissions
   The default permission for newly created files
    and directories are:
    File:      -rw-rw-r-- 644
    Directory: drwxrwxr-x 775
   Why?
       umask: an octal number which contains the bits
        that are NOT set as permission bits.
       Default 002 for normal user, 022 for root.
Editing Files
   vi
   emacs
   gedit
   …
Working with Processes
   What is a process?
       A process is a task.
       进程是一个正在执行的程序实例。由执行程
        序、它的当前值、状态信息以及通过操作系
        统管理此进程执行情况的资源组成。
       An address space with one or more
        threads executing within that address
        space, and the required system resources
        for those threads. (susv3)
Working with Processes (cont’d)
   A running program is an example of a
    process




   A shell is a process that reads your
    commands and start the appropriate
    process.
       echo $$
Starting and Stopping a Process
   All processes are started by other processes
       Parent/Child relationship
       One exception: init (PID 1) is started by the kernel
        itself
       A tree hierarchy
   A process can be terminated because of two
    reasons:
       The process terminates itself when done.
       The process is terminated by a signal from
        another process
Basic Commands
   ps: report process status
   pstree: display a tree of processes
   jobs, fg, bg, <ctrl-z>: job controlling
   kill:
   nohup: run a command, ignoring hangup
    signals
   nice, renice:
   top: display top CPU processes
Daemons
How to Find Help?
   “man” command
   “info”
   command --help
   HOWTO Documentation
   Refer to Internet
The man command
   With the man command you can read the manual
    page of commands
   Manual pages are stored in /usr/man
   The manual page consists of:
       Name: The name of the command and a online description
       Synopsis: The syntax of the command
       Description: Explanation of how the command works and
        what it does
       Files: The files used by the command
       Bugs: Known bugs and errors
       See also: Other commands related to this one
The man command (cont’d)
   The “-k” option
         man –k print
   Manual pages are divided in 8 sections:
     1.   User commands
     2.   System calls
     3.   Libc calls
     4.   Devices
     5.   File formats and protocols
     6.   Games
     7.   Conventions, macro packages and so forth
     8.   System administation
   To select correct section, add section number:
         man 1 passwd, man 5 passwd
The info command
   A program for reading documentation,
    sometimes a replacement for manual pages
   Information for info is stored in /usr/info
   Some info commands:
       space: next screen of text
       delete: previous screen of text
       n: next node
       p: previous node
       u: up node
       q: quit info
       <tab>: skip to next menu item
Review
   What we have learned?
   What you should do yourself?
   Next class…
Homework
   浏览网站:
       http://www.gnu.org
       http://www.linux.org
       www.linuxsir.com
       http://www-
        900.ibm.com/developerWorks/cn/linux/index.shtml
   安装一种 Linux 发行版本
   学习 Linux 命令的使用
   复习 C 程序设计语言
基本命令 (1)
   文件操作
       列出目录内容 : ls, dir, vdir
       创建特殊文件 : mkdir, mknod, mkfifo
       文件操作 : cp, mv, rm
       修改文件属性 : chmod, chown, chgrp, touch
       查找文件 : locate, find
       字符串匹配 : grep(egrep)
       其它 : pwd, cd, ar, file, grep, tar, more, less, head,
        tail, cat
基本命令 (2)
   进程操作
       ps, kill, jobs, fg, bg, nice
   其它
       who, whoami, passwd, su, uname, …
       man
管道和重定向
   重定向
       stdin, stdout, stderr
       > 和 >>
   管道
       例子 :
         ls | wc –l
         ar t /usr/lib/libc.a | grep printf | pr -4 -t
环境变量
   环境变量
       操作环境的参数
       查看和设置环境变量
   例 : PATH 环境变量
        echo $PATH
        /usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/song/bin
        PATH=$PATH:.
        export PATH
编程工具
   编辑工具
       vi, emacs
   编译、链接
       gcc
   调试
       gdb
   make 命令
   版本控制工具
       CVS 等

More Related Content

What's hot

Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating SystemMahakKasliwal
 
Unix operating system architecture with file structure
Unix operating system architecture with file structure Unix operating system architecture with file structure
Unix operating system architecture with file structure amol_chavan
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file systemNikhil Anurag VN
 
Unix and shell programming | Unix File System | Unix File Permission | Blocks
Unix and shell programming | Unix File System | Unix File Permission | BlocksUnix and shell programming | Unix File System | Unix File Permission | Blocks
Unix and shell programming | Unix File System | Unix File Permission | BlocksLOKESH KUMAR
 
Unit 1-a-brief-history-of-unix-ppt
Unit 1-a-brief-history-of-unix-pptUnit 1-a-brief-history-of-unix-ppt
Unit 1-a-brief-history-of-unix-pptRahul Mashal
 
Unix operating system
Unix operating systemUnix operating system
Unix operating systemmidhunjose4u
 
LINUX Admin Quick Reference
LINUX Admin Quick ReferenceLINUX Admin Quick Reference
LINUX Admin Quick Referencewensheng wei
 
A beginners introduction to unix
A beginners introduction to unixA beginners introduction to unix
A beginners introduction to unixzafarali1981
 
unix training | unix training videos | unix course unix online training
unix training |  unix training videos |  unix course  unix online training unix training |  unix training videos |  unix course  unix online training
unix training | unix training videos | unix course unix online training Nancy Thomas
 
Operating systems unix
Operating systems   unixOperating systems   unix
Operating systems unixAchu dhan
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating SystemShivam Pandey
 
Linux fundamentals Training
Linux fundamentals TrainingLinux fundamentals Training
Linux fundamentals TrainingLove Steven
 
Unix OS & Commands
Unix OS & CommandsUnix OS & Commands
Unix OS & CommandsMohit Belwal
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux Harish R
 

What's hot (20)

Unix ppt
Unix pptUnix ppt
Unix ppt
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
 
Unix operating system architecture with file structure
Unix operating system architecture with file structure Unix operating system architecture with file structure
Unix operating system architecture with file structure
 
Introduction to UNIX
Introduction to UNIXIntroduction to UNIX
Introduction to UNIX
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file system
 
Chapter 1: Introduction to Unix / Linux Kernel
Chapter 1: Introduction to Unix / Linux KernelChapter 1: Introduction to Unix / Linux Kernel
Chapter 1: Introduction to Unix / Linux Kernel
 
Unix and shell programming | Unix File System | Unix File Permission | Blocks
Unix and shell programming | Unix File System | Unix File Permission | BlocksUnix and shell programming | Unix File System | Unix File Permission | Blocks
Unix and shell programming | Unix File System | Unix File Permission | Blocks
 
Unit 1-a-brief-history-of-unix-ppt
Unit 1-a-brief-history-of-unix-pptUnit 1-a-brief-history-of-unix-ppt
Unit 1-a-brief-history-of-unix-ppt
 
Unix operating system
Unix operating systemUnix operating system
Unix operating system
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Unix - An Introduction
Unix - An IntroductionUnix - An Introduction
Unix - An Introduction
 
LINUX Admin Quick Reference
LINUX Admin Quick ReferenceLINUX Admin Quick Reference
LINUX Admin Quick Reference
 
A beginners introduction to unix
A beginners introduction to unixA beginners introduction to unix
A beginners introduction to unix
 
Linux: Basics OF Linux
Linux: Basics OF LinuxLinux: Basics OF Linux
Linux: Basics OF Linux
 
unix training | unix training videos | unix course unix online training
unix training |  unix training videos |  unix course  unix online training unix training |  unix training videos |  unix course  unix online training
unix training | unix training videos | unix course unix online training
 
Operating systems unix
Operating systems   unixOperating systems   unix
Operating systems unix
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
 
Linux fundamentals Training
Linux fundamentals TrainingLinux fundamentals Training
Linux fundamentals Training
 
Unix OS & Commands
Unix OS & CommandsUnix OS & Commands
Unix OS & Commands
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 

Viewers also liked

intro unix/linux 10
intro unix/linux 10intro unix/linux 10
intro unix/linux 10duquoi
 
Linux installation and booting process
Linux installation and booting processLinux installation and booting process
Linux installation and booting processSiddharth Jain
 
intro unix/linux 04
intro unix/linux 04intro unix/linux 04
intro unix/linux 04duquoi
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBshimosawa
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)shimosawa
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedureDhaval Kaneria
 
Linux booting Process
Linux booting ProcessLinux booting Process
Linux booting ProcessGaurav Sharma
 
Techbuddy: Introduction to Linux session
Techbuddy: Introduction to Linux sessionTechbuddy: Introduction to Linux session
Techbuddy: Introduction to Linux sessionAshish Bhatia
 
UNIX and Linux - an introduction by Mathias Homann
UNIX and Linux - an introduction by Mathias HomannUNIX and Linux - an introduction by Mathias Homann
UNIX and Linux - an introduction by Mathias HomannMathias Homann
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linuxanandvaidya
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt onu9
 

Viewers also liked (15)

intro unix/linux 10
intro unix/linux 10intro unix/linux 10
intro unix/linux 10
 
Linux boot process
Linux boot processLinux boot process
Linux boot process
 
Linux installation and booting process
Linux installation and booting processLinux installation and booting process
Linux installation and booting process
 
intro unix/linux 04
intro unix/linux 04intro unix/linux 04
intro unix/linux 04
 
Linux booting process
Linux booting processLinux booting process
Linux booting process
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Unix Administration 2
Unix Administration 2Unix Administration 2
Unix Administration 2
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
Linux booting Process
Linux booting ProcessLinux booting Process
Linux booting Process
 
Linux Booting Steps
Linux Booting StepsLinux Booting Steps
Linux Booting Steps
 
Techbuddy: Introduction to Linux session
Techbuddy: Introduction to Linux sessionTechbuddy: Introduction to Linux session
Techbuddy: Introduction to Linux session
 
UNIX and Linux - an introduction by Mathias Homann
UNIX and Linux - an introduction by Mathias HomannUNIX and Linux - an introduction by Mathias Homann
UNIX and Linux - an introduction by Mathias Homann
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
 

Similar to Ch1 linux basics

Introduction to Operating Systems.pptx
Introduction to Operating Systems.pptxIntroduction to Operating Systems.pptx
Introduction to Operating Systems.pptxMohamedSaied877003
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemSadia Bashir
 
Linux Getting Started
Linux Getting StartedLinux Getting Started
Linux Getting StartedAngus Li
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System AdministrationSreenatha Reddy K R
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentalsBimal Jain
 
Basics of Linux Commands, Git and Github
Basics of Linux Commands, Git and GithubBasics of Linux Commands, Git and Github
Basics of Linux Commands, Git and GithubDevang Garach
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentalsRaghu nath
 
Unix_commands_theory
Unix_commands_theoryUnix_commands_theory
Unix_commands_theoryNiti Patel
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driverVandana Salve
 
Linux architecture
Linux architectureLinux architecture
Linux architecturemcganesh
 
UNIT II-Programming in Linux
UNIT II-Programming in LinuxUNIT II-Programming in Linux
UNIT II-Programming in LinuxDr.YNM
 

Similar to Ch1 linux basics (20)

Introduction to Operating Systems.pptx
Introduction to Operating Systems.pptxIntroduction to Operating Systems.pptx
Introduction to Operating Systems.pptx
 
Linux introduction (eng)
Linux introduction (eng)Linux introduction (eng)
Linux introduction (eng)
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Linux security
Linux securityLinux security
Linux security
 
Linux 4 you
Linux 4 youLinux 4 you
Linux 4 you
 
Linux Getting Started
Linux Getting StartedLinux Getting Started
Linux Getting Started
 
Device drivers tsp
Device drivers tspDevice drivers tsp
Device drivers tsp
 
Tutorial 2
Tutorial 2Tutorial 2
Tutorial 2
 
Linux filesystemhierarchy
Linux filesystemhierarchyLinux filesystemhierarchy
Linux filesystemhierarchy
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
 
Basics of Linux Commands, Git and Github
Basics of Linux Commands, Git and GithubBasics of Linux Commands, Git and Github
Basics of Linux Commands, Git and Github
 
Linux
Linux Linux
Linux
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
 
Unix_commands_theory
Unix_commands_theoryUnix_commands_theory
Unix_commands_theory
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driver
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
 
3CS LSP UNIT 1-1.pdf
3CS LSP UNIT 1-1.pdf3CS LSP UNIT 1-1.pdf
3CS LSP UNIT 1-1.pdf
 
UNIT II-Programming in Linux
UNIT II-Programming in LinuxUNIT II-Programming in Linux
UNIT II-Programming in Linux
 

Recently uploaded

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

Ch1 linux basics

  • 1. Ch1 Linux Basics Jianjian SONG Software Institute, Nanjing University Sept. 2004
  • 2. Content 1. What is Linux? 2. Linux/UNIX Overview 3. Installation 4. Using the System 5. Linux Programming Prerequisite
  • 3. 1. What is Linux?  A free Unix-type operating system developed under the GNU General Public License.  Open source  Popular  Support most of the platforms available
  • 4. A Short History of UNIX  Multics, AT&T Bell Lab, GE, MIT  1969, UNIX, Ken Thompson, Dennis Ritchie  1973, Rewrite UNIX with C  Berkeley UNIX(BSD UNIX)  1983, System V  Commercial products  SunOS, Solaris, HP-UX, AIX, SCO UNIX  Standards  SVID, IEEE POSIX, X/Open XPG4.2
  • 5. A Short History of Linux(1)
  • 6. A Short History of Linux(2)
  • 7. GNU & Linux  GNU/Linux System GNU software/library  Linux kernel  GNU software/library Linux kernel  Distributions :  Red Hat, Debain, SuSe, Mandrake, Redflag…
  • 8. 2. Linux/UNIX Overview  早期的 UNIX  一个简单的文件系统  一个进程子系统和一个 Shell (命令解释 器)  内核和核外程序
  • 9. 用 用 用 户 户 户 户 Shell 核外程序 高级语言和实用程序 系统调用 进程间通 文件子系统 信 进程 管理 调度程序 内核 子系统 高速缓存 存储管理 块设 字符设备 备 设备驱动程序 硬 件 控 制 硬 件
  • 11. 3. Installation  Distributions :  Redhat  Debian  SuSe  Mandrake  ……  Live CD  KNOPPIX  Using virtual machine  VMware
  • 12. Installing Linux  Boot system from bootable media  All installation programs need to perform essentially the same steps:  Choose language, keyboard type, mouse type  Create partitions  Setup a boot loader  Configure network  Configure user and authentication  Select package groups  Configure X  Install packages  Create boot disk
  • 14. Disk Partitioning  At a minimum, create  /, 750MB (1.5G or more recommended)  Swap, size equal to amount of memory  Recommended: /boot (16MB)  May need/want to create other partitions:  /usr, /usr/local, /var, /tmp, /opt, /home  Default partitioning program under Linux is fdisk  Distributions may add their own partitioning programs
  • 15. Boot loader  A boot loader loads and starts the Linux kernel  Can pass boot parameters to the Linux kernel, such as device information  Can optionally load an Initial Root Disk  Can boot other operating systems as well  Common Boot loaders:  LILO: Linux Loader  GRUB: Grand Unified Boot Loader  Generally configured in /dev/hda, unless other boot loader is used.
  • 16. Boot loader (cont’d)  LILO  Program to set up the MBR  Syntax: lilo [-v] [-v] [-C config-file] [-t]  Configuration file /etc/lilo.conf  Configures MBR according to configuration file  GRUB  Program stored in MBR (first stage) and in /boot/grub (1.5th and second stage)  Understand file system structure; no need to activate a configuration as with LILO  Configuration file /boot/grub/grub.conf  Installed in MBR with grub-install
  • 17. Linux Startup Flow power on  BIOS  Checks memory, loads options from non- volatile memory, checks for boot devices, loads MBR of boot device and executes it BIOS  MBR  Contains a “boot loader” and the partition table boot loader  Traditionally set up by LILO/GRUB  Boot loader Linux kernel  Loads the compressed kernel image into memory  The kernel uncompress itself and starts… init  Init process  Configuration file /etc/inittab  run levels system ready
  • 18. 4. Using the System  Basic Knowledge  Working with Files and Directories  Working with Processes  Linux Documentation
  • 19. Multi-user and Multi-tasking  Linux is a multi-user, multi-tasking operating system  Multiple users can run multiple tasks simultaneously, independent of each other.  Always need to “log in” before using the system  Identify yourself with user name, password  Multiple ways to log in to the system  Console: Directly attached keyboard, mouse, monitor  Serial terminal  Network connection
  • 20. Virtual Terminal  In most Linux distributions, the console emulates a number of virtual terminals  Each virtual terminal can be seen as a separate, directly attached console  Different users can use different virtual terminals  Typical setup:  VT 1-6: text mode logins  VT 7: graphical mode login prompt (if enabled)  Switch between VTs with Alt-Fn (or Ctrl-Alt- Fn if in X)
  • 21. Linux Commands  Everything on a Linux system can be done by typing commands  the GUI (X-Window) is not needed for running a Linux System  In order to type commands in X-Window you need to start a terminal emulator  Command Prompt  Can be configured yourself  $ - “logged in as a regular user”,  # - “logged in as root”
  • 22. Command Syntax  Linux commands have the following fomat: $ command option(s) argument(s)  Examples: $ ls $ ls –l $ ls /dev $ ls –l /dev
  • 23. Some Basic Linux Commands  passwd: Change your password  mkpasswd: Generate a random password  date, cal: Find out today’s date and display a calendar  who, finger: Find out who else is active on the system  clear: Clear the screen  echo: Write a message to your screen  write, wall, talk; mesg  ……
  • 24. Working with Files & Directories  What is a file?  A collection of data;  An object that can be written to, or read from, or both. A file has certain attributes, including access permissions and type. (susv3)  File structure  Generally: byte stream, record sequence, record tree  In Linux: byte stream
  • 25. File Types  regular file  Text or code data; no particular internal structure  character special file  block special file  Special files: represent hardware or logical devices  Found in directory called /dev  fifo  socket  symbolic link  Directory  A table of contents; a list of files in that directory
  • 26. File System  What is File System  操作系统中负责存取和管理文件的部分  A collection of files and certain of their attributes. It provides a name space for file serial numbers referring to those files. (susv3)  File System in Linux:  VFS  EXT2, EXT3, FAT32, …
  • 27. Directory Structure  All Linux directories are contained in one, virtual, “unified file system”.  Physical devices are mounted on mount points  Floppy disks  Hard disk partition  CD-ROM drives  No drive letter like A:, C:, …
  • 28. A Example of Directory Structure
  • 29. Main Directories in Linux Linux File System Standard: http://www.pathname/fhs
  • 30. Basic Commands(1)  Commands used with directories:  pwd: print working directory  cd: change directory  mkdir: make directory  rmdir: remove directory  ls: list the contents of directories  -l, -a, -R, -d options
  • 31. Basic Commands(2)  commands used with files:  touch: update the access and/or modification time of a files  cp: copy files  mv: move and rename files  ln: link files  rm: remove files  cat: concatenate files  more/less: display files page by page  od, strings: display binary files  split: splits files
  • 35. Default File Permissions  The default permission for newly created files and directories are: File: -rw-rw-r-- 644 Directory: drwxrwxr-x 775  Why?  umask: an octal number which contains the bits that are NOT set as permission bits.  Default 002 for normal user, 022 for root.
  • 36. Editing Files  vi  emacs  gedit  …
  • 37. Working with Processes  What is a process?  A process is a task.  进程是一个正在执行的程序实例。由执行程 序、它的当前值、状态信息以及通过操作系 统管理此进程执行情况的资源组成。  An address space with one or more threads executing within that address space, and the required system resources for those threads. (susv3)
  • 38. Working with Processes (cont’d)  A running program is an example of a process  A shell is a process that reads your commands and start the appropriate process.  echo $$
  • 39. Starting and Stopping a Process  All processes are started by other processes  Parent/Child relationship  One exception: init (PID 1) is started by the kernel itself  A tree hierarchy  A process can be terminated because of two reasons:  The process terminates itself when done.  The process is terminated by a signal from another process
  • 40. Basic Commands  ps: report process status  pstree: display a tree of processes  jobs, fg, bg, <ctrl-z>: job controlling  kill:  nohup: run a command, ignoring hangup signals  nice, renice:  top: display top CPU processes
  • 42. How to Find Help?  “man” command  “info”  command --help  HOWTO Documentation  Refer to Internet
  • 43. The man command  With the man command you can read the manual page of commands  Manual pages are stored in /usr/man  The manual page consists of:  Name: The name of the command and a online description  Synopsis: The syntax of the command  Description: Explanation of how the command works and what it does  Files: The files used by the command  Bugs: Known bugs and errors  See also: Other commands related to this one
  • 44. The man command (cont’d)  The “-k” option  man –k print  Manual pages are divided in 8 sections: 1. User commands 2. System calls 3. Libc calls 4. Devices 5. File formats and protocols 6. Games 7. Conventions, macro packages and so forth 8. System administation  To select correct section, add section number:  man 1 passwd, man 5 passwd
  • 45. The info command  A program for reading documentation, sometimes a replacement for manual pages  Information for info is stored in /usr/info  Some info commands:  space: next screen of text  delete: previous screen of text  n: next node  p: previous node  u: up node  q: quit info  <tab>: skip to next menu item
  • 46. Review  What we have learned?  What you should do yourself?  Next class…
  • 47. Homework  浏览网站:  http://www.gnu.org  http://www.linux.org  www.linuxsir.com  http://www- 900.ibm.com/developerWorks/cn/linux/index.shtml  安装一种 Linux 发行版本  学习 Linux 命令的使用  复习 C 程序设计语言
  • 48. 基本命令 (1)  文件操作  列出目录内容 : ls, dir, vdir  创建特殊文件 : mkdir, mknod, mkfifo  文件操作 : cp, mv, rm  修改文件属性 : chmod, chown, chgrp, touch  查找文件 : locate, find  字符串匹配 : grep(egrep)  其它 : pwd, cd, ar, file, grep, tar, more, less, head, tail, cat
  • 49. 基本命令 (2)  进程操作  ps, kill, jobs, fg, bg, nice  其它  who, whoami, passwd, su, uname, …  man
  • 50. 管道和重定向  重定向  stdin, stdout, stderr  > 和 >>  管道  例子 : ls | wc –l ar t /usr/lib/libc.a | grep printf | pr -4 -t
  • 51. 环境变量  环境变量  操作环境的参数  查看和设置环境变量  例 : PATH 环境变量 echo $PATH /usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/song/bin PATH=$PATH:. export PATH
  • 52. 编程工具  编辑工具  vi, emacs  编译、链接  gcc  调试  gdb  make 命令  版本控制工具  CVS 等