introduction to linux ( i )

20
Introduction to Introduction to Linux ( Linux ( I I ) ) Sidney Fong Sidney Fong 4 4 th th Feb 2006 Feb 2006

Upload: samson

Post on 19-Mar-2016

40 views

Category:

Documents


0 download

DESCRIPTION

Introduction to Linux ( I ). Sidney Fong 4 th Feb 2006. Rough Outline. Prerequisites: Knowledge of basic Computer / Operating System concepts No previous knowledge of Linux No previous knowledge of Windows or any other systems Training is divided into Two Parts: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to Linux ( I )

Introduction to Linux (Introduction to Linux (II))Sidney FongSidney Fong44thth Feb 2006 Feb 2006

Page 2: Introduction to Linux ( I )

Rough OutlineRough Outline Prerequisites:Prerequisites:

Knowledge of basic Computer / Operating System Knowledge of basic Computer / Operating System conceptsconcepts

NoNo previous knowledge of Linux previous knowledge of Linux NoNo previous knowledge of Windows or any other previous knowledge of Windows or any other

systemssystems Training is divided into Two Parts:Training is divided into Two Parts:

Part I - Introduction of the background of LinuxPart I - Introduction of the background of Linux Part II – Practical Session Part II – Practical Session

Page 3: Introduction to Linux ( I )

Introduction to Linux (Introduction to Linux (II))Part I – Some Background of Part I – Some Background of

LinuxLinux

Page 4: Introduction to Linux ( I )

What is “Linux”?What is “Linux”?

Operating system?Operating system? … … What is an operating system?What is an operating system?

Page 5: Introduction to Linux ( I )

What is an “Operating System”?What is an “Operating System”? Wikipedia: Wikipedia: “the system software responsible for t“the system software responsible for t

he direct control and management of hardware ahe direct control and management of hardware and basic system operations”nd basic system operations”..

The kernel?The kernel? The basic interface (eg. command line, graphical The basic interface (eg. command line, graphical

interface)?interface)? The commands? The tools?The commands? The tools? Text editors? Compilers?Text editors? Compilers? Web Browser?Web Browser? … … Everything?Everything?

Page 6: Introduction to Linux ( I )

Operating System (cont’d)Operating System (cont’d)

In general, there is one narrow usage and In general, there is one narrow usage and a broader usagea broader usage

Narrow usage: Only the parts that deal dirNarrow usage: Only the parts that deal directly with the hardware, and very low level ectly with the hardware, and very low level features (i.e. the kernel)features (i.e. the kernel)

Broader usage: Also includes system softBroader usage: Also includes system software. What is “system software” depends ware. What is “system software” depends on the nature of the system.bon the nature of the system.b

Page 7: Introduction to Linux ( I )

Graphical IllustrationGraphical Illustration

User space programs

Shell

Kernel

Hardware

X Client

Daemons

X Server

Page 8: Introduction to Linux ( I )

What is Linux?What is Linux?

There are also two usages of the term There are also two usages of the term “Linux”, corresponding roughly to the “Linux”, corresponding roughly to the narrow/broad usage of the term “Operating narrow/broad usage of the term “Operating System”.System”.

The narrow definition: simply the kernelThe narrow definition: simply the kernel The broader definition: includes basically The broader definition: includes basically

everything available in the systemeverything available in the system

Page 9: Introduction to Linux ( I )

A Typical Linux SystemA Typical Linux System Linux KernelLinux Kernel User space programs (many are GNU software)User space programs (many are GNU software)

Shell (command line): bashShell (command line): bash Utilities: ls, cp, mv, rm, cat, grep, ...Utilities: ls, cp, mv, rm, cat, grep, ... Compiler: gccCompiler: gcc … … and more …and more …

X Window System (for desktops/workstations)X Window System (for desktops/workstations) Various daemons (a.k.a. services)Various daemons (a.k.a. services)

Eg.: syslogd, httpd, cron, inetdEg.: syslogd, httpd, cron, inetd

Page 10: Introduction to Linux ( I )

A bit of HistoryA bit of History Richard Stallman founded Richard Stallman founded

the GNU project in the 19the GNU project in the 1980’s80’s

Linus Torvalds began writLinus Torvalds began writing a kernel in the early 1ing a kernel in the early 1990’s990’s

=> GNU/Linux, commonly => GNU/Linux, commonly referred to as “Linux”.referred to as “Linux”.

(For more details, see for (For more details, see for yourself on the web)yourself on the web)

Page 11: Introduction to Linux ( I )

Open Source / FreeOpen Source / Free Open Source – Source code is available to Open Source – Source code is available to

everybodyeverybody ““Free” – Source code is available to everyFree” – Source code is available to every

body, and everybody can re-distribute the body, and everybody can re-distribute the source codesource code

““Copyleft” – Source code is available to evCopyleft” – Source code is available to everybody, and if you want to distribute the perybody, and if you want to distribute the program, you must also distribute the sourcrogram, you must also distribute the source code.e code.

Page 12: Introduction to Linux ( I )

Linux DistributionsLinux Distributions Once upon a time, there were softwaresOnce upon a time, there were softwares The softwares were scattered in different sites, and they The softwares were scattered in different sites, and they

were distributed by source codewere distributed by source code If people wanted to use them, they have to download theIf people wanted to use them, they have to download the

m from different sites, compile them, and install themm from different sites, compile them, and install them See how many packages you have in your system! (dpkSee how many packages you have in your system! (dpk

g -l)g -l) Also, consider the difficulty of installing software onto a nAlso, consider the difficulty of installing software onto a n

ew computer (with no operating system pre-installed)ew computer (with no operating system pre-installed) Conclusion: Installation of software is a very complicated Conclusion: Installation of software is a very complicated

process.process. (Refer to the LFS “Distribution” if you want to get a feel o(Refer to the LFS “Distribution” if you want to get a feel o

f this)f this)

Page 13: Introduction to Linux ( I )

Linux Distributions (cont’d)Linux Distributions (cont’d) In the beginning, people did In the beginning, people did

those complicated and tedious those complicated and tedious work themselves.work themselves.

Later, some of them released Later, some of them released their work of collecting the their work of collecting the software to the public. These software to the public. These are called “distributions”.are called “distributions”.

Typically, a modern distribution Typically, a modern distribution handles the following:handles the following: Installation of the OSInstallation of the OS Software Packaging (compiled Software Packaging (compiled

software instead of source)software instead of source) Install / Upgrade / Removing Install / Upgrade / Removing

packagespackages Sensible default configurationsSensible default configurations

You may have heard of these You may have heard of these names:names: Redhat / FedoraRedhat / Fedora MandrakeMandrake DebianDebian SlackwareSlackware GentooGentoo

Page 14: Introduction to Linux ( I )

Characteristics of Linux SystemsCharacteristics of Linux Systems

Heavy emphasis of command lineHeavy emphasis of command line Many command line utilities for scripting Many command line utilities for scripting

purposespurposes CustomizableCustomizable

Page 15: Introduction to Linux ( I )

Introduction to Linux (Introduction to Linux (II))Part II - PracticalPart II - Practical

Page 16: Introduction to Linux ( I )

Before Starting…Before Starting… Remember that Linux is a completely different system Remember that Linux is a completely different system

from Windows. You may find that everything is different from Windows. You may find that everything is different from what you are used to. Do not be frustrated. You from what you are used to. Do not be frustrated. You may not yet be able to do everything you can in may not yet be able to do everything you can in Windows, but after some time, you will be able to grasp Windows, but after some time, you will be able to grasp the basics and feel more comfortable in using Linuxthe basics and feel more comfortable in using Linux

Also, forget all your “cool” Windows skills, and forget Also, forget all your “cool” Windows skills, and forget how you do things in Windows… the Linux way is quite how you do things in Windows… the Linux way is quite different, especially if we focus on the CLI.different, especially if we focus on the CLI.

Page 17: Introduction to Linux ( I )

Login ScreenLogin Screen

“Message of the day”

Usually contains important notices

Username Hostname Current directoryHint: You may press

<Ctrl+Alt+F1> to <Ctrl+Alt+F6>for multiple terminals if you are

using Linux on the local machine(instead of over network)

Why is the username and hostname displayed in the command prompt?

Page 18: Introduction to Linux ( I )

Getting HelpGetting Help

man pagesman pages

Purpose of commandDifferent

usages

Detailed description of command and

its options

Hint:

Press ‘q’ to quit

Page 19: Introduction to Linux ( I )

More on Man PagesMore on Man Pages There are different sections oThere are different sections o

f man pagesf man pages Section 1: commandsSection 1: commands Section 2: system callsSection 2: system calls Section 3: C library callsSection 3: C library calls Section 4: special files (in /dev)Section 4: special files (in /dev) Section 5: (config) file formatsSection 5: (config) file formats Section 6: “games”Section 6: “games” Section 7: MiscSection 7: Misc Section 8: System administratioSection 8: System administratio

n commandsn commands

If there are conflicts in nIf there are conflicts in names, the section of lowames, the section of lower value is displayed. For er value is displayed. For a specific section:a specific section: man <section> <page>man <section> <page>

Note that you may find sNote that you may find section 3 very useful as a ection 3 very useful as a reference to standard C freference to standard C functions (eg. printf, fopeunctions (eg. printf, fopen, string functions, etc)n, string functions, etc)

Page 20: Introduction to Linux ( I )

Useful Commands in CompetitionsUseful Commands in Competitions bc – Arbitrary precision calculatorbc – Arbitrary precision calculator sort – Sort lines of text files (note the “-n” option)sort – Sort lines of text files (note the “-n” option) ps – list running processes on the machineps – list running processes on the machine kill – Sends a signal to running programs (terminates it by default)kill – Sends a signal to running programs (terminates it by default) date – Print system date/timedate – Print system date/time time – reports execution time of a commandtime – reports execution time of a command diff – compares filesdiff – compares files head, tail – prints the first/last N lines of the inputhead, tail – prints the first/last N lines of the input wc – word count (also counts characters and lines)wc – word count (also counts characters and lines) more – pager (allows you to scroll the input for easy viewing)more – pager (allows you to scroll the input for easy viewing) less – better version of moreless – better version of more grep – print lines matching a patterngrep – print lines matching a pattern find – search for filesfind – search for files factor – factorize numbersfactor – factorize numbers tsort – perform topological sorttsort – perform topological sort seq – print a sequence of numbersseq – print a sequence of numbers file – determine file type (sometimes displays other useful information)file – determine file type (sometimes displays other useful information) tar – Archive files (“glue” multiple files into one, and vice versa)tar – Archive files (“glue” multiple files into one, and vice versa)