BI296: Linux and Shell Programming -...
Transcript of BI296: Linux and Shell Programming -...
![Page 1: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/1.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
BI296: Linux and Shell Programming
Maoying,[email protected]
Dept. of Bioinformatics & BiostatisticsShanghai Jiao Tong University
Spring, 2018
![Page 2: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/2.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Course OverviewI Course Description: Linux command line, system
administration and bash/python programmingI Prerequisite: NoneI Textbook: NoneI Grading: Grades will be determined roughly by
I Assignments: 20%I 5 Quizzes: 25% totalI 2 Take-home Practicals: 30%I Projects: 25%
I Exams: There will be 5 quizzes, 2 bring-homepracticals. All exams will be open-book, and willcover materials from lectures, discussions, labs andextracurricular readings.
I Webpage:http://cbb.sjtu.edu.cn/course/bi296
I Github:https://github.com/ricket-sjtu/bi028
![Page 3: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/3.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Course ScheduleSchedule is to be changed according to the practicalreasons.
I Lecture 01: Fundamental Knowledge about LinuxI Lecture 02: Dummy Linux CommandsI Lecture 03: Linux File System,Process
ManagementI Lecture 04: Regular Expression - GREP, SED and
AWKI Lecture 05: Shell Programming (BASH)I Lecture 06: System AdministrationI Lecture 07: Fundamental Python ProgrammingI Lecture 08: Data Structures and Algorithms in
PythonI Lecture 09: Scientific computing with PythonI Lecture 10: Python Data Science
![Page 4: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/4.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Assignment Policy
I To: [email protected] Title: lab1 516080910001I Attachment: lab1 5160809010001.tar.gzI Late Policy
I Solutions to assignments should be submitted beforethe due.
I Being late within 3 days will get the 50% grades.I Later more than 3 days will get no grades.
![Page 5: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/5.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
![Page 6: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/6.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Stop here and Ask
Any Questions?
![Page 7: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/7.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
fundamental concepts
I Central Processing Unit(CPU,中央处理器)I Graphical Processing Unit (GPU,图形处理器)I Cache(高速缓存)I Storage(存储):bit, Byte, KB, MB, GB, TB, PB,
EB, ZBI Input/Output(输入输出)I Controller(控制器)
![Page 8: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/8.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Number system
I Decimal(十进制)I Binary(二进制)I Octal(八进制)I Hexadecimal(十六进制)
![Page 9: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/9.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Exercise
decimal binary octal hexadecimal12.68
10011107553
9FA5
![Page 10: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/10.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Machine digit(机器数的二进制表示)
I Original(原码)I One’s complement(反码)I Two’s complement(补码)
![Page 11: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/11.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Exercise
1. Convert these positive decimal to binary:I 133dI 25dI 73d
2. Convert these negative decimal values to negativebinary using one’s complement and two’scomplement(补码,假设计算机字长为8bit):
I -192dI -16dI -1dI -0d
![Page 12: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/12.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Network
I Host(主机), Domain(域)I IP Adress, IPv4, IPv6I Physical Address (MAC Address)I Gateway(网关), netmask(子网掩码)I Domain Name Server(DNS,域名服务器)I Network Communication Protocol (网络通信协议)
![Page 13: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/13.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Next we will talk about ...
Course Outline
Fundamental Computer Science
Introduction to LinuxOperating System (OS)Why Linux?Linux vs. Windows vs. MacOSBasic KnowledgeLinux Commands
![Page 14: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/14.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
The Definition of Operating System (OS)WikipediaAn OS is a collection of software that manages computerresources (CPUs, memory, storage, etc.) and providesuniversal services for a set of computer programs.
Figure : Operating System
![Page 15: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/15.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
The principal tasks of OS
I Processor (CPU) Management(处理器管理)I Memory (Storage) Management(内存/存储管理)I Devices Management(其他设备管理)I Application Management(应用程序管理)I User Interface (UI)(提供用户接口)
![Page 16: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/16.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Next we will talk about ...
Course Outline
Fundamental Computer Science
Introduction to LinuxOperating System (OS)Why Linux?Linux vs. Windows vs. MacOSBasic KnowledgeLinux Commands
![Page 17: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/17.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
![Page 18: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/18.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
What is Linux?
A free and open-source UNIX-like operating systemdeveloped under the GNU General Public License (GPL).
I Free and open source(自由、开源).I More and more popular(时髦), especially in the
field of scientific computing.I Portable(可移植): Supports most of the available
computers
![Page 19: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/19.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
A Short History of UNIX
I Prototype: Multics by AT&T Bell Lab, GE and MITI 1969, UNIX by Ken Thompson and Dennis RitchieI 1973 UNIX rewritten with C (providing portability)I Berkeley UNIX (BSD UNIX)I 1983, System VI Commercial Products: SunOS, Solaris, HP-UX, AIX,
SCO-UNIX
![Page 20: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/20.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Advantages of UNIX
I Unix is very simpleI Implements only hundreds of system calls(系统调用)and
I have a straightforward, even basic design.I In UNIX, everything is a file, which unifies the
manipulation of data and devices into a set of coresystem calls.
I Kernels(内核)and all related system utilities arewritten in C and ASM
I Fast process creation and unique fork() system call.I Providing simple yet robust IPC(进程通信)primitives.
I Exhibiting clean layering, with a strong separationbetween policy (what to do) and mechanism (how todo).
![Page 21: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/21.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
A Short History of Linux (1)
I 1984, Richard Stallman, GNU ProjectI GNU’s Not Unix:http://www.gnu.orgI Copyleft
I Purpose: Free UNIXI Free as free speech, not free lunch.
I 1st step: re-implementation of UNIX utilities,especially
I C Compiler, C libraryI emacs/bash
I Free Software Foundation (FSF)I http://www.fsf.org
![Page 22: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/22.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
A Short History of Linux (2)
I 1991, Linus Torvalds, 1st version of Linux KernelI Initially on the 386 protected modeI Linus’s UNIX-Like OS = Linux
I 1992: 1st distributions emergedI Linux KernelI GNU and other toolsI Installation procedure
I The rest is well-known story ...I RedHat, Ubuntu, Debian, OpenSuSe, etc.
![Page 23: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/23.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
A Typical Computer System Architecture
![Page 24: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/24.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Programmer’s Viewpoint
![Page 25: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/25.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Next we will talk about ...
Course Outline
Fundamental Computer Science
Introduction to LinuxOperating System (OS)Why Linux?Linux vs. Windows vs. MacOSBasic KnowledgeLinux Commands
![Page 26: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/26.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Linux, Windows, MacOS
![Page 27: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/27.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Next we will talk about ...
Course Outline
Fundamental Computer Science
Introduction to LinuxOperating System (OS)Why Linux?Linux vs. Windows vs. MacOSBasic KnowledgeLinux Commands
![Page 28: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/28.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
M2: Multi-User and Multi-tasking
I Linux is a multi-user, multi-tasking OSI Multiple users can run multiple tasks simultaneously,
independent of each other.I Always need to “log in” before using the system
I Identify yourself with username + passwordI Ways to log in to the system
I Console: Directly attached keyboard, mouse, monitorI Serial terminalI Network connection (ssh, telnet, etc.)
![Page 29: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/29.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Next we will talk about ...
Course Outline
Fundamental Computer Science
Introduction to LinuxOperating System (OS)Why Linux?Linux vs. Windows vs. MacOSBasic KnowledgeLinux Commands
![Page 30: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/30.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Linux Commands
I Many things on a Linux system can be done bytyping commands
I Note that the GUI (X-window) is not needed forrunning a Linux system.
I In order to type commands in X-window you need tostart a terminal emulator
I Command PromptI Can be configure yourself, the default isI $ - “logged in as a regular user”I # - “logged in as root (privileged user)”
![Page 31: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/31.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Start Linux
Now start Linux and log in as administrator“root”; and then open a terminal on yourdesktop. See, what’s your commandprompt?
![Page 32: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/32.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Command Syntax
Syntax format<command> [option(s)] [argument(s)]
Examples
# list files and directories in currentdirectory
ls# list files and directories lengthilyls -l# list files and directories in /devls /devls -al /dev
![Page 33: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/33.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Some Useful Commands
I passwd: Change your passwordI mkpasswd: Generate a random passwordI date, cal: Find out today’s date and display a
calendarI who, finger: Find out who else is active on the
systemI clear: Clear the screenI echo: Write a message to your screenI write, wall, talk, mesg: Inter-user
communicationI ...
![Page 34: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/34.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
who, what, where, where to go
I pwd: Print Working DirectoryI uname: Print the system informationI whoami: Who am II cd: Change working Directory
![Page 35: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/35.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
pwd: knowing where you are now
I Synopsis: pwdI All the path names are started with a slash (“/”), for
exampleI “/root” is the home directory for rootI “/home/xxx” is the home directory for user “xxx”I Use command “which pwd” can show you where
your command locatesI Most of the user commands are stored in /bin or
/usr/binI Commands for super user are in the directories /sbin
and /usr/sbin
![Page 36: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/36.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
uname: knowing what my system is
I Synopsis: uname option(s)
I uname -a: --all
I uname -i: --hardware-platform
I uname -m: --machine
I uname -n: --node-name
I uname -o: --operation-system
I uname -r: --kernel-release
I uname -s: --kernel-name
I uname -v: --kernel-version
I uname -p: --processor
I You can use uname --help to obtain moreinformation for this command.
I This command is very useful in compiling thesystem-dependent code.
![Page 37: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/37.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
whoami: knowing who you are
I Synopsis: whoamiI The command is different from “who am i”I and also “who”I Now guess what the command “who” can do for you?
![Page 38: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/38.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
cd: change directory to
I Synopsis: cd dir name
I Command “cd” without any argument will direct youto your home directory
I Command “cd ∼xxx” can direct you to the homedirectory of user “xxx”
I You can use either absolute pathname to visit thedirectory, e.g. “cd /tmp” or
I You can also use relative pathname to visit therelevant directory.
I If you are root, you can visit anywhere; but if you area normal user, maybe you will be forbidden to visitsomewhere, for example “/root”.
![Page 39: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/39.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
How to get help for a command
I “man” commandI for example “man ls” can return the manual for the
command “ls”I manpage is stored in the directory/usr/share/man/
I “info”I command --help or command -h
I HOWTO DocumentationI Refer to Internet
![Page 40: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/40.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
The man command (1)
I With the man command you can get the manualpage of commands
I Manual pages are stored in /usr/man or/usr/share/man
I The manual page consists of:I NAME: The name of the command and a online
descriptionI SYNOPSIS: The syntax of the commandI DESCRIPTION: Explanation of how the command
works and what it doesI Files: The files used by the commandI Bugs: Known bugs and errorsI See Also: Other relevant commands
![Page 41: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/41.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
The man command (2)
I The “-k” optionI man -k print
I Manual pages are divided into 8 sections:1. User commands2. System calls3. Libc calls4. Devices5. File formats and protocols6. Games7. Conventions, macro packages and so forth8. System administration
I To select the correct section, add section number:I man 1 passwdI man 5 passwd
![Page 42: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/42.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Working with Files and Directories
What is a file?I A collection of dataI An object that can be read from, or written to, or both.I All the objects in Linux are filesI A file has certain attributes include
I File typeI Access permissions
File StructureI Generally: byte stream, record sequence, record treeI In Linux: byte stream
![Page 43: BI296: Linux and Shell Programming - cbb.sjtu.edu.cncbb.sjtu.edu.cn/course/bi296/lecture/lec01.pdf · BI296 Maoying Wu Outline CS-Fundamentals Linux Overview Operating System (OS)](https://reader031.fdocuments.in/reader031/viewer/2022020303/5b02a3277f8b9a84338fee22/html5/thumbnails/43.jpg)
BI296
Maoying Wu
Outline
CS-Fundamentals
Linux OverviewOperating System (OS)
Why Linux?
Linux vs. Windows vs.MacOS
Basic Knowledge
Linux Commands
Directory Structure
I Linux File System Standard:http://www.pathname/fhs