Linux/Cygwin Practice Computer Architecture

Similar documents
Introduction to Linux Environment. Yun-Wen Chen

Mills HPC Tutorial Series. Linux Basics I

User Guide Version 2.0

CHE3935. Lecture 1. Introduction to Linux

Unix Workshop Aug 2014

Lab Working with Linux Command Line

Linux Shell Script. J. K. Mandal

Introduction to the UNIX command line

Helpful Tips for Labs. CS140, Spring 2015

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

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

AMS 200: Working on Linux/Unix Machines

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

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

CS4350 Unix Programming. Outline

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

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

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

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Introduction to Cygwin Operating Environment

Introduction to the Linux Command Line

Development Environment & Linux Guide

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

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

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

Intermediate Programming, Spring Misha Kazhdan

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]

Unix Tutorial. Beginner. CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015

The Directory Structure

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

Lab 3a Using the vi editor

Practical Session 0 Introduction to Linux

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

INF322 Operating Systems

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

Outline. Structure of a UNIX command

CENG 334 Computer Networks. Laboratory I Linux Tutorial

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

Development Environment. ICLAB NCTU Institute of Electronics

Short Read Sequencing Analysis Workshop

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

Getting started with Hugs on Linux

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

Session 1: Accessing MUGrid and Command Line Basics

CS101 Linux Shell Handout

Physics REU Unix Tutorial

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

An Introduction to Unix

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

CS CS Tutorial 2 2 Winter 2018

CS Fundamentals of Programming II Fall Very Basic UNIX

Std: XI CHAPTER-3 LINUX

Working with Basic Linux. Daniel Balagué

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

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

Linux Command Line Primer. By: Scott Marshall

Parallel Programming Pre-Assignment. Setting up the Software Environment

COSC UNIX. Textbook. Grading Scheme

Introduction: What is Unix?

Using WestGrid from the desktop Oct on Access Grid

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Getting Started with UNIX

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

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

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

CSCI 2132 Software Development. Lecture 4: Files and Directories

UNIX Quick Reference

Introduction. SSH Secure Shell Client 1

C++ Programming on Linux

Unix Introduction to UNIX

(7) Get the total energy from the output (1 Hartree = kcal/mol) and label the structure with the energy.

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

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

Introduction to Linux Workshop 1

Getting started with Hugs on Linux

Introduction to Linux. Fundamentals of Computer Science

The Unix Shell & Shell Scripts

Introduction to Linux

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

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

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

UNLV Computer Science Department CS 135 Lab Manual

CS/CIS 249 SP18 - Intro to Information Security

A Brief Introduction to Unix

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.

Using the Zoo Workstations

Getting Started With UNIX Lab Exercises

Part I. UNIX Workshop Series: Quick-Start

Using the Unix system. UNIX Introduction

15-122: Principles of Imperative Computation

Course 144 Supplementary Materials. UNIX Fundamentals

Chapter-3. Introduction to Unix: Fundamental Commands

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Operating System Interaction via bash

You will automatically be in your user (home) directory when you login.

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

INTRODUCTION TO BIOINFORMATICS

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

Introduction of Linux

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Transcription:

Linux/Cygwin Practice 2010 Computer Architecture

Linux Login Use ssh client applications to connect (Port : 22) SSH Clients zterm ( http://www.brainz.co.kr/products/products4_2.php ) Putty ( http://kldp.net/frs/download.php/3411/hangulputty-0.58.h2.exe ) Some departments provide Linux machines for undergrads Change your default password using command passwd 2/23

Cygwin On Windows machine Cygwin provides a similar environment to Linux Windows DLL for Linux API emulation Tools with Linux look & feel Download Cygwin setup file from the following URL and install it http://www.cygwin.com 3/23

Shell Shell? Interface program between users and OS Typing commands, user can launch programs Prompt and cursor Ready to take commands from users 4/23

File and Directory Directory Separate space (or folder) for related files Usually keep different files in different directories / indicates the hierarchy of directories and files Ex) /home/beowulf/readme.txt Examples: /etc and /bin represent two different directories. : current directory / : top level directory (root directory) Current directory.. : immediately above directory Users work within a specific directory for file editing and executing apps. pwd command shows the full path of current directory After login (or launching cygwin), the initial directory is called home directory Ex) /home/userid 5/23

Usage Rights User On Linux, userid distinguish individual users Example: jschoi, jdseo, etc Group Multiple users belong to a group Example: users = (jschoi, jdseo, ) ca_st = (st001, st002, ) Ownership Each file has a designated user and group Each file has different usage right for 3 categories (owner, group, other) For each category, Read, write, execute rights can be differently specified For directories, execute right means right to change directory 6/23

File List ls command List up files and sub-directories in current directory. ls -al : can have options such as -al (For details, ls --help) [directory(1)][user(3)][group(3)][other(3)] r=read, w=write, x=execute 7/23

Directory Command cd <directory_name> : changes current directory Ex) cd.., cd work, cd /usr/local, If no directory_name is specified, changes to home directory pwd : shows the full path of the current directory mkdir <directory_name> : creates a new directory rmdir <directory_name> : delete the specified directory temp 8/23

File Commands cp <source-file-name> <target-file-name> Copy the source file to the target file mv <source-file-name> <target-file-name> Similar to cp, but the source file is deleted (move) rm <file-name> - Delete the file cat <file-name> - show the content of the file 9/23

Misc. Commands (1) chmod Change the access right of the file Example chmod 764 <file-name> 7 = user access right : 4(read)+2(write)+1(execute) 6 = group access right : 4(read)+2(write) 4 = other access right : 4(read) Each number can be 0~7 depending on access right you want to specify man [section] <command> - show manual pages for command Can look up the manual pages of C system calls and library functions E.g. write(2) : write command in section 2 For most commands, <command> --help shows the usage pages Try apropos 10/23

Misc. Commands (2) Function-name(section) Brief description Necessary headers, function type Detailed description Return value Error code 11/23

Misc. Commands(3) Error code (cont d) Other notes to mention Related functions 12/23

Using vi vi Most prevail file editor in Unix/Linux environment Command mode Search and edit command can be used Vi starts in command mode Input mode Type characters into the file Switch between two modes Command mode input mode : press one of the following - i, l, a, A, o, O, R Input mode command mode : press ESC 13/23

Using vi Command mode input mode Press one of the following i, l, a, A, o, O, R Key pressed i I a A o O R Action Insert at the cursor Insert at the beginning of the current line Append at the next position of the cursor Append at the end of the current line Open a new line at the end of current line Open a new line in front of the current line Replace from the current cursor 14/23

Using vi Move cursor in command mode Key Cursor Position Key Cursor Position k One line above b One word left j One line below Ctrl-D Half screen down l One character right Ctrl-F Full screen down h One character left Ctrl-U Half screen up ^ Beginning of the line Ctrl-B Full screen up $ End of the line :n n-th line w One word right 15/23

Using vi Delete text Key x dw dd D :nd Action Delete a character at the cursor Delete a word at the cursor Delete a line at the cursor Delete characters from the cursor to the end of line Delete n lines from the cursor 16/23

Using vi File save, read, quit Key Action :w <filename> Save current file to <filename> :w Save current file :<range>w <filename> Save the lines in the <range> to <filename> :r <filename> Read <filename> at the current cursor :q Quit if the file is not modified :q! Force to quit without saving the modified text :wq Save the modified text and quit 17/23

Using vi Other commands Copy text Key p Action Put the text in the buffer at the next character of the cursor or at the next line of the cursor Search text P Key Put the text in the buffer in front of the cursor or at the above line of the cursor Action /[pattern]?[pattern] Search for [pattern] in the forward direction Search for [pattern] in the backward direction / Repeatedly search for the recently searched pattern in the forward direction? Repeatedly search for the recently searched pattern in the backward direction n N Repeatedly search for the recently searched pattern in the current direction Repeatedly search for the recently searched pattern in the opposite direction 18/23

Using vi Learn frequently used commands first! Tutorial for vi Korean version http://www.joinc.co.kr/modules/moniwiki/wiki.php/site/dev elopment/env/usedvim English version http://www.eng.hawaii.edu/tutor/vi.html 19/23

Structure of C Program #include headers, global variables, function declarations main() entry function Local variables Program body Return 0 end of main() Another function divide() 20/23

Comment in C Programs Comment Describe the program Ignored when compiling Form of comment in C /* comment-text */ // comment-text all characters to the end of line are comment 21/23

Compile and Execute gcc <options> <C-program-file> Without options, the default executable file is a.out Typing./a.out at the prompt will execute the program gcc -o <executable-filename> <C-program-file> will produce an executable file with the specified name E.g.) gcc o div div.c [cygwin-pc]$./div 22/23

Practice 1) Create a directory named lab in your home directory 2) Using vi, create a file called div.c in your lab directory 3) Compile the program to produce the executable file named div 4) Move your div program to your home directory and run it there 23/23

Computer Architecture Lab. 24/23