Download presentation
Presentation is loading. Please wait.
1
TUTORIAL LESSON Linux & Tools
Institute of Parallel and Distributed Systems (iPads) Shanghai Jiao Tong University Rong Chen 2018.9
2
BIRTH of TUTORIAL LESSON
ICS introduces the Computer Systems, then WHO introduces ICS ? A new environment: Linux Many new tools: svn, … ICS Book does not contain them Institute of Parallel and Distributed Systems (iPads), SJTU
3
OUTLINE Pre-requisite Linux Tools
4
Pre-requisite Linux Tools
5
REGISTRATION Institute of Parallel and Distributed Systems (iPads), SJTU
6
TASKS Labs (25%) Exams (70%) Homework (5%) 1: Bits 2: Bomb *
3: Buffer Overflow * 4: Y86 Assembler 5: Y86 Compiler 6: Y86 Processor * Online Test Exams (70%) Middle Final Homework (5%) Institute of Parallel and Distributed Systems (iPads), SJTU
7
HARD RULES Deadline: No Extension Plagiarism: No Tolerance
Multiple submissions Plagiarism: No Tolerance Forbid C&P from Network from Classmates Punishment 0 point for ALL Institute of Parallel and Distributed Systems (iPads), SJTU
8
Cheating will not be tolerated
… All homework, labs and exams are to be done individually. It is your responsibility to ensure that your passwords are well-guarded, directories protected, and printouts do not fall into other hands. Institute of Parallel and Distributed Systems (iPads), SJTU
9
STATISTICS 2012 2013 Semester 1: 35 Semester 2: 12 Semester 1: 17
Cheating: 29 Register: 2 Submission: 4 Semester 2: 12 Cheating: 4 Submission: 8 2013 Semester 1: 17 Cheating: 4 Register: 7 Submission: 6 Semester 2: 11 Cheating: 8 Submission: 3 Institute of Parallel and Distributed Systems (iPads), SJTU
10
STATISTICS 2014 Semester 1: 21 Semester 2: 17 Cheating: 19 Register: 0
Submission: 2 Semester 2: 17 Cheating: 10 Submission: 7 Institute of Parallel and Distributed Systems (iPads), SJTU
11
WARNING … 不过我的本意并没有提供代码让他抄袭的啊。他有一个binfile 的函数怎么调试都不对,我确实把这段代码发给了他,但我教会了他怎么做的了。… …, 她请教我怎么优化,我跟她讲了优化方法然后她自己去改了,改过以后问我为什么效率没有提升, 我就叫她让我看下她的代码,发现没有实质性的优化,我嫌讲不清就叫她参考我的代码, … … 我们都是“好学生”,在同学之间会很难拒绝。这次之后就没有这种情况发生了。… …, 知道了,只是实在不会写唉,没学c这个指针真的看不太懂额。这次错了,下次一定不会这么做了。不过能不能请老师不要把 XX判为0分 … … XXX没有错,有错的是将他的代码直接交上去的人,他们根本就没考虑一下这可能对XXX造成什么影响。… (From YY BBS) Institute of Parallel and Distributed Systems (iPads), SJTU
12
Pre-requisite Linux Tools
Introduction Installation Shell Pre-requisite Linux Tools
13
BACKGROUND Keep It Simple, Stupid ! The History of Linux
Linus Torvalds, 1991 Unix-like Operating Systems “ Unix is not so much an operating system as an oral history ” Heirs: Linux, BSD, Solaris, MacOS X, … Principle: KISS Keep It Simple, Stupid ! Institute of Parallel and Distributed Systems (iPads), SJTU
14
COMPARISON Differences between Windows and Linux
One Kernel and Multiple Distribution 3.2.x kernel (newest: ) RedHat / Fedora, Debian Suse, Gentoo, Arch, Ubuntu, … Powerful Command Line Interface Directories Organization … Institute of Parallel and Distributed Systems (iPads), SJTU
16
Pre-requisite Linux Tools
Introduction Installation Shell Pre-requisite Linux Tools
17
INSTALL Step 0: How to find it ?
Tips: about version Fedora Sulphur(9), Cambridge(10) Debian (Toy Story) Squeeze (6.0), Wheezy(7.0), Jessie(8.0) INSTALL Step 0: How to find it ? SJTU Depository ftp://ftp.sjtu.edu.cn/ e.g. Debian /debian-cd/9.4.0/amd64/iso-dvd/ Online: get the official web-site by google e.g. Debian (/'dɛbiːjən/, Debra + Ian) Institute of Parallel and Distributed Systems (iPads), SJTU
18
INSTALL Step 1: Where to install it ? Cygwin on RAW machine
Tips: virtual machine Definition provides a complete system platform which supports the execution of a complete operating system Java Runtime Environment INSTALL Step 1: Where to install it ? Cygwin Sorry, no technical support on RAW machine Cool ! on VIRTUAL machine Safety! Dangerous ! Recommendation ! Institute of Parallel and Distributed Systems (iPads), SJTU
19
INSTALL Step 2: Create VM Select a Guest Operating System (if no ISO)
Tips: VMware Workstation Benefit hosted, popular, graphic easy, stable, checkpointed INSTALL Step 2: Create VM Select a Guest Operating System (if no ISO) e.g. Debian 9 Set name and location Disk capacity 20G (engross on demand) Network connection (customized) Bridge (separate IP) or NAT (internal IP, default) Done ! Institute of Parallel and Distributed Systems (iPads), SJTU
20
INSTALL Step 3: Configure VM Let’s go ! Insert ISO image
“VM -> Settings -> CD-ROM : Use ISO Image” ISO Image: “debian amd64-DVD-1.iso” Configure Hardware (Customized) Memory Size #CPU / #Core Ethnet Mode Power On Let’s go ! Institute of Parallel and Distributed Systems (iPads), SJTU
22
INSTALL Step 4: Install Debian Select a language and your location
Tips: VMware Workstation Switch Ctrl + Alt INSTALL Step 4: Install Debian Select a language and your location Select a keyboard layout U.S. English Configure the network Hostname and Domain name Set root password and Create a User Configure the clock Time Zone Institute of Parallel and Distributed Systems (iPads), SJTU
23
INSTALL Step 4: Install Debian Partition disks Partitioning Manual
Tips: hard Disk in Linux Naming: sd[x][y] sda 1 - the 1st section of 1st HD sdb3 - the 2nd section of 3rd HD * sd: SCSI disk / hd: IDE disk INSTALL Step 4: Install Debian Partition disks Manual Partitioning 1. _ swap M (equal to memory size) sda2 2. / ext fill to maximum allowable size sda1
24
INSTALL Step 4: Install Debian Configure package manager
Tips: Desktop Environment GNOME /gə'noʊm/ from GNU Project KDE /'keidiː‘iː/ from Qt Software as you like INSTALL Step 4: Install Debian Configure package manager Use a Network mirror Hostname: ftp://ftp.sjtu.edu.cn Mirror directory: /debian/ Software selection Graphical desktop environment Standard System Utilities … Institute of Parallel and Distributed Systems (iPads), SJTU
25
INSTALL Step 4: Install Debian Welcome to Debian 9 !
Install GRUB boot loader Waiting … Reboot … OK Welcome to Debian 9 ! Institute of Parallel and Distributed Systems (iPads), SJTU
28
APPENDIX: System Virtualization
Architecture VM VM Unmodified User Software Unmodified User Software VM VM Unmodified User Software Unmodified User Software Operating System Operating System Operating System Operating System Virtual Machine Monitor Host Operating System Virtual Machine Monitor Hardware (CPU, Memory, Disk, Ethernet) Hardware (CPU, Memory, Disk, Ethernet) Non-hosted Hosted Institute of Parallel and Distributed Systems (iPads), SJTU
29
APPENDIX: System Virtualization
Virtual Machine Monitor VMware (EMC) Player, Workstation, … Fusion, VMware Server, ESX Server, … Other s Hyper-V (Virtual PC) xVM (VirtualBox) KVM, Xen … Institute of Parallel and Distributed Systems (iPads), SJTU
30
APPENDIX: VMware Workstation
Snapshot (unsupported in VMware Player) Backup the whole computer Don’t worry about system crash Trade of between storage and computers Files in VMware Workstation Configuration (.vmx) BIOS (.nvram) Paging file (.vmem) Disk (.vmdk) Snapshot (.vmsn ) … Institute of Parallel and Distributed Systems (iPads), SJTU
31
APPENDIX: VMware Workstation
Configuration Network >setup select ‘network configuration’ >ping ftp.sjtu.edu.cn Install VMware Tools Institute of Parallel and Distributed Systems (iPads), SJTU
32
Pre-requisite Linux Tools
Introduction Installation Shell Pre-requisite Linux Tools Institute of Parallel and Distributed System (iPads), SJTU
33
SHELL Operating System Shell
Provide access to the services of a kernel Command-Line Interface (CLI) Unix Shell e.g. Bounce-Again Shell, bash Non-Unix Shell e.g. DOS Graphical User Interface (GUI) Windows, X Window (KDE, GNOME, Xfce), Mac OS Institute of Parallel and Distributed Systems (iPads), SJTU
35
Commands MOST IMPORTANT Search Path: /bin, /usr/bin, ...
Command is case sensitive man – display the on-line manual pages e.g. >man man whatis – search the whatis database for complete words e.g. >whatis passwd Institute of Parallel and Distributed Systems (iPads), SJTU
36
Commands File and Directory ls - list files/dirs e.g. >ls -l
mkdir – create a dir e.g. >mkdir test cd - change dir e.g. >cd test rm - remove files/dirs e.g. >rm -f a.txt cp - copy files/dirs e.g. >cp a.txt b.txt mv – move files/dir s e.g. >mv a.txt c.txt pwd – show current path e.g. >pwd du – estimate files/dirs space usage e.g. >du -c -h test df – report free disk space e.g. >df Institute of Parallel and Distributed Systems (iPads), SJTU
37
Commands File and Directory
chmod – change mode of file/dir e.g. >chmod 777 test chown – change owner of file/dir e.g. >chown rong edit chgrp – change group of file/dir e.g. >chgrp guest draft -R $ ls -l drwxr--r-- 1 peter admin Mar drafts -rw-r--r-- 1 peter admin Mar edition-32 -r-xr-xr-x 1 terry admin Mar edit duuugggooo C owner group size date name C:(hard link count) Institute of Parallel and Distributed Systems (iPads), SJTU
38
Commands Search whereis - locate special files for a command (binary, src and manual file) e.g. >whereis cp find – search for files/dirs in a dir hierarchy e.g. >find . –name “c.txt” locate – locate files/dirs by name in system based on a database e.g. >locate test grep – text search utility e.g. >grep “abc” . -R Institute of Parallel and Distributed Systems (iPads), SJTU
39
Commands User Account useradd – create a new user e.g. >useradd rong userdel – delete a user account e.g. >userdel rong passwd – set password for a user account based on a database e.g. >passwd rong users – print name of user currently logged e.g. >users Institute of Parallel and Distributed Systems (iPads), SJTU
40
Commands Text cat – concatenate and print files e.g. >cat b.txt
head – output the first part of files e.g. >head –n 4 b.txt tail – output the last part of files e.g. >tail –c 50 b.txt wc – print the number of newlines, words, and bytes in files e.g. >wc b.txt cut – remove sections from each line of files e.g. >cut –c 4-10 b.txt Institute of Parallel and Distributed Systems (iPads), SJTU
41
Commands Misc echo – display a line of text e.g. >echo $PATH
mount – mount a file system e.g. >mount /dev/sda3 /mnt umount – unmount a file system e.g. >umount /mnt ping – send ICMP ECHO_REQUEST to network hosts e.g. >ping date – print or set the system date and time e.g. >date "+%m/%d/%y“ time – time a simple command e.g. >time locate mapreduce Institute of Parallel and Distributed Systems (iPads), SJTU
42
Commands Misc ; – join two command in one line e.g. >echo $PATH; whereis echo < > >> – redirect input and output e.g. >cat b.txt >> c.txt | – pipe the former output as the later input e.g. >cat b.txt | grep “abc” & – do command in new process e.g. >cat b.txt & Institute of Parallel and Distributed Systems (iPads), SJTU
43
Pre-requisite Linux Tools
Software Installer Compressing and Archiving Remote Login Text Editor
44
VERSION CONTROL APT (Advanced Package Tools)
A management system for software packages Package resource list for APT: /etc/apt/sources.list $ cat /etc/apt/source.list ... deb squeeze main dbe-src squeeze main type URI of source dist comp URI type: http, ftp, cdrom, file, ssh ... Institute of Parallel and Distributed Systems (iPads), SJTU
45
VERSION CONTROL APT (Advanced Package Tools)
apt-get: command-line tool update e.g. >apt-get update install e.g. >apt-get install htop remove e.g. >apt-get remove htop upgrade e.g. >apt-get upgrade htop apt-cache: cache manipulator search e.g. >apt-cache search htop showpkg e.g. >apt-cache showpkg htop Institute of Parallel and Distributed Systems (iPads), SJTU
46
VERSION CONTROL APT (Advanced Package Tools) example: install vim
>su root user >apt-get update update apt list >apt-cache search vim search in cache >apt-get install vim install vim >man vim manual of vim $ apt-cache search vim ... vim – Vi IMproved – enhanced vi editor vim-doc - Vi IMproved – HTML documentation Institute of Parallel and Distributed Systems (iPads), SJTU
47
Pre-requisite Linux Tools C Language Lab Software Installer
Compressing and Archiving Remote Login Text Editor
48
COMPRESSING GZIP (Gnu ZIP) gzip file format Compress just single file
Replace the original file with .gz file e.g. >gzip test.txt >gunzio test.txt.gz Institute of Parallel and Distributed Systems (iPads), SJTU
49
ARCHIVING TAR (Tape ARchive) tar file format Suffix:
.tar e.g. >tar -cf src.tar src/ .tgz/.tar.gz e.g. >tar -zxf src.tar.gz .tbz/.tar.bz2 e.g. >tar -jcf src.tbz src/ Institute of Parallel and Distributed Systems (iPads), SJTU
50
Pre-requisite Linux Tools C Language Lab Software Installer
Compressing and Archiving Remote Login Text Editor
51
REMOTE LOGIN SSH (Secure SHell) A Replacement for Telnet
Communication through a secure channel Tatu Ylönen, 1995 OpenSSH (OpenBSD Secure Shell), 1999 e.g. >ssh -l root SCP, A Replacement for FTP e.g. >scp b.txt >scp ./ Institute of Parallel and Distributed Systems (iPads), SJTU
52
REMOTE LOGIN Remote Login from Windows Command-Line Interface
PuTTY act as a client for SSH and Telnet Developed by Microsoft Graphical User Interface VNC (Virtual Network Client) Platform Independent Client-Sever Model Institute of Parallel and Distributed Systems (iPads), SJTU
53
Pre-requisite Linux Tools C Language Lab Software Installer
Compressing and Archiving Remote Login Text Editor
54
TEXT EDITOR vi (Visual Editor) /'viː'ai/, not /'siks/
Extension: vim, vile, xvi, … Simple and Convenient BOOK: “learning the vi editor” Cheat Sheet (Chinese version) “>vimtutor” to get a simple tutorial Institute of Parallel and Distributed Systems (iPads), SJTU
55
TEXT EDITOR Emacs (Editing MACroS) /'imæks/ More powerful than IDE !
Emacs List BOOK: “Learning GNU Emacs” Institute of Parallel and Distributed Systems (iPads), SJTU
56
Thanks
57
Tutorial-1 Tasks Install Linux
Shell Institute of Parallel and Distributed Systems (iPads), SJTU
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.