PowerPoint 演示文稿 - Peking University

Download Report

Transcript PowerPoint 演示文稿 - Peking University

Microprocessor Research Center of Peking University Software Research Group

Introduction to Linux

shishu 2005-3-5

© 2004 Microprocessor Research Center of Peking University – All Rights Reserved

What is Linux

• A fully-networked 32/64-Bit Unix-like Operating System – Unix Tools Like sed, awk, and grep (explained later) – Compilers Like C, C++, Fortran, Smalltalk, Ada – Network Tools Like telnet, ftp, ping, traceroute • Multi-user, Multitasking, Multiprocessor • Has the X Windows GUI • Coexists with other Operating Systems • Runs on multiple platforms • Open Source

Tips No. 1 Step by Step

Structures of Linux

• / • /home Start point of file system, root directory Users’ directory • /bin Standard commands and tools • /usr Users’ files • /usr/bin Users’ commands and applications • /usr/sbin Administrator’s applications • /usr/lib Programming libraries • /usr/doc Linux documents • /usr/man Online manual

• /sbin • /var • /dev • /etc • /boot • /dev • /etc

Structures of Linux

Commands necessary for system Temporary files and spool files Devices System configuration files and startup shell scripts -> how to select booting kernels /dev/cdrom /dev/floppy /dev/sd* /dev/hd* /dev/null /dev/zero /etc/fstab /etc/inittab

Basic Operations

What do these commands do?

 shutdown/halt/reboot  w/who/whoami/whereis  ll/ls/ln  sync/mount  df/du/dd  head/tail  talk/write/wall  yes/no?

© 2004 Microprocessor Research Center of Peking University – All Rights Reserved

Tips No.2

Always Keep Security in Mind

Logging In

• Login the System – ssh – telnet – rsh – Using serial port to login (Kermit) • Additional Tips – Login Sequence (what happed while login?) – Customize your own prompt – Forget your password?

***Rule***

• Do not login as root unless you have to • root is the system super user (the “ master ” but more “ dangerous ” ) of Linux – Normal protection mechanisms can be overridden – Careless use can cause damage – Has access to everything by default • root is the only user defined when you install – First thing is to change root ’ s password – The second job is to define “ normal ” users for everyday use

Tips No.3

Documents are very important & helpful

Basic Operations

 Man  What do these arguments mean?

 cd ~ cd –  mkdir -p mkdir -m  rm -i  cp –af / cp –rf  scp/rcp  echo –n  touch echo -e  ctrl + c ctrl + z  shift+insert ctrl + u ctrl+insert

© 2004 Microprocessor Research Center of Peking University – All Rights Reserved

 grep  sed/awk  find  tar/gzip  ftp

Little Tools

© 2004 Microprocessor Research Center of Peking University – All Rights Reserved

Shell Programming

• Exploit what a tool can do • Use simplest tool for hardest job

Tips No.4

Be Open!

Homework

 How to create an empty file without an editor? please give 3 methods.

 What is the difference between the followings?

and explain why.

 ./a.out > filename 2>&1  ./a.out 2>&1 > filename  Source code of a.out is shown at next page  How to get the date of yesterday and tomorrow?

© 2004 Microprocessor Research Center of Peking University – All Rights Reserved

Homework

#include #include main() { char* sin ="stdin\n"; char* sout="stdout\n"; char* serr="stderr\n"; write(0,sin, strlen(sin)); write(1,sout, strlen(sout)); write(2,serr, strlen(serr)); }

© 2004 Microprocessor Research Center of Peking University – All Rights Reserved