Unit 10. Linux Operating System

Similar documents
Unit 13. Linux Operating System Debugging Programs

Using the Command Line

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi and Cyrill Stachniss

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

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

CS CS Tutorial 2 2 Winter 2018

Introduction to Lab Sessions

Lab: Supplying Inputs to Programs

Laboratory 1 Semester 1 11/12

Programming Studio #1 ECE 190

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

Eclipse Environment Setup

C++ Programming on Linux

CS 261 Recitation 1 Compiling C on UNIX

Introduction to Linux. Fundamentals of Computer Science

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

You should see something like this, called the prompt :

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

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

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

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

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

Intermediate Programming, Spring Misha Kazhdan

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

Unix Tutorial Haverford Astronomy 2014/2015

Session 1: Accessing MUGrid and Command Line Basics

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

Lab Working with Linux Command Line

Practical Session 0 Introduction to Linux

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

Programming Studio #1 ECE 190

User Guide Version 2.0

UNLV Computer Science Department CS 135 Lab Manual

AMS 200: Working on Linux/Unix Machines

ROS-Industrial Basic Developer s Training Class: Linux Basics. Southwest Research Institute Last Updated 2017

Intro to Linux & Command Line

Programming and Data Structure Laboratory (CS13002)

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

Lab 1 Introduction to UNIX and C

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

Python for Astronomers. Week 1- Basic Python

Introduction of Linux

Development Environment & Linux Guide

Working with the Command Line

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

Parallel Programming Pre-Assignment. Setting up the Software Environment

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

Guided Tour (Version 3.4) By Steven Castellucci

C++ For Science and Engineering Lecture 2

Introduction to the Linux Command Line

Introduction to Linux

CSE 391 Lecture 1. introduction to Linux/Unix environment

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

CMSC 201 Spring 2017 Lab 01 Hello World

The Directory Structure

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

HOW TO Use Linux, Text-Edit, Compile, and More

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

Linux and Git Boot Camp

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

CSE 391 Lecture 1. introduction to Linux/Unix environment

Essential Linux Shell Commands

Introduction: What is Unix?

Lab 1 Introduction to UNIX and C

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

CMSC 201 Spring 2018 Lab 01 Hello World

Chapter 4. Unix Tutorial. Unix Shell

Recitation #1 Boot Camp. August 30th, 2016

CHEM5302 Fall 2015: Introduction to Maestro and the command line

15-122: Principles of Imperative Computation

Getting Started With UNIX Lab Exercises

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

Numerical Algorithms for Physics. Andrea Mignone Physics Department, University of Torino AA

Unix Tools / Command Line

Terminal Windows, Emacs, Subversion and Make

Unix Basics. Systems Programming Concepts

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

Linux hep.wisc.edu

EKT332 COMPUTER NETWORK

CSC111 Computer Science II

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

CHEM 5412 Spring 2017: Introduction to Maestro and Linux Command Line

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

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

Using the Unix system. UNIX Introduction

CS Fundamentals of Programming II Fall Very Basic UNIX

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

Perl and R Scripting for Biologists

IDE: Integrated Development Environment

LAB 1 INTRODUCTION TO LINUX ENVIRONMENT AND C COMPILER

CSCI 2132 Software Development. Lecture 4: Files and Directories

Linux Survival Guide

CHAPTER 1 UNIX FOR NONPROGRAMMERS

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you.

Gradle and Command Line Workshop Activity

Tutorial 1: Unix Basics

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

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

STA 303 / 1002 Using SAS on CQUEST

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

Transcription:

1 Unit 10 Linux Operating System

2 Linux Based on the Unix operating system Developed as an open-source ("free") alternative by Linux Torvalds and several others starting in 1991 Originally only for Intel based processors but has now been ported to other platforms (i.e. ARM processors in your phone, etc.) Commonly used in industry and in embedded devices

3 Using the Command Line While it has a GUI interface like your Mac or Windows PC much of its power lies in its rich set of utilities that are most easily run at the command line (aka command prompt or terminal) Here we can navigate the file system (like you would with Explorer or Finder), start programs (doubleclicking an icon), and much more by simply typing commands Terminal Icon Linux Terminal View Vocareum Terminal View

4 Navigating the File System A file system has Folders (directories) Files They are organized in a hierarchy Everything we can do with a GUI we can do at the command line

5 Some Basic Commands Here are some helpful commands to use in Linux at the command prompt Command ls pwd cd dirname cp srcfiles dest mv srcfile dest rm srcfiles mkdir dirname rmdir dirname List (see) all files in the current folder Present working directory shows the current folder location of the terminal Change directory to a new folder Copy file(s) to a new location Move/rename files to a new name/location Remove files from the current folder Make directory / create a new folder Remove directory / delete a folder (must be empty first)

6 Directory Structure Ex. 1 Each circle is a directory Each name in the box is a file Starting from your home (e.g. 'mark') directory/folder Use cd to change directories (folders) cd Desktop cd cs102 cd hw7 Or go multiple folders at a time cd Desktop/cs102/hw7 hw7 hw7a.cpp hw7b.cpp you start here cs102 Desktop / home mark other Documents src test2.h test2.cpp

7 To go up a level use cd.. Directory Structure Ex. 2 To go up 2 levels use cd../.. Let's go one level to 'cs102' cd.. Now make a directory mkdir hw8 Shortcuts:. = Current directory.. = Parent directory (up one) ~ = Home directory * = Wildcard to match filenames Unix commands: pwd = Print current working dir hw7 hw7a.cpp hw7b.cpp you start here cs102 Desktop hw8 / home mark other Documents src test2.h test2.cpp

8 Directory Structure Ex. 3 Let's say we want to start a new lab with a copy of our old work and just modify it. Let's copy our work Recall I'm in cs102 folder currently cp hw7/* hw8/ you start here Desktop / home mark Documents Shortcuts:. = Current directory.. = Parent directory (up one) ~ = Home directory * = Wildcard to match filenames Unix commands: pwd = Print current working dir hw7 hw7a.cpp hw7b.cpp cs102 hw8 hw7a.cpp hw7b.cpp other src test2.h test2.cpp

9 Directory Structure Ex. 4 Let's now go into the test folder cd test Now rename the hw7a.cpp to hw8.cpp mv hw7a.cpp hw8.cpp Now delete the hw7b.cpp file rm hw7b.cpp Remember, you can see all the files in a folder by typing ls You can see what folder/directory you are in by typing pwd hw7 hw7a.cpp hw7b.cpp you start here cs102 Desktop hw8 hw7a.cpp hw7b.cpp / home mark other Documents src test2.h test2.cpp

EDITORS AND COMPILERS 10

11 Editors "Real" developers use editors designed for writing code No word processors!! You need a text editor to write your code Eclipse, Sublime, MS Visual Code, Emacs, Atom, and many others These often have handy functions for commenting, indenting, checking matching braces ({..}) etc.

12 Starting An Editor From the command line you can navigate to the folder where you want to create new files or where your files already exist cd cs102 You need to know the name of the editor application (subl for Sublime, code for MS Visual Code, emacs for Emacs) and you can include a filename after the application name and it will open that file (if it exists) or create it (if it doesn't) subl hw8.cpp & code hw8.cpp & emacs hw8.cpp & The '&' prevents the terminal from freezing until the editor is closed and thus allows you to continue typing in new commands into the terminal while the editor remains open

13 Compilers Several free and commercial compilers are available g++: clang++ XCode MS Visual Studio Several have "integrated" editors, debuggers and other tools and thus are called IDE's (Integrated Development Environments)

14 Software Process #include <iostream> using namespace std; int main() { int x = 5; cout << "Hello" << endl; cout << "x=" << x; return 0; } C++ file(s) (test.cpp) Std C++ & Other Libraries g++ Compiler 1110 0010 0101 1001 0110 1011 0000 1100 0100 1101 0111 1111 1010 1100 0010 1011 0001 0110 0011 1000 Executable Binary Image ("test") Load & Execute Note: Most documentation and books use $ as a placeholder for the command line prompt. $ subl test.cpp & $ subl test.cpp & 1 Edit & write code $ g++ g Wall o test test.cpp or $ make test 2 Compile & fix compiler errors $ subl test.cpp & $ g++ g Wall o test test.cpp $./test 3 Load & run the executable program

15 g++ Options Most basic usage g++ cpp_filenames Creates an executable a.out Options -o => Specifies output executable name (other than default a.out) -g => Include info needed by debuggers like gdb, kdbg, etc. -Wall => show all warnings Most common usage form: $ g++ -g -Wall hw8.cpp -o hw8

16 Running the Program First ensure the program compiles $ g++ -g -Wall hw8.cpp -o hw8 Then run the program by preceding the executable name with./ $./hw8