CS197U: A Hands on Introduction to Unix

Similar documents
CS197U: A Hands on Introduction to Unix

CS197U: A Hands on Introduction to Unix

CS 261 Recitation 1 Compiling C on UNIX

CSE 374 Programming Concepts & Tools. Hal Perkins Winter 2012 Lecture 16 Version control and svn

Recitation #1 Unix Boot Camp. August 29th, 2017

Bok, Jong Soon

RH033 Red Hat Linux Essentials

2 Initialize a git repository on your machine, add a README file, commit and push

Intermediate Programming, Spring Misha Kazhdan

Text Editors for Programmers. Dr. Prasad Kulkarni Michael Jantz Jamie Robinson

Exercise 1: Basic Tools

2/9/2013 LAB OUTLINE INTRODUCTION TO VCS WHY VERSION CONTROL SYSTEM(VCS)? II SENG 371 SOFTWARE EVOLUTION VERSION CONTROL SYSTEMS

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

Recitation #1 Boot Camp. August 30th, 2016

Revision Control. An Introduction Using Git 1/15

9 and 11-Jan CSCI 4152/6509 Natural Language Processing Lab 1: FCS Computing Environment, SVN Tutorial. FCS Computing Environment, SVN Tutorial

CS197U: A Hands on Introduction to Unix

CS480. Compilers Eclipse, SVN, Makefile examples

Contents Coding standard Debugging tool Text editor Version control system

Section 2: Developer tools and you. Alex Mariakakis (staff-wide)

A Short Introduction to Subversion

CS 246 Winter Tutorial 1

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

And check out a copy of your group's source tree, where N is your one-digit group number and user is your rss username

Warmup. A programmer s wife tells him, Would you mind going to the store and picking up a loaf of bread? Also, if they have eggs, get a dozen.

A Practical Introduction to Version Control Systems

Using Git to Manage Source RTL

CS2720 Practical Software Development

Systems Software. Recitation 1: Intro & Revision Control. Quite different from 213. Our Philosophy. Partly-free lunch

Lab 3a Using the vi editor

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

213/513/613 Linux/Git Bootcamp. Cyrus, Eugene, Minji, Niko

Part I. UNIX Workshop Series: Quick-Start

CSCI 4152/6509 Natural Language Processing. Lab 1: FCS Computing Environment

Unix Philosophy, Text Editors, IDEs

AMath 483/583 Lecture 2

Linux Command Line Interface. December 27, 2017

AMath 483/583 Lecture 2. Notes: Notes: Homework #1. Class Virtual Machine. Notes: Outline:

Working with GIT. Florido Paganelli Lund University MNXB Florido Paganelli MNXB Working with git 1/47

Using RANCID. Contents. 1 Introduction Goals Notes Install rancid Add alias Configure rancid...

CS 460 Linux Tutorial

Systems Programming Advanced Software Development

2/8/18. Overview. Project Management. The First Law. What is Project Management? What Are These Changes? Software Configuration Management (SCM)

Project Management. Overview

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Operating Systems Lab 1 (Users, Groups, and Security)

Department of Computer Science College of Engineering Boise State University

Intro to Git. Getting started with Version Control. Murray Anderegg February 9, 2018

Getting started with Hugs on Linux

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

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

Lab 1 1 Due Wed., 2 Sept. 2015

Linux and Git Boot Camp

Introduction. File System. Note. Achtung!

Reviewing gcc, make, gdb, and Linux Editors 1

Introduction to Linux Environment. Yun-Wen Chen

Revision Control and GIT

CS 143A. Principles of Operating Systems. Instructor : Prof. Anton Burtsev

12/7/09. How is a programming language processed? Picasso Design. Collaborating with Subversion Discussion of Preparation Analyses.

9.2 Linux Essentials Exam Objectives

SECTION 1: CODE REASONING + VERSION CONTROL + ECLIPSE

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

Topics covered. Introduction to Git Git workflows Git key concepts Hands on session Branching models. Git 2

Git Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : October, More documents are freely available at PythonDSP

Software Development I

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

Common Configuration Management Tasks: How to Do Them with Subversion

Version Control. Kyungbaek Kim. Chonnam National University School of Electronics and Computer Engineering. Original slides from James Brucker

Compiling Software on UNIX. System Administration Decal Spring 2009 Lecture #4 George Wu Slides prepared by Joshua Kwan

CSE 391 Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

[Software Development] Development Tools. Davide Balzarotti. Eurecom Sophia Antipolis, France

CSE 391 Lecture 9. Version control with Git

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Git. Charles J. Geyer School of Statistics University of Minnesota. Stat 8054 Lecture Notes

Getting started with Hugs on Linux

EE516: Embedded Software Project 1. Setting Up Environment for Projects

FEEG Applied Programming 3 - Version Control and Git II

Short Read Sequencing Analysis Workshop

CSCI 2132 Software Development. Lecture 5: File Permissions

Using Subversion for Source Code Control

Terminal Windows, Emacs, Subversion and Make

CISC 220 fall 2011, set 1: Linux basics

Chapter 3. Revision Control

CS Unix Tools. Fall 2010 Lecture 10. Hussam Abu-Libdeh based on slides by David Slater. September 29th, 2010

Review of Fundamentals

Git Tutorial. Version: 0.2. Anders Nilsson April 1, 2014

Introduction to the UNIX command line

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Intro to Linux & Command Line

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

The Command Shell. Fundamentals of Computer Science

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

Revision control. INF5750/ Lecture 2 (Part I)

Parallel Programming Pre-Assignment. Setting up the Software Environment

Exercise sheet 1 To be corrected in tutorials in the week from 23/10/2017 to 27/10/2017

Section 1: Tools. Kaifei Chen, Luca Zuccarini. January 23, Make Motivation How... 2

Section 1: Tools. Contents CS162. January 19, Make More details about Make Git Commands to know... 3

ENCM 339 Fall 2017: Editing and Running Programs in the Lab

Version Control Systems

Computational Physics Compiling a C++ program

Transcription:

CS197U: A Hands on Introduction to Unix Lecture 7: Version Control and Advanced Topics Tian Guo University of Massachusetts Amherst CICS 1

Reminders Questions? tian@cs.umass.edu Assignment 4 is due on Oct 15. Let me know if you re skipping this. Have your own virtual machine configured! Will need to be a root in the following lectures No Class on Oct 13 (Monday Schedule) A Guest Lecture on Oct 15 No office hours on Oct 15 2

Last time File Processing Utilities Awk: Quick reviews and examples Sed Shell Scripting automating command line tasks

Today Programming in Linux compilers and accessories Version Control helps synchronize files shared with multiple users Advanced Vim Other Useful Commands 4

Programming in Linux Compiled languages - larger programs, optimized performance C, C++, C# Java Scripting languages - ease of development, cross platform Shell scripting Python Perl Ruby 38

C / C++ programming gcc and g++ are the main C / C++ compilers Usage: gcc file.c - o execname If you don t use -o flag, default name is a.out For projects with multiple files: g++ - c file1.cpp g++ - c file2.cpp # produces file1.o # produces file2.o # link the.o files into an executable g++ file1.o file2.o - o execname g++ file1.cpp file2.cpp - o execname 39

Building big programs If you are installing a program from source code or writing big apps... Don t want to manually compile and link each file and library Makefiles simplify the build process Contains a list of build targets Run make <target> to automate compilations steps Common procedure when installing from source:./configure - checks that you have libraries, prepares configuration files make - compiles the main application code make install - copies the new executables to their final paths (may require sudo!) 40

Simple Makefile example # A simple Makefile myprogram: main.o library.o gcc - o myprogram main.o library.o library.o: library.c library.h header.h make myprogram will automatically build the other targets gcc - c library.c main.o: main.c header.h gcc - c main.c clean: @rm - f myprogram main.o library.o Make tutorial: http://mrbook.org/blog/tutorials/make/ 41

Other languages Java Compile to create.class files: javac file.java javac file1.java file2.java file2.java Run: java file (where file.java contains a main method) Python type python at command prompt to use an interactive interpreter Run script by: python filename.py Perl/Ruby Run script by: perl filename.pl or ruby filename.rb 42

Today Programming in Linux compilers and accessories Version Control helps synchronize files shared with multiple users Advanced Vim Other Useful Commands 4

Version control systems Used to coordinate files being edited by multiple people Or just use it for your own projects to track history Helps resolve conflicts from simultaneous edits Stores history of files so you can easily revert / branch projects Many different version control systems: CVS Subversion Git Mercurial etc, etc 5

Version control concepts Repository - The set of files or directories that are under version control Stores the tracking history You never edit these files directly Local copy - check out files from repository to edit them Modify the files as you like Update - updates your local copies Detects if another user modified the same file Attempts to merge changes (only works for text files) Commit - sends your versions of the files to the repository Will only update repository if there are no conflicts A collection of actions that are performed inside the repository 6

Subversion workflow Checkout a working copy of the repository svn checkout svn+ssh://<username>@elnux7.cs.umass.edu/<path> Creates a local copy of all files Work on the files in the working copy. Everyone works on their own local copies Add new files to be tracked svn add <file or directory> 7

Subversion workflow Commit your changes back to the repository svn commit Double checks that there are no new conflicts Uploads your changes Update the files to see other people s changes svn update Applies their changes to your local files Will warn you about conflicts Must manually resolve files with edits to same lines Now your partner will have to get your changes svn update 8

Subversion Commands > svn checkout svn+ssh://<username>@elnux7.cs.umass.edu/<path> ## makes you a local copy of the files > svn commit - m A message describing what you ve done ## sends your files to the repository > svn add <filename or directory> ## Adds a file or directory to local copy and will send to repository on next commit > svn status ## shows status of files (A added, M modified,? not tracked, D- deleted etc.) > svn list svn+ssh://<username>@elnux7.cs.umass.edu/<path> ## prints out the files contained in repository > svn update ## updates your files 9

SVN on Edlab machines Each student has their own empty SVN repository in their course home directory /courses/cs100/cs197u/<username>/svn You should not interact directly with this directory ls svn conf, db, format, hooks, locks, README.txt Do not add/remove files from here 10

SVN on Edlab machines Instead, use svn checkout command to create a local copy in another directory When you check out a copy, it will also be called svn on your machine Usually the repository is stored somewhere else, but on the Edlab machines this setup works best because of permissions You can interact with these files, make new files (on your machine) They are only modified on your machine Use svn commands to add/remove files to/from the repository Then svn commit them, they ll be updated on the repository You will get a revision number for this round 11

Why use version control? Track and back up versions of your code Revert to an older version quickly and easily svn revert file_name Revert to a previous version if it is not yet committed Share files with a group Make individual changes and distribute code to everyone 12

Outline Programming in Linux compilers and accessories Version Control helps synchronize files shared with multiple users Advanced Vim Other Useful Commands 13

Important Vim commands There are three commonly used modes in Vim. Normal: return to this mode with ESC Insert: Start inserting new text; from normal mode, press i to enter Visual: Text selections; from normal mode, press v to enter Save without closing file: ESC + :w Save and quit: ESC + :wq Vim cheat sheet: http://vim.rtorr.com/ Advanced Vim Tips: http://vim.wikia.com/wiki/vim_tips_wiki

vi or vim - advanced text editor #2 Mode based - probably opposite of what you d expect Normal Mode - keys invoke different commands Insert Mode - keys type characters to the screen dozens of other commands. Some start with : some don t vim filename 15

vim Cheat Sheet Vim Visual Cheat Sheet :6 # e W % { 0 ^ } b w 'x Ctrl-N mx Ctrl-W p :split /foocl * % fi gd Ctrl-W j :vsplit :diffsplit k h j $ Ctrl-W k Ctrl-W l l H zt Ctrl-B M zz [{ ]} Ctrl-F L zb Created by vgod, Dec. 2009 Character h Movement/Range j k word, WORD(all non-blank ch) w W e Line ^ b 0 $ l next/prev word next/prev WORD end of word/word begin/end of line begin (non-blank) of line Paragraph, Block { } [{ ]} % prev/ next paragraph begin/end of block matching parenthesis Window, File H M L C-B mx B E top of win mid of win btm of win C-F zt scroll to top zz scroll to middle zb scroll to bottom prev/next page gg G begin/end of file 'x mark/jump to x Search * # find current word backward/forward fx to character x to right gd to definition of current word /xxx search xxx n N next/prev search result Mode Commands ESC C-[ enter normal mode v enter visual mode V C-v enter visual line mode enter visual block mode i enter insert mode R enter replace mode a append A append at end of line General Commands y yank/copy (range) d delete/cut (range) c modify (range) x delete/cut (character) D delete to end of line C modify to end of line p paste after cursor J join lines r replace (character) > indent < indent leftward. redo u undo EX Commands :w save(:wq save and quit) :q quit(:q! quit anyway) :e x edit file x :n new window :h vim help :xx jump to line #xx Auto-completion [insert mode] auto-complete C-N C-P next/prev keyword C-X C-F auto-complete file name Split window :vsp :sp vertically/horizontally split :diffs split and diff C-W p C-W w to last accessed window to next window

Configuring vim using vimrc syntax on/off: toggle color syntax set number/nonumber: toggle on/off line number noh: remove the highlight by searching Use pathogen.vim to install and manage vim plugins https://github.com/tpope/vim-pathogen

Outline Programming in Linux compilers and accessories Version Control helps synchronize files shared with multiple users Advanced Vim Other Useful Commands 17

Suspend, background, foreground To suspend a job (pause) Type ctrl-z suspends the current job, returns to prompt To check status of jobs Type jobs [1]+ Stopped bc To run a job in the background/foreground Type bg/fg %<job #>: fg %1 No arguments runs the most recently suspended job <command> & runs a job in the background directly 18

screen Program that allows you to detach/attach to terminal sessions Useful for running long processes Start process, detach from terminal session, log out of machine log in to machine, attach to same terminal session, view results screen - S <name> screen - r <name> ctrl- a d ctrl- d screen - ls exit (in screen session) Starts a new screen session Attaches to an existing session Detach from session Terminate session Lists current screen sessions Closes screen session 19

nohup detaching processes Usually, you run a command and wait for its output Can background a job and do other stuff all your running jobs get killed when logging out/disconnected nohup <command- with- flags> & standard output goes to nohup.out unless other file is given Will run the command in the background, detached from terminal close and reopen the terminal, will be still running (if not finished yet)!

cron scheduling re-occurring jobs Run a command regularly e.g. every day, every hour, on weekdays crontab e Edit cron file <min> <hr> <day_of_month> <month> <day_of_week> <command> One `job per line (make sure there is a new empty line for new job ) crontab l Display listing of cron jobs Examples 00 18 * * 1-5 mail s work on CS197u assignment me@me.com 00 00 1 1 * echo HAPPY NEW YEAR! 00 7 * * * backup.sh

Scheduling jobs after booting up Run a command after booting up There are several ways to do this Edit /etc/rc.local Make sure it is executable This is run as root! Add a line to your cron file @reboot /path/to/shell.script This is run without root access More crontab examples http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/

Display Forwarding Use ssh - X flag to forward the graphics from programs to your local machine ssh - X username@elnux.cs.umass.edu Example When you open Matlab, the GUI version displays Try typing gedit, a text editor window will pop up 23

rsync Synchronizes files and directories locally or across a network great for backing up files rsync - avz <source> <destination> - a archive - v verbose - z compress - P show progress and keep partially transferred files Resume from partial transfer possible --delete to reflect deletions in source in the destination directory Only copies files that change after first backup, much faster 24

Looking for things find - prints the path to a file (also remember locate) find <dir> -name 'assignment_*' whereis - locate a binary file > whereis perl /usr/bin/perl which > which ls /bin/ls 25

diff, cd diff - compares two files diff <file1> <file2> Output shows lines that appear in one file and lines numbers in both files cd - - moves to the last directory you were in 26

Next week We ll focus on network system Background knowledge of UNIX networking Basic skills to control/monitor network traffic of your system