LAB 0: LINUX COMMAND LINE AND SVN

Similar documents
Introduction to Unix - Lab Exercise 0

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.

CSE115 Lab exercises for week 1 of recitations Spring 2011

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

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

Introduction to the UNIX command line

Using the Zoo Workstations

Lab Working with Linux Command Line

Intro to Linux & Command Line

CMSC 201 Spring 2018 Lab 01 Hello World

CMSC 201 Spring 2017 Lab 01 Hello World

CENG 334 Computer Networks. Laboratory I Linux Tutorial

SECTION 2: CODE REASONING + PROGRAMMING TOOLS. slides borrowed and adapted from Alex Mariakis and CSE 390a

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.

Physics REU Unix Tutorial

Lab 1 1 Due Wed., 2 Sept. 2015

Systems Programming and Computer Architecture ( ) Exercise Session 01 Data Lab

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C

You should see something like this, called the prompt :

Unix Tutorial Haverford Astronomy 2014/2015

CSC209. Software Tools and Systems Programming.

Recitation #1 Boot Camp. August 30th, 2016

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

Linux File System and Basic Commands

CS CS Tutorial 2 2 Winter 2018

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

CS Fundamentals of Programming II Fall Very Basic UNIX

Introduction to the Linux Command Line

Tutorial 1: Unix Basics

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

Parallel Programming Pre-Assignment. Setting up the Software Environment

COSC UNIX. Textbook. Grading Scheme

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

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]

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

CSC111 Computer Science II

Mills HPC Tutorial Series. Linux Basics I

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

TDDC88 Lab 4 Software Configuration Management

CSCI 2132 Software Development. Lecture 5: File Permissions

Getting Started With UNIX Lab Exercises

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Introduction: What is Unix?

Git. CSCI 5828: Foundations of Software Engineering Lecture 02a 08/27/2015

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Lecture 01 - Working with Linux Servers and Git

User Guide Version 2.0

CS 300. Data Structures

CSE 391 Lecture 1. introduction to Linux/Unix environment

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

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

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

Session 1: Accessing MUGrid and Command Line Basics

Computer Science 62 Lab 8

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Working with Basic Linux. Daniel Balagué

Introduction to UNIX command-line

CSE 391 Lecture 1. introduction to Linux/Unix environment

The Unix Shell & Shell Scripts

CSE 390a Lecture 1. introduction to Linux/Unix environment

Exercise 1: Basic Tools

CSN08101 Digital Forensics. Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Human-Computer Interaction Design

Due: February 26, 2014, 7.30 PM

Introduction to Linux

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

CS 1301 Fall 2008 Lab 2 Introduction to UNIX

Operating Systems. Copyleft 2005, Binnur Kurt

Commands are in black

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Subversion FOUR. 4.1 What is Version Control? 4.2 What is Subversion? Types of Version Control SESSION

Programming Studio #1 ECE 190

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

EDGE Tutorial and Sample Project Overview

COMS 6100 Class Notes 3

HOMEWORK 8. M. Neumann. Due: THU 29 MAR PM. Getting Started SUBMISSION INSTRUCTIONS

Guided Tour (Version 3.3) By Steven Castellucci as Modified by Brandon Haworth

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

Part I. Introduction to Linux

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Files

CS 261 Recitation 1 Compiling C on UNIX

CSC209. Software Tools and Systems Programming.

Introduction to Linux Workshop 1

Lecture 2: Data in Linguistics, Git/GitHub, Jupyter Notebook. LING 1340/2340: Data Science for Linguists Na-Rae Han

AMS 200: Working on Linux/Unix Machines

STA 303 / 1002 Using SAS on CQUEST

UNIX File Hierarchy: Structure and Commands

Unix Basics. Systems Programming Concepts

Introduction. Overview of 201 Lab and Linux Tutorials. Stef Nychka. September 10, Department of Computing Science University of Alberta

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Introduction to Unix: Fundamental Commands

Lab 2A> ADDING USERS in Linux

Introduction to Linux Spring 2014, Section 02, Lecture 3 Jason Tang

Lab 1: Introduction to Linux Networking

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

L.A.M.P. Stack Part I

Transcription:

CSE427S LAB 0: LINUX COMMAND LINE AND SVN M. Neumann Due: TUE 23 JAN 2018 1PM No group work. The submission for this lab needs to be done via SVN repository commit. The completion of this tutorial counts towards your recap [R] quiz score. Thanks to Angelina Lee and Anne Bracy for sharing this tutorial. Introduction The purpose of this lab is to get you up to speed on some basic class tools, namely: The Linux Command Line: Linux is a free, open source OS that has most of its identity derived from the precursor Unix family of operating systems. Like other operating systems, Linux provides a desktop environment; however, in this class you will learn to love the command line interface. Say goodbye to your mouse... We re not in Kansas anymore. (We re in Missouri!) SVN: short for subversion, or svn, (see also http://subversion.apache.org). This course relies on SVN to distribute and collect your assignments. Rather than using subversion via a GUI-based interface like Tortoise SVN, we will call our SVN commands exclusively from the Linux command line (in our course VM). This lab is a tutorial introducing the Linux command line. Working on the command line in the Linux course VM will be essential for all labs and homework assignments. 1 Explore commands for navigation, directory creation, etc. In the examples below, the > character is the prompt issued by the shell. The shell is the program that reads and interprets the commands provided by the user. Issue the command > pwd 1

which shows you your current working directory. Note that if you open a terminal via a Linux desktop session using the Linux Lab website, you may not be in your home directory (e.g., /home/cloudera/) when you first log in. In this case, issue the command > cd will bring you to your home directory. We indicate that you should be in your home directory as follows: home> home> ls provides a listing of the files and subdirectories in the current working directory. home> mkdir tmp_dir makes a new directory (within the current directory) called tmp_dir. Observe that this new directory is present with an ls command. This is the directory you will use for this course for the rest of the semester. home> rmdir tmp_dir removes the directory if it s empty (which it is right now). If the directory is not empty, you will get an error message, and the directory won t be removed (consider that a safety guard). Move to the new directory with cd, as follows: home> cd tmp_dir home/tmp_dir> An ls command should show that the new directory is empty. You can make an empty file in the current directory using touch: home/cse427s> touch newfile An ls now confirms that the file newfile is present. We can clean up after ourselves by removing the file we have just created. home/cse427s> rm newfile or simply go up one level, and remove the whole thing entirely: home/tmp_dir> cd.. home> rm -rf tmp_dir Note that the.. is a short hand for the parent directory you can do cd.. in any directory, and it basically brings you one directory up. The rm -rf removes the directory even though it is not empty. The rm -rf will remove a non-empty directory use man page to checkout what the -r and -f mean: home/cse427s> man rm Also checkout commands such as mv, cp, and less to learn what a particular command do. Remember, man is your friend. Any command line supported by linux, or any standard C library routines can be found under the man page. 2 Check out lab0 directory Each student in CSE427s has their own svn repository, which is accessible only by you, the instructor, the TAs, and a few technical support folks in the department. Your repository name will be your <wustlkey>/cse427s_sp18. 2

If you have not checked out your repository, do the following to check it out on your host machine (not inside the VM if you want to to that, see instructions below): > svn checkout https://svn.seas.wustl.edu/repositories/<yourwustlkey>/cse427s_sp18 cse427s The first string after svn checkout is the URL for your repository, and the second string indicates the directory name you want to use when you check out the repository. If you want to checkout your SVN repository inside your VM, you will need to install subversion before executing the above command. To install subversion execute the following command in the terminal: > sudo yum install subversion (if you are asked for a password use cloudera) When you are prompted for a username and password in order to access you SVN repository, you should provide your wustlkey username and password. This process will create a directory named cse427s. A few comments: 1. If you are asked whether to accept the site certificate for the server, go ahead and hit p for permanently. 2. If you are asked whether to store your svn password unencrypted, say no. Note: If you cut and paste this from the pdf, there is an underscore between cse427s and sp18 that often goes missing. Also note: there is a space between cse427s_sp18 and cse427s, where we assume you will check out the repo with the name cse427s, but really, you can name it anything you like. If you have checked out your repository, simply step into the directory: If you step into this directory, and do svn update to pull the code for lab0: home> cd cse427s home/cse427s> svn up This command will pull everything committed to your repository since you last updated which means, a copy of lab0 should now appear in your svn repository. Note that I use home as the ptath to the home directory. This path will most likely be differnt for you. home/cse427s> ls you will see some items including one called lab0. Is it a regular file, or is it a subdirectory? We can tell with the command home/cse427s> ls -l (this is a lower case L, not a 1) Which shows us the long form of the directory listing. The first character on the line is a d if the file is a directory. The next 9 characters show read, write, and execute privileges for the owner, group, and world. You are the owner, you can learn what groups you are in with the groups command (go ahead, type groups and hit return), and world is everyone. For normal files, execute privileges mean that the file can be executed (i.e., it is a program), just like one would expect. For directories, they indicate permission to navigate the directory (i.e., permission to issue an ls command within the directory). lab0 contains everything you need to complete the assignment. Move to the directory lab0 and issue an ls command there. You should find two files: origfile.txt and reallylongfile.txt. A quick viewing of a file can be accomplished with the cat command home/cse427s/lab0> cat origfile.txt home/cse427s/lab0> cat reallylongfile.txt 3

Notice that using cat for a really long file is a bit overwhelming since the entire file floods the screen far faster than you can read it. In such cases, you should use less. home/cse427s/lab0> less reallylongfile.txt Hit the spacebar each time you are ready to see the next page of the file. Hit q to quit less and return to the command line. You can determine the length of a file (or files) by using the word count command, wc. home/cse427s/lab0> wc origfile.txt home/cse427s/lab0> wc * (The star indicates that you want a word count of all files in that directory.) To understand the output of this command, read the manual entry for wc: home/cse427s/lab0> man wc The man command opens the wc manual in less, so once again, hit the spacebar to read more of the manual and type q to quit less and return to the command line. Note: although the.txt extension is common for normal text files, it is not required. Make a copy of this file and call it OrigFile.txt, noting that on Linux systems, filenames are case sensitive: home/cse427s/lab0> cp origfile.txt OrigFile.txt The mv command is short for move. We can change the name of our new file using this command: home/cse427s/lab0> mv OrigFile.txt answer.txt The ls command now shows us the files: origfile.txt, reallylongfile.txt, and answer.txt. The cp command did not remove the source file, but the mv command did (OrigFile.txt should be gone). Notice also that although origfile.txt is part of your svn repository, the new file answer.txt is not. You can observe this directly by issuing the svn info command: home/cse427s/lab0> svn info origfile.txt home/cse427s/lab0> svn info answer.txt Fix this by adding the new file to the repository. home/cse427s/lab0> svn add answer.txt Now try the status command (or stat for short): home/cse427s/lab0> svn status What happened? This command shows the file answer.txt with a character A in front of it. What this tells you is that, the file answer.txt has been earmarked to be added to the repository. Doing a svn info on the file will tell you the same thing in more details. Although it is earmarked to be added, it hasn t actually been added. To make the repository aware of the addition, you need to issue a commit to commit the the changes. home/cse427s/lab0> svn commit -m adding new file answer.txt answer.txt The -m specifies the comment for this commit. It s always a good idea to add a comment about what you re checking in. Now try the info command again home/cse427s/lab0> svn info answer.txt Notice, you have committed your changes. Also note that, for any of these commands, you can give a command multiple file names. Another way to see what s been done to a file is to use the svn log command. home/cse427s/lab0> svn log origfile.txt This will show you the time stamp and comment for every version of your code. Incidentally, this is how we can see whether your homework was checked in on time. In fact, when 4

we check out your repository, we just ask for the state of the repo as of the due date and time, and we won t even see anything that you turn in late. Aside: The most recent checked-in version of your repository can always be viewed (by those with permission!) on the web at the same URL that you used to check out your repository, i.e., https://svn.seas.wustl.edu/repositories/<yourwustlkey>/cse427s_sp18/ After you submit your homework via svn, it is a very good idea to check out this URL and make sure that everything looks up to date. It is your responsibility to make sure that you submit your homework both punctually and successfully. There are many other commands that svn supports, and naturally we won t be able to get into all of them in this document. To see a list of commands available, do: home/cse427s/lab0> svn help One other very useful command once you start coding is svn revert. To see how a command, do: home/cse427s/lab0> svn help revert 3 Linux Playtime Now that you have played around with Linux in the context of both files and SVN, take a moment to become even more familiar with the command line. Have a look at the following cheat sheet: https://www.cheatography.com/davechild/cheat-sheets/linux-command-line/ pdf/. That document (and many others you can find online) has a lot of information. But it s a good document. Skim through it and play around with the commands listed. Hopefully what we ve covered in this document is enough to get you by, but when in doubt, look though this or other cheat sheets you find online. Likely you will find what you need. The only way to get better at command line is by spending time and trying things out. You will get a hang of it eventually. 5