Introduction to Linux (Part II) BUPT/QMUL 2018/03/21

Similar documents
Editors in Unix come in two general flavours:

vi filename edit filename starting at line 1

Basic File Attributes

Basic vi Commands. What is vi? To Get Into and Out Of vi

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02

2. First C. Algorithm

Mills HPC Tutorial Series. Linux Basics I

Using the Unix system. UNIX Introduction

CMPT 300. Operating Systems. Brief Intro to UNIX and C

Lab 3a Using the vi editor

Statistics 202A - vi Tutorial

Outline. Structure of a UNIX command

vi Primer Adapted from:

Software I: Utilities and Internals. What is vi?

Problem Set 1: Unix Commands 1

Unix and C Program Development SEEM

Linux/Cygwin Practice Computer Architecture

Basic Unix Commands. CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang

CHE3935. Lecture 1. Introduction to Linux

VIM Tips and Tricks. Search and replace a string in a document : :.,$s/search_string/replacement_string/g

Laboratory 1 Semester 1 11/12

Unix Introduction to UNIX

Practical Session 0 Introduction to Linux

CSCI 211 UNIX Lab. Text Editor - Vi. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

FILE MAINTENANCE COMMANDS

SHELL SCRIPT BASIC. UNIX Programming 2014 Fall by Euiseong Seo

Getting Started. Running Utilities. Shells. Special Characters. Special Characters. Chapter 2 Unix Utilities for non-programmers

UNIX Quick Reference

SHELL SCRIPT BASIC. UNIX Programming 2015 Fall by Euiseong Seo

IBM AIX Basic Operations V5.

CS4350 Unix Programming. Outline

Linux environment. Graphical interface X-window + window manager. Text interface terminal + shell

Introduction to Linux

Std: XI CHAPTER-3 LINUX

Intro. To Unix commands. What are the machines? Very basics

Introduction. SSH Secure Shell Client 1

PASS4TEST IT 인증시험덤프전문사이트

Configuring Ubuntu to Code for the OmniFlash or OmniEP

CS354 gdb Tutorial Written by Chris Feilbach

Introduction to Supercomputing

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Development Environment & Linux Guide

Computer Programming Lecture 3 이윤진서울대학교

Listing Directory Attributes. Bamuengine.com Page 1. BY Prof. P. Katkar, DIEMS, AURANGABAD

CS101 Linux Shell Handout

Using the Vi Text Editor

VI Commands Cheat Sheets

UNIX Commands. Ex: $ pwd $/tmp $cd/home/sales, this will change the directory from /tmp to /home/sales.

Linux Systems Administration Getting Started with Linux

CENG393 Computer Networks Labwork 1

Linux Command Line Primer. By: Scott Marshall

Program Development Tools. Lexical Analyzers. Lexical Analysis Terms. Attributes for Tokens

Compilation, Disassembly, and Profiling (in Linux)

Bok, Jong Soon

Once you have installed MobaXterm, open MobaXterm. Go to Sessions -> New Session, and click on the SSH icon.

Getting Started with Linux Editors. Network Startup Resource Center

Embedded Systems Ch 3A Linux Development Environment

Linux 下代码查看 编辑 编译与调试 (I) 袁华

Week 2 Lecture 3. Unix

The Linux Programming Environment. Computer Science Department Texas State University

CENG 334 Computer Networks. Laboratory I Linux Tutorial

RH033 Red Hat Linux Essentials

Introduction to Linux Environment. Yun-Wen Chen

Programming Tools. Venkatanatha Sarma Y. Lecture delivered by: Assistant Professor MSRSAS-Bangalore

I/O and Shell Scripting

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Intro to Segmentation Fault Handling in Linux. By Khanh Ngo-Duy

We first learn one useful option of gcc. Copy the following C source file to your

Appendix C. Icon and Text Editors

HOW TO USE CODE::BLOCKS IDE FOR COMPUTER PROGRAMMING LABORATORY SESSIONS

Course 144 Supplementary Materials. UNIX Fundamentals

INF322 Operating Systems

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Linux Tutorial. Ken-ichi Nomura. 3 rd Magics Materials Software Workshop. Gaithersburg Marriott Washingtonian Center November 11-13, 2018

Basic Linux Command Line Interface Guide

Getting started with UNIX/Linux for G51PRG and G51CSA

Hand-on Labs for Chapter 1 and Appendix A CSCE 212 Introduction to Computer Architecture, Spring

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

Basic Linux Command Line Interface Guide

VIP Quick Reference Card

Operating Systems, Unix Files and Commands SEEM

CS241 Class Notes rev 2

NETW 110 Lab 3 Post-Installation Configuration Page 1

1. Open VirtualBox and start your linux VM. Boot the machine and log in with the user account you created in Lab #1. Open the Terminal application.

Unix Philosophy, Text Editors, IDEs

Exercise 1: Basic Tools

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

FREEENGINEER.ORG. 1 of 6 11/5/15 8:31 PM. Learn UNIX in 10 minutes. Version 1.3. Preface

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

Source level debugging. October 18, 2016

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

VI (and Clone) Introductory Guide

Introduction to the Emacs Editor

Lecture 4: Build Systems, Tar, Character Strings

Intro to C and Binary Numbers 8/27/2007

Transcription:

Introduction to Linux (Part II) BUPT/QMUL 2018/03/21

Contents 10. vi 11. Other commands 12. Developing tools 2

10. Editor - vi Text editor Insert mode Override mode Use sub-commands Tradition tools and others 3

The vi command vi is a text editor. vi shows you part of your file and allows you to enter commands that change something ( add new stuff, delete a char or line, etc). 4

vi modes vi has a couple of modes: command mode: move the cursor around, move to a different part of the file, issue editing commands, switch to insert mode. The command will not be displayed in screen ENTER is not needed insert mode: whatever you type is put in the file (not interpreted as commands). when you first start vi you will be in command mode. 5

Cursor Movement Commands (only in command mode!) h l j k move left one position move right one position or space bar move down one line move up one line Your arrow keys might work (depends on the version of vi and your terminal) 6

More Cursor Movement Commands $ move to the end of the line G move to the end of the file w b e move forward one word move backward one word move to the end of the word ) move to beginning of next sentence ( move to beginning of current sentence 7

Scrolling Commands CTRL-F scroll forward one screen CTRL-B scroll backward one screen CTRL-D scroll forward 1/2 screen CTRL-U scroll backward 1/2 screen 8

Command that delete stuff x X delete character (the one at the cursor) delete back one character (backspace) dw delete word dd delete line 3x delete 3 characters (any number works) 5dd delete 5 lines (any number works) 9

Changing Text cw change word (end with Esc) cc change line (end with Esc) C change rest of the line rx replace character with 'x' (could be anything, not just 'x') 10

Insert Mode In insert mode whatever you type goes in to the file. There are many ways to get in to insert mode: i insert before current position a append (insert starting after cursor) A append at end of line R begin overwriting text o insert text in a new line below the current line O insert text in a new line above the current line 11

Copy & Paste p P yy ye paste text last copied to the right of the cursor paste text last copied to the left of the cursor copy current line copy from the cursor to the end of the word 12

Ending Insert Mode To get out of insert mode (back to command mode) you press "Esc" (the escape key). There is a status line (bottom of screen) that tells you what mode/command you are in. 13

Saving and Exiting ZZ save if changes were made, and quit. :wq Write file and quit :w Write file :w file Write to file named file :q Quit :q! Really quit (discard edits) 14

Searching and Replacing /text search forward for text?text search backward for text n repeat previous search N repeat search in opposite direction :s/findtext/ replace the first occurrence of findtext :%s/findtext/ replace all occurrences of findtext 15

16

17

netstat arp ping traceroute ftp ps top df w last history 11. Other commands 18

Change File Access Permissions chmod directory change the access permission of reading, writing and executing for file or chmod [who][op][mode] filename chmod [who][op][mode] directory Two manners: symbolic and numerical 19

Change File Access Permissions Symbolic manner who: u-user, g group, O-other, A-all op: + - Adding the access permission defined by [mode] by defined - - Deleting the access permission defined [mode] = - Assigning the access permission by [mode] mode: r-read, w write, x-execute Examples $ chmod a+rx test.txt $ chmod go-rx filename 20

-rw-rw-r-- Chmod a+x test.txt Chmod a=x test.txt 21

Change File Access Permissions Numerical manner Three octal numbers are used to describe the access mode Three numbers for user, group, other Examples: $ chmod 741 test.txt 22

Change File Owner and Group chown change the owner of the file or directory chown username filename chown -R username directory Only the owner and the root user can change the owner of the file 23

Search for a File find find the files in the given directory according to the given expression find pathname [option] expression option -name file name -user user name -group group name -mtime n files modified in n days -newer fn files modified later than fn Examples $ find. -name test $ find. name *abc* 24

Locate a Command whereis locate the binary, source and manual of the given command whereis command Examples $ whereis ls 25

12. Developing tools gcc gdb gprof 26

Compiler for C in Linux gcc pre-process and compile gcc c hello.c hello.o is created link gcc o hello hello.o hello is created Execute (the absolute or relative path is needed)./hello Compile and link can be done in one step gcc o he hello.c 27

Interactive debugging in Linux gdb(the GNU Project Debugger) r run; b breakpoint; p print; n next; s step into; Usage gcc g o hi hello.c gdb./hi 28

Off-line debugging in Linux Coredump Recorded state of a program s working memory when it crashed. Used to capture memory status during dynamic memory allocation Good at tracking a bug difficult to reappear Usage gcc g o hi hello.c ulimit -c unlimited./hi (segment fault) gdb./hi core.222 29

Profile tools in linux gprof display call graph profile data calculates the amount of time spent in each routine usage $ gcc -pg -o hello hello.c $./hello $ gprof hello more 30