Helpful Tips for Labs. CS140, Spring 2015

Similar documents
CHE3935. Lecture 1. Introduction to Linux

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

Tutorial 1: Unix Basics

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

AMS 200: Working on Linux/Unix Machines

Physics REU Unix Tutorial

User Guide Version 2.0

Linux/Cygwin Practice Computer Architecture

CS CS Tutorial 2 2 Winter 2018

FILE MAINTENANCE COMMANDS

Intermediate Programming, Spring Misha Kazhdan

CSC111 Computer Science II

Introduction to Linux Environment. Yun-Wen Chen

Short Read Sequencing Analysis Workshop

CS1600 Lab Assignment 1 Spring 2016 Due: Feb. 2, 2016 POINTS: 10

Using the Zoo Workstations

Lab 1 Introduction to UNIX and C

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

Introduction to the UNIX command line

COL100 Lab 9. I semester Week 9, To be able to write C programs involving functions and recursion.

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

Linux Shell Script. J. K. Mandal

Mills HPC Tutorial Series. Linux Basics I

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

Linux Exercise. pwd answer: We call this directory (into which you get when you log in) your home directory.

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

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

Introduction to Unix - Lab Exercise 0

Laboratory 1 Semester 1 11/12

CSE 391 Lecture 1. introduction to Linux/Unix environment

Development Environment & Linux Guide

mkdir Phys338 s2017 Draw the tree of the directories and files for this step and all the following cd Phys338 s2017

Introduction to the Linux Command Line

CMSC 201 Spring 2017 Lab 01 Hello World

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.)

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

PDS Lab Section 16 Autumn Tutorial 1. Unix Commands pwd The pwd command displays the full pathname of the current directory.

Eugene, Niko, Matt, and Oliver

Lab 1 Introduction to UNIX and C

Lecture 01 - Working with Linux Servers and Git

CSE 391 Lecture 1. introduction to Linux/Unix environment

CS101 Linux Shell Handout

CMSC 201 Spring 2018 Lab 01 Hello World

Getting Started With UNIX Lab Exercises

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

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

Temple University Computer Science Programming Under the Linux Operating System January 2017

Command Line Interface The basics

C++ Programming on Linux

COSC UNIX. Textbook. Grading Scheme

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

Lab 3a Using the vi editor

Introduction. File System. Note. Achtung!

Intel Edison Tutorial: Introduction to Vim 1

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.

Outline. Structure of a UNIX command

Editors in Unix come in two general flavours:

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

15-122: Principles of Imperative Computation

Session 1: Accessing MUGrid and Command Line Basics

Programming and Data Structure Laboratory (CS13002)

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4

1. The Mac Environment in Sierra Hall 1242

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

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

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Introduction. SSH Secure Shell Client 1

Introduction: What is Unix?

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

Unix Introduction to UNIX

CS Fundamentals of Programming II Fall Very Basic UNIX

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Parallel Programming Pre-Assignment. Setting up the Software Environment

Week 2 Lecture 3. Unix

Development Environment. ICLAB NCTU Institute of Electronics

CHEM5302 Fall 2015: Introduction to Maestro and the command line

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

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

Lab Working with Linux Command Line

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

1. The Mac Environment in SIE 1222

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

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

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

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

Part I. Introduction to Linux

Tiny Instruction Manual for the Undergraduate Mathematics Unix Laboratory

Getting Started with UNIX

Std: XI CHAPTER-3 LINUX

No Food or Drink in this room. Logon to Windows machine

Practical Session 0 Introduction to Linux

A Brief Introduction to Unix

Linux File System and Basic Commands

Lecture 1. A. Sahu and S. V. Rao. Indian Institute of Technology Guwahati

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

Programming Studio #1 ECE 190

h/w m/c Kernel shell Application s/w user

Lab 1: Introduction to C++

Getting started with Hugs on Linux

Transcription:

Helpful Tips for Labs CS140, Spring 2015

Linux/Unix Commands Creating, Entering, Changing Directories to Create a Directory (a Folder) on the command line type mkdir folder_name to Enter that Folder cd foldername (cd stands for change directory) to go back to the previous folder cd.. to move back 2 directories cd../.. or to move 2 directories in cd folder1/folder2. means current directory (or folder).. means parent (or previous) directory (folder) When you create a directory, you are creating a folder inside of another folder. The 1st directory is the parent directory.

Examples I want to create a folder for my cs140 labs. First, I open my terminal. Then: Looking at moving into and out from directories: I made the directory cs140, and then entered that directory. ls lists the files and folders within the directory I am currently in. You will notice that the 2nd time I typed ls nothing happened. This was because I have nothing in the cs140 folder. I move into lab1 folder from my home directory. Then I saw that I have no files or folders in the directory (and there shouldn t be since I have not created any). Next, I move back out to my home directory. Here I can list the cs140 directory.

Examples Now I want to create folders for labs 1 and 2: I created both folders and then listed them. I moved into the lab1 directory and saw I have no files in the new directory (and there shouldn t be since the folder was just created). I moved back into the parent directory (cs140) and listed the contents of that folder (showing only 2 folders, as it should). I then move into the lab2 directory and do the same as before. Now, I want to switch from the lab2 directory to the lab1 directory. Next I move back into the parent directory and list the contents again.

Linux/Unix Commands Dealing with Files to Create a file (.txt,.cpp,.c,.pl, etc) vi filename.txt or vim filename.cpp vi/vim is the text editor. In a few slides, I will talk about vi/vim commands. to Edit a file use the same command vi filename.cpp to List the Files in the Directory type on the command line ls to see all the possible ways of listing these files type man ls to see the manual page to Remove a File rm filename.cpp to Remove a Directory rmdir foldername (Note: the folder must be empty to be deleted)

Examples To create the file filename.txt: This is what the terminal looks like after I hit enter: to Write (or save) the file type :w to Quit (or exit) the file type :q to Write and Quit the file type :wq (shown below) to Quit without saving the file type :q!

Examples After I Write and Quit my text file filename.txt, I can now see the file I created when I use the command line argument ls : The cat command shows the line of text from my file. Then, I remove my text file from the directory. Next, I show an example script and output.

Linux/Unix Commands Copying and Moving Files to Copy a File cp file_to_be_copied.cpp new_file.cpp to Move (same as Cut and Paste) a File mv file_to_be_moved.cpp ~/directory/address/to/move/file/to/ if also want to change the name of the file being moved: mv file_to_be_moved.cpp ~/directory/address/to/move/file/to/new_name.cpp to Change the Name of a File mv old_filename.cpp new_filename.cpp

Examples I changed the name of the file; then I copied that file, naming the new file filename2.cpp: Here I am moving filename2.cpp from the lab1 folder into the parent folder.

Linux/Unix Commands Fun Tips pwd (print working directory) will show you the address of your current folder use man (for manual pages) to get more information about a command c or clear cleans the screen, moving the prompt to the top of the page (you can still scroll up to see the last so many lines printed to the screen) bye exits the terminal There s also the tutorial, help guides, and other useful resources at http://www.tutorialspoint.com/unix/

vi (or vim) i enters insert mode o enters insert mode and adds a newline r replaces one character R enters replace mode ESC exits these modes x deletes one character (5x deletes 5 characters) yy yanks (or copies) a line (5yy copies 5 lines) dd deletes (or cuts) a line (5dd cuts 5 lines) p pastes the line u to undo the last action :redo to redo the last action G moves to the last line in the file :1 moves to the first line in the file /word_to_be_searched_for will search for the next instance of this word (after the initial command you only have to type / to go to the next instance) :w to Write (or save) the file type :wq to Write and Quit the file :q to Quit (or exit) the file type :q! to Quit without saving the file type

Examples(vi) To create the file filename.txt: This is what the terminal looks like after I hit enter: To start typing, hit i on your keyboard. This puts the text editor into insert mode. To exit any mode, press the ESC key on your keyboard. To replace a single character (when not in any of the editing modes), using your arrow keys move the cursor over the character you wish to change, press the r key, then press the key of the character you wish to replace. If you wish to replace multiple characters, pressing shift + r (or R ) will put the editor in replace mode.

Commenting Your Code Taken from Dr. Parker s webpage: http://web.eecs.utk.edu/~leparker/courses/cs302-fall06 /Labs.html Here's an example of what I would consider a well documented program: #include < stdio.h > /* sumnsquared.c Author: Ima Smart Date: August 23, 1998 This program prompts for and reads a value n from standard input, and then calculates and prints the sum of squares from one to n. It uses a for loop instead of using the closed form expression. */ main(){ int n; /* The value */ int sum; /* The running sum of squares */ int i; /* An induction variable */ /* Prompt for and read in a value of n */ printf("enter a value n: "); fflush(stdout); if (scanf("%d", &n)!= 1) { exit(1); } /* Calculate sum for each value of i from one to n */ sum = 0; for (i = 1; i <= n; i++) sum += (i*i); /* Print the final summation */ printf("%d\n", sum); }

Remote Login & SCP For those who need to download Putty/WinSCP: http://www.eecs.utk.edu/resources/it/kb/remote-access To ssh into the Hydra computers: in your Terminal type ssh NetID@hydra#.eecs.utk.edu and when it prompts, type in your password (it is the same password as for your email) Use scp (secure copy) to download files to and from the Hydra computers. First move to the folder on your computer where you want the files or have the files. to Download onto your Computer: scp NetID@hydra#.eecs.utk.edu:cs140/lab1/filename.cpp. to Download onto Hydra: scp filename.cpp NetID@hydra#.eecs.utk.edu:cs140/lab1/ Reminder:. means current directory (or folder) and.. means parent (or previous) directory (folder)

Casey Miller Last update: 2015.01.07 Thanks and Good luck!