1. Trang chủ
  2. » Công Nghệ Thông Tin

bài giảng lập trình mã nguồn mở - ts. lê nhật duy

191 676 1
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Lập Trình Mã Nguồn Mở - TS. Lê Nhật Duy
Chuyên ngành Lập Trình Mã Nguồn Mở
Thể loại bài giảng
Định dạng
Số trang 191
Dung lượng 2,09 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

What is Linux ? Linux is an Unix-like operating system  Linux is an free and open source software  Linux is a leading server operating system  Multi-user, security, stability, … 3 

Trang 1

LẬP TRÌNH MÃ NGUỒN MỞ

TS Lê Nhật Duy

Blog: https://Lnduy.wordpress.com

Email: Ln.duy@mail.ru

Trang 2

Nội dung chương trình

Trang 3

Nội dung chương trình

Trang 4

Kiểm tra đánh giá

 Kiểm tra giữa kỳ

 Tiểu luận theo nhóm

 Thi kết thúc môn

 Kiểm tra giữa kỳ

 Tiểu luận theo nhóm

 Thi kết thúc môn

Trang 5

Giáo trình và TLTK

Neil Matthew, Richard Stones, “Beginning LinuxProgramming”, 4th Edition, Wiley Publishing,Inc, 2008

Slides bài giảng của giảng viên

Neil Matthew, Richard Stones, “Beginning LinuxProgramming”, 4th Edition, Wiley Publishing,Inc, 2008

Slides bài giảng của giảng viên

5

Trang 6

 …

Trang 7

Essential Linux

Trang 8

4. Using Linux Text Editor

1. Introduction Linux and Linux Distributions

2. Installing Linux

3. Getting Help (using man pages, info and other

documentation resources)

4. Using Linux Text Editor

Trang 9

What is Linux ?

 Linux is an Unix-like operating system

 Linux is an free and open source software

 Linux is a leading server operating system

 Multi-user, security, stability, …

3

 Linux is an Unix-like operating system

 Linux is an free and open source software

 Linux is a leading server operating system

 Multi-user, security, stability, …

Trang 10

What is Linux ?

 Linux is an operating system,

provides key functions in a computer system:

 Linux is an operating system,

provides key functions in a computer system:

Trang 11

The History of Linux

5

Trang 12

The History of Linux

Richard Matthew Stallman (born March 16, 1953), is an

American software freedom activist and computer program

 Is a student at Harvard University

 a programmer at the MIT Artificial Intelligence Laboratory

 In September 1983, he launched the GNU Project to create a free Unix-like operating system

 With the launch of the GNU Project, he initiated the free software movement In October 1985, he founded the Free Software Foundation, and in 1989 he wrote the GNU General Public License (GNU GPL)

Richard Matthew Stallman (born March 16, 1953), is an

American software freedom activist and computer program

 Is a student at Harvard University

 a programmer at the MIT Artificial Intelligence Laboratory

 In September 1983, he launched the GNU Project to create a free Unix-like operating system

 With the launch of the GNU Project, he initiated the free software movement In October 1985, he founded the Free Software Foundation, and in 1989 he wrote the GNU General Public License (GNU GPL)

Trang 13

The History of Linux

 By the early 1990s, many of the programs required in the

GNU project’s operating system (such as libraries,

compilers, text editors, a Unix shell, and a windowing system) were completed, although low-level elements

such as device drivers, daemons, and the kernel were stalled and incomplete.

In 1991, in Helsinki, Linus Torvalds began a project that

later became the Linux kernel

 Development was done on MINIX using the GNU C compiler

7

 By the early 1990s, many of the programs required in the

GNU project’s operating system (such as libraries,

compilers, text editors, a Unix shell, and a windowing system) were completed, although low-level elements

such as device drivers, daemons, and the kernel were stalled and incomplete.

In 1991, in Helsinki, Linus Torvalds began a project that

later became the Linux kernel

 Development was done on MINIX using the GNU C compiler

Trang 14

The History of Linux

 The first release of the Linux kernel, Linux 0.01, included

a binary of GNU's Bash shell

 In 1992, he suggested releasing the kernel under the GNU General Public License.

 He first announced this decision in the release notes of version 0.12.

 In the middle of December 1992 he published version 0.99 using the GNU GPL

Linux and GNU developers worked to integrate GNU components with Linux to make a fully-functional and free operating system.

 The first release of the Linux kernel, Linux 0.01, included

a binary of GNU's Bash shell

 In 1992, he suggested releasing the kernel under the GNU General Public License.

 He first announced this decision in the release notes of version 0.12.

 In the middle of December 1992 he published version 0.99 using the GNU GPL

Linux and GNU developers worked to integrate GNU components with Linux to make a fully-functional and free operating system.

Trang 15

Linux Distributions

distribution or distro for short ) is a member of thefamily of Unix-like operating systems

built on top of the Linux kernel

 consist a set of libraries and utilities from the GNU

project

9

distribution or distro for short ) is a member of thefamily of Unix-like operating systems

built on top of the Linux kernel

 consist a set of libraries and utilities from the GNU

project

Trang 16

platform- Designed for servers, desktops, or embedded devices;

 General purpose or highly specialized toward specific machine functionalities (e.g firewalls, network routers, and computer clusters);

 Built primarily for security, usability, portability, or comprehensiveness.

 Linux distributions have taken a wide variety of forms

platform- Designed for servers, desktops, or embedded devices;

 General purpose or highly specialized toward specific machine functionalities (e.g firewalls, network routers, and computer clusters);

 Built primarily for security, usability, portability, or comprehensiveness.

Trang 17

Linux Distributions …

 Today there are hundreds of different

distributions available popular

 Today there are hundreds of different

distributions available popular

Trang 18

Linux Distributions …

Trang 19

Roles of Linux

 Desktop operating system

 Server operating system

 Firewall

13

 Desktop operating system

 Server operating system

 Firewall

Trang 21

User Interface

Linux Graphical User Interface

 The Linux GUI is composed of the following components:

 X Window System

 The X Window System provides the base system for the graphical interface on Linux It allows programmers to run applications in windows It also allows users to move windows around on the screen as well as click on items with the mouse.

 Window manager

 The role of the window manager is to control the appearance of the windows

on the screen It also determines how they are arranged on the screen.

 Window manager

 The role of the window manager is to control the appearance of the windows

on the screen It also determines how they are arranged on the screen.

Trang 22

User Interface

Linux Command-Line Interface (CLI)

 The Linux command line interface is created by shells

The bash shell is the default shell for most distributions

A shell is a command interpreter that allows you to type

commands from the keyboard to interact with the operating system kernel.

 The Linux command line interface is created by shells

The bash shell is the default shell for most distributions

A shell is a command interpreter that allows you to type

commands from the keyboard to interact with the operating system kernel.

Trang 23

Getting Help

Trang 25

Using Linux Text Editors

Trang 27

 Two reasons to learn text manipulation tools

 Configuration information is stored in a variety of text

files, in the /etc directory

 Using a text editor to edit these files to customize the system.

$ vi /etc/inittab

21

 Two reasons to learn text manipulation tools

 Configuration information is stored in a variety of text

files, in the /etc directory

 Using a text editor to edit these files to customize the system.

$ vi /etc/inittab

Trang 28

Using the vi Editor

 Two versions of vi

vi

vim (Vi IMproved)

 Replacing vi version on the most newer Linux distributions

 Program file locate in /bin

 When execute the vi program, /usr/bin/vi file called

 This is a symbolic link file, points to the /bin/vim executable file

 Two versions of vi

vi

vim (Vi IMproved)

 Replacing vi version on the most newer Linux distributions

 Program file locate in /bin

 When execute the vi program, /usr/bin/vi file called

 This is a symbolic link file, points to the /bin/vim executable file

Trang 29

press ESC and press :

 Escape current mode

press ESC

23

press ESC and press :

 Escape current mode

press ESC

After starting Vi

Press ESC + :

Press ESC + <insert>

Press Insert Press :

Trang 30

Commands in Command mode

w and ENTER

Writes the current file

w filename and ENTER

Writes the current file to a different file name

exit and ENTER

Writes the current file and then closes vi Or press wq

q Closes vi without saving the current file This can only

be used if the file hasn’t been changed If the file has been changed, then you must enter q!

w and ENTER

Writes the current file

w filename and ENTER

Writes the current file to a different file name

exit and ENTER

Writes the current file and then closes vi Or press wq

q Closes vi without saving the current file This can only

be used if the file hasn’t been changed If the file has been changed, then you must enter q!

Trang 31

Using the Emacs Editor

• Emacs is a more powerful

text-based editor

• It can use either keyboard

commands or a menu-driven

interface that can be

manipulated with your

mouse.

• You will need to install the

Emacs package on your

Linux system before you can

use the program.

interface that can be

manipulated with your

mouse.

• You will need to install the

Emacs package on your

Linux system before you can

use the program.

Trang 32

Use Graphical Text Editors

conditions are true:

■ The system is working properly.

■ The system has X Windows, a window manager, and a desktop installed.

■ Your X Window System has been configured properly to work with your hardware

 Some of graphic editors are :

 Kate

 X emacs

 gedit

conditions are true:

■ The system is working properly.

■ The system has X Windows, a window manager, and a desktop installed.

■ Your X Window System has been configured properly to work with your hardware

 Some of graphic editors are :

 Kate

 X emacs

 gedit

Trang 33

Linux File System

Trang 34

The Hierarchical Structure of the Linux File System

Trang 35

/ - The root directory The starting point of your directory

structure Every other file and directory on your system is under the root

directory.

/bin - contains shells (bash) and file system management

utilities

/etc - keep linux text-based configuration files

/boot - keep important linux booting files

/dev - keep all device files

/usr - keep all user binary and X library

/home - keep user home directory

/proc - is pseudo file system for tracking running process and state

of linux system

The Hierarchical Structure of the Linux

File System

29

/ - The root directory The starting point of your directory

structure Every other file and directory on your system is under the root

directory.

/bin - contains shells (bash) and file system management

utilities

/etc - keep linux text-based configuration files

/boot - keep important linux booting files

/dev - keep all device files

/usr - keep all user binary and X library

/home - keep user home directory

/proc - is pseudo file system for tracking running process and state

of linux system

Trang 36

/var - keeping variable data, log file and

printer spooling

/lib - contain shared library that is

required by system program

/root - the root user’s home directory

/sbin - contains important system management and

admin files (fdisk, fsck, ifconfig, init, mkfs, shutdown, halt)

/media - system use to mount externel devices

(CD/DVD , floppy drives) (or /mnt)

The Hierarchical Structure of the Linux File System

/var - keeping variable data, log file and

printer spooling

/lib - contain shared library that is

required by system program

/root - the root user’s home directory

/sbin - contains important system management and

admin files (fdisk, fsck, ifconfig, init, mkfs, shutdown, halt)

/media - system use to mount externel devices

(CD/DVD , floppy drives) (or /mnt)

Trang 37

Navigating the File System

 Path

 absolute path

 Current directory & relative path

 Current directory (.) and parent directory ( )

Home directory ( ~ )

31

 Path

 absolute path

 Current directory & relative path

 Current directory (.) and parent directory ( )

Home directory ( ~ )

Trang 38

Path /

home etc usr bin boot dev lib root …

a b c /home/a/hoso absolute path

Hoso Vd.txt

Vd1.txt

relative path

hoso a/hoso

If current directory

/home/a /home

Trang 39

Current directory and Relative path

 pwd (Present Working Directory)

 Display the current directory

 pwd (Present Working Directory)

 Display the current directory

Trang 40

Introduction to Linux

Programming

Trang 41

6 Low-Level File Access

7 The Standard I/O Library

8 Formatted Input & Output, File & Directories

9 The /proc File System

1 The GNU Project and the Free Software Foundation

4 Terminals

5 Library Functions

6 Low-Level File Access

7 The Standard I/O Library

8 Formatted Input & Output, File & Directories

9 The /proc File System

2

Trang 42

GNU/Linux

Trang 43

GNU - GPL

 Tác giả vẫn giữ bản quyền đối với với phần mềm gốc.

 Người sử dụng có quyền :

 Tự do chạy chương trình, cho bất cứ mục đích nào.

 Tự do tái phân phối bản sao.

 Tự do tìm hiểu cách hoạt động của chương trình, tự do sửa đổi

nó và phát hành những gì sửa đổi ra công cộng.

 Người sử dụng có thể thay đổi một phần của chương trình và phân phối thay đổi của mình cùng toàn bộ phần mềm cho người khác, với điều kiện nói rõ phần mình thay đổi.

 Phải đảm bảo cung cấp mã nguồn khi bán một sản phẩm theo GNU GPL để người khác có thể sử dụng và/hoặc bán tiếp Người dùng kế tiếp có đầy đủ quyền lợi như của người trước.

4

 Tác giả vẫn giữ bản quyền đối với với phần mềm gốc.

 Người sử dụng có quyền :

 Tự do chạy chương trình, cho bất cứ mục đích nào.

 Tự do tái phân phối bản sao.

 Tự do tìm hiểu cách hoạt động của chương trình, tự do sửa đổi

nó và phát hành những gì sửa đổi ra công cộng.

 Người sử dụng có thể thay đổi một phần của chương trình và phân phối thay đổi của mình cùng toàn bộ phần mềm cho người khác, với điều kiện nói rõ phần mình thay đổi.

 Phải đảm bảo cung cấp mã nguồn khi bán một sản phẩm theo GNU GPL để người khác có thể sử dụng và/hoặc bán tiếp Người dùng kế tiếp có đầy đủ quyền lợi như của người trước.

Trang 44

Programming Linux

 List of programming languages available to the Linux

programmer:

Trang 45

Linux Programs

 Linux applications are represented by two special

Executable files are programs that can be rundirectly by the computer; they correspond to

Windows exe files Scripts are collections of

instructions for another program, an interpreter, to

follow These correspond to Windows bat or cmd files, or interpreted BASIC programs.

 Linux applications are represented by two special

Executable files are programs that can be rundirectly by the computer; they correspond to

Windows exe files Scripts are collections of

instructions for another program, an interpreter, to

follow These correspond to Windows bat or cmd files, or interpreted BASIC programs.

6

Trang 46

The First Linux C Program

Trang 47

8

Trang 48

Compile the program and test it

Trang 49

Libraries (cont.)

create the archive and add your object files to it.The program is called ar because it createsarchives, or collections, of individual files placedtogether in one large file Note that we can alsouse ar to create archives of files of any type

$ ar crv libfoo.a bill.o fred.o

a - bill.o

a - fred.o

create the archive and add your object files to it.The program is called ar because it createsarchives, or collections, of individual files placedtogether in one large file Note that we can alsouse ar to create archives of files of any type

$ ar crv libfoo.a bill.o fred.o

a - bill.o

a - fred.o

10

Ngày đăng: 03/04/2014, 11:29

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w