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

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

101 279 1

Đ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

Định dạng
Số trang 101
Dung lượng 5,2 MB

Nội dung

• GNU: General Public License • FS: File System • CLI: Command Line Interface • LILO: Linux Loader • GRUB: Grand Unified Bootloader Supplementary Slide... File System – Permission Examp

Trang 1

Linux Fundamental

(For ICT)

By : ICT/BA

Trang 2

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

Trang 3

Basic Administration

Basic commands Install/uninstall software Enable/disable services

Trang 4

• GNU: General Public License

• FS: File System

• CLI: Command Line Interface

• LILO: Linux Loader

• GRUB: Grand Unified Bootloader

Supplementary Slide

Trang 5

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 Linus Torvalds in 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

Refer to References number 1 for Unix history

What is linux?

Unix-like system

Linux was initially developed by Linus Torvalds in 1991

Linux family: refer to References number 5 detail of Linux distributions

Trang 6

Basic Concepts

Trang 7

Basic Concepts

Kernel:

Central component of most computer operating systems (OS)

Manage system's resources and communication between hardware and software components.

Shell: interface for users access to services of a kernel.

Graphical (GUI) shell

Central component of most computer operating systems (OS)

Manage system's resources and communication between hardware and software components.

Shell: interface for users access to services of a kernel.

Graphical (GUI) shell

Trang 9

Boot sequence

BIOS

Master Boot Record (MBR)

Boot loader: lilo or grub

• load kernel (image=), or

• load partition boot sector (other=) (dual boot)

Master Boot Record (MBR)

Boot loader: lilo or grub

• load kernel (image=), or

• load partition boot sector (other=) (dual boot)

Trang 10

System state

System state

0 - Shutdown

1 – Single User Mode

2 – Basic Multi-user Mode

3 – Full Multi-user without X

1 – Single User Mode

3 – Full Multi-user without X

5 – Mutli-user with X

6 – Reboot

Trang 11

File System

Trang 12

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:

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

Trang 13

File System – File Permission

Character 1 is the type of file:

Trang 14

File System – File type

Trang 15

File System – Permission Example

Type "ls -l" and a listing like the following is displayed:

total 10

-rw-rw-rw- 1 george team1 1873 Aug 23 08:34 test

-rw-rw-rw- 1 george team1 1234 Sep 12 11:13 datafile

Which means the following:

Type and # of Files's File's Size in Date of last Filename

Permission field Files Owner Group Bytes modification

drwxrwxrwx 4 george team1 122 Dec 12 18:02 Projects

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

Type "ls -l" and a listing like the following is displayed:

total 10

drwxrwxrwx 4 george team1 122 Dec 12 18:02 Projects

-rw-rw-rw- 1 george team1 1873 Aug 23 08:34 test

-rw-rw-rw- 1 george team1 1234 Sep 12 11:13 datafile

Which means the following:

Type and # of Files's File's Size in Date of last Filename

Permission field Files Owner Group Bytes modification

drwxrwxrwx 4 george team1 122 Dec 12 18:02 Projects

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

Trang 16

File System (cont.)

/etc: contains all system related configuration files in here or in 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 system and 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 or in 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 system and run the commands.

.a: static library

.so: shared library

Trang 17

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

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

Trang 18

Getting StartedSection 2: Basic Administration

Trang 19

Login - Putty

Trang 20

Login – Tera term

Trang 21

Shell Basic

Trang 22

Shell types

Commonly used shells

command line editing

Commonly used shells

command line editing

Trang 23

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 | grep http

Trang 24

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

Trang 25

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

Trang 27

Install/uninstall software

Redhat/Fedora:

[root@localhost soft]# rpm -ivh mysql-5.0.27-1.fc6.i386.rpm

warning: mysql-5.0.27-1.fc6.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2

all packages) (default: all) [?,??,q]: all

Redhat/Fedora:

[root@localhost soft]# rpm -ivh mysql-5.0.27-1.fc6.i386.rpm

warning: mysql-5.0.27-1.fc6.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2

all packages) (default: all) [?,??,q]: all

Trang 28

Install/uninstall software (cont.)

Compile and Installing from source:

Download source code of package (*.tgz, *.bz2)

Unzip

Read README, INSTALL file or related file to know how to

install/uninstall this driver

Notes: you should have a basic knowledge about gcc (compile options), make file, debug and check tool (dump, ldd …)

Auto install/update

Fedora: yum

Debian: apt-get

Note: require get through GCS’s proxy automatically: ntlmap

Compile and Installing from source:

Download source code of package (*.tgz, *.bz2)

Unzip

Read README, INSTALL file or related file to know how to

install/uninstall this driver

Notes: you should have a basic knowledge about gcc (compile options), make file, debug and check tool (dump, ldd …)

Trang 29

Network service and LAMP

Trang 30

GCS Network Information

C:\Documents and Settings\annt>ipconfig /all

Windows IP Configuration

Host Name : annguyen0647

Primary Dns Suffix : cybersoft.vn

Node Type : Hybrid

IP Routing Enabled : No

WINS Proxy Enabled : No

DNS Suffix Search List : cybersoft.vn

cybersoft.vn Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix : cybersoft.vn

Description : Intel(R) PRO/1000 PL Network Connection

Lease Obtained : Wednesday, August 06, 2008 4:26:33 PM

Lease Expires : Thursday, August 14, 2008 4:26:33 PM

Trang 32

GCS Network Information

Proxy server: find proxy server in ISA client

Ex: GBOProxy.cybersoft.vn

SMTP server: for setup sendmail

Ex: phanthiet cybersoft.vn

Trang 33

Check network configuration

Show ip address

# ifconfig -a

eth0 Link encap:Ethernet HWaddr 00:18:F3:82:12:D8

inet addr:172.21.204.200 Bcast:172.21.255.255 Mask:255.255.0.0

inet6 addr: fe80::218:f3ff:fe82:12d8/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Show route

# netstat -rn

Routing Table: IPv4

Destination Gateway Flags Ref Use Interface

Trang 35

DHCP - Dynamic Host Configuration Protocol

DHCP: Automatically assign an IP address other related configuration information such as the subnet mask and default gateway, DNS servers, WINS servers

Trang 36

DHCP

Trang 37

Telnet – RFC 854

Telnet (default port 23) is a standard application that almost every TCP/IP implementation provides It works between hosts that use different operating systems.

Trang 38

Telnet – Detect network service

Example of use telnet to detect mail server

# telnet 172.20.0.4 25

Trying 172.20.0.4

Connected to 172.20.0.4.

Escape character is '^]'.

220 PHANTHIET.cybersoft.vn Microsoft ESMTP MAIL Service, Version:

6.0.3790.3959 ready at Mon, 11 Aug 2008 16:16:08 +0700

Trang 39

FTP – File Transfer Protocol

Trang 40

FTP – File Transfer Protocol

Example

C:\Documents and Settings\annt>ftp 172.21.204.133

Connected to 172.21.204.133

220 dnpperl0955.cybersoft.vn FTP server ready

User (172.21.204.133:(none)): annt

331 Password required for annt

Trang 41

Samba is essentially a TCP/IP file and print server for Microsoft Windows clients

Configure a samba share folder

1 Share Linux directory

writable = yesprintable = nobrowseable = yes

2 Set password for samba user

# smbpasswd –a luc

Trang 42

Enable accessing Windows folder from Linux

Syntax: request root privilege to execute

• Mount folder

smbmount win_dir linux_dir [-o options]

• Unmount samba folder

smbumount linux_dir

Options: not allow space between these below options

• rw: read/write mode

• ro: read only mode

• username: user name to log in to Windows computer

• password: password to log in to Windows computerExample

• Mount samba folder

# smbmount //172.16.5.26/Share /home/luc/share -o ro,username=administrator,password=gcsvn123

• Unmount samba folder

Trang 43

NFS – Network File System

NFS allows users to access files across a network and treat them as if they resided in a local file directory.

Trang 44

Refer to sendmail howto document

Trang 45

• -e: edit user's crontab

• -l: list user's crontab

• -r: delete user's crontab Crontab files path: /var/spool/cron/crontabs /

Crontab file format

Trang 46

Example

Use df command to check disk space with the below schedule

1 export EDITOR=vi ;to specify a editor to open crontab file

2 $ crontab –e

3 Input the above content into crontab file

4 Save the file

5 View crontab content

$ crontab -l Output memory information to mem.txt after each minute

1 $ crontab -e

• * * * * * free >> mem.txt

Trang 47

Cron and problem with time zone

1 The times in cron are local times This means, that if you configure cron to start some program at

7 in the morning, it is 7 in the morning local time as determined by the system Timezone

This causes headaches, if the system Timezone is not the same you have set for yourself using the TZ enviroment variable, or you have two host in different Timezones that need to start

someting at the same time on both hosts

=> solution synchronize system time zone and environment time zone

2 How to check and reconfig system timezone

- Show local date: $date

Mon Dec 3 23:03:54 EST 2007

EST stand for Eastern Standard Time

- Check time zone information: /usr/share/zoneinfo/ or $tzselect

- Check system time zone: $cat /etc/timezone

- Check environment time zone: $env | grep TZ

- Change system time zone: $tzconfig

- Synchronize environment time zone to system time zone: add this scrip into /etc/profile

Trang 48

'NTLM Authorization Proxy Server' (APS) is a proxy software

that allows you to authenticate via an MS Proxy Server (e.g ISA server) using the proprietary NTLM protocol

Refer to NTML howto

Trang 49

Compiling and Installing

Server Side Includes (SSI)

Authentication, Authorization and Access Control

Trang 50

Apache – Stop/start

Check Apache version:

[root@dnpasa ~]# httpd -V

Server version: Apache/2.2.3

Server built: Sep 11 2006 09:43:05

Server's Module Magic Number: 20051115:3

To start/stop Apache HTTP Server:

Trang 51

Start mysql/stop

# /etc/init.d/mysql start/stop

Check error log

# tail /var/adm/messages (Solaris)

# tail /var/log/messages (Linux)

Trang 52

Start/stop Oracle

Login as oracle user

Check env variables: ORACLE_HOME and ORACLE_SID

Start oracle instance:

sqlplus /nolog sqlplus>connect sys/<password> as sysdba sqlplus>startup

Shutdown oracle instance

Trang 53

Any Questions?

Trang 56

2 Using sudo to execute command

$ sudo /sbin/service smb restart

Trang 58

Environment variables

Environment variable in Linux is similar to Window

Temporary variable: is a variable which is available to a shell console only

User variable: is a variable which is only available to a user

System variable: is a variable which is available to all users

List of environment variables

Trang 59

Define user variable: define variable in ~/.bash_profile file

instead of shell console When you relogin, your new variable will be updated

Define a system variable: define variable in /etc/profile file You need to have root privilege to modify this file

Trang 60

-R: recursive when granting permissions for directory

Example: change mode for test.txt file

$ chmod 755 test.txt

Change file ownership (require root privilege)

Syntax

chown user[:group] filename/directory [-R]

Example: change owner of test.txt to user1

# chown user1 test.txt

Trang 61

File operation commands

Trang 62

File operation commands

Display current working directory

Syntax

pwd

Make a directory

Syntax

mkdir [option] directory

Example: make sample directory

Trang 63

File operation commands

Copy file or directory

Trang 64

File operation commands

Create a new empty file or modify file timestamp

Trang 65

File operation commands

Page through the contents of a file one screenful at a time

Syntax

less [options] filename

Options

• -c: clear screen before displaying

• -number: number of lines per screen

Key control

• Enter: view one more line

• q: quit to view a file

• b: move back one screen

• f: move forward one screen

• /text: search for text in the remainder of file

Example

$less mem.txt

Ngày đăng: 28/05/2014, 08:12

TỪ KHÓA LIÊN QUAN

w