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

Similar documents
Perl and R Scripting for Biologists

Introduction of Linux

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

Introduction to Linux

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

GNU/Linux Course Lesson 1. Puria Nafisi

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

Introduction: What is Unix?

Linux at the Command Line Don Johnson of BU IS&T

Introduction to Linux

INF322 Operating Systems

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

Intro to Linux & Command Line

Operating Systems. Copyleft 2005, Binnur Kurt

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

CISC 220 fall 2011, set 1: Linux basics

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

Introduction to Unix: Fundamental Commands

CS 300. Data Structures

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

Lab Working with Linux Command Line

CS 300 Data Structures

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

INSE Lab 1 Introduction to UNIX Fall 2017

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

The Directory Structure

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

Essential Linux Shell Commands

Computer Systems and Architecture

CENG393 Computer Networks Labwork 1

Using the Unix system. UNIX Introduction

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

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

Linux. An introduction. Aurélien Villani 01/2018

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

CSE 391 Lecture 1. introduction to Linux/Unix environment

Chapter-3. Introduction to Unix: Fundamental Commands

1 Installation (briefly)

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

Introduction to Linux

The Unix Shell & Shell Scripts

A Brief Introduction to the Linux Shell for Data Science

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

Introduction to Linux

Chapter 4. Unix Tutorial. Unix Shell

INTRODUCTION TO LINUX

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

LAB #7 Linux Tutorial

Working with Basic Linux. Daniel Balagué

Introduction to Linux Basics

Linux Command Line Primer. By: Scott Marshall

CSE 391 Lecture 1. introduction to Linux/Unix environment

Introduction to UNIX command-line

EKT332 COMPUTER NETWORK

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

Introduction to Linux. Fundamentals of Computer Science

CSC209. Software Tools and Systems Programming.

Physics REU Unix Tutorial

A Brief Introduction to Unix

Scripting Languages Course 1. Diana Trandabăț

Introduction to Linux Workshop 1

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

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

Introduction. Let s start with the first set of slides

L.A.M.P. Stack Part I

Introduction To Linux. Rob Thomas - ACRC

Computer Architecture Lab 1 (Starting with Linux)

Introduction to Linux for BlueBEAR. January

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

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

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

Introduction to the UNIX command line

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.

CS197U: A Hands on Introduction to Unix

Getting started with Hugs on Linux

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

Linux/Cygwin Practice Computer Architecture

Linux & Shell Programming 2014

Unix System Architecture, File System, and Shell Commands

The Unix Family. Linux 101. GNU/Linux distributions. Even more. MULTICS MIT/GE/Bell Labs. UNIX AT&T (Bell Labs) Mach, Carnegie Mellon

Introduction to Linux

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.

Mills HPC Tutorial Series. Linux Basics I

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

COMS 6100 Class Notes 3

Computer Systems and Architecture

Unix Basics. Systems Programming Concepts

Unix Basics. Benjamin S. Skrainka University College London. July 17, 2010

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

Introduction of Linux. Huang Cheng-Chao Dept. of Comput. Sci. & Tech. East China Normal University

Introduction to the Linux Command Line

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

Lab01: Part I. Introduction to Linux. Professional Training Academy Linux Series

Introduction to Linux

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

INTRODUCTION TO BIOINFORMATICS

Unix Tutorial Haverford Astronomy 2014/2015

You should see something like this, called the prompt :

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

Transcription:

EECS 2031 - Software Tools Lab 2 Tutorial: Introduction to UNIX/Linux Tilemachos Pechlivanoglou (tipech@eecs.yorku.ca) Sep 22 & 25, 2017

Material marked with will be in your exams Sep 22 & 25, 2017

Introduction to Unix Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 3

Linux is an operating system (OS) Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 4

It was based on UNIX Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 5

Applications Distribution Kernel An entire Linux system Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 6

Applications Distribution Kernel Linux kernel Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 7

Linux kernel Written in C by Linus Torvald in 1991 Handles low-level actions like: CPU usage RAM/memory usage Hard disk read/write Filesystem management Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 8

Applications Distribution Kernel Linux distributions Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 9

Linux Distributions (distros) Bundles containing: the kernel all the tools needed to interact with it application/program store and installer other tools like device drivers, etc. Most popular Linux distros: Ubuntu Fedora CentOS RaspBian RedHat opensuse Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 10

Shell Graphical shell Linux shell Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 11

Linux shell Shell: interface between kernel & outside world (user) can be through a command line or graphical Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 12

Linux graphical shell The graphical shell: is much more user friendly web browsers, image editors, etc. use it is similar to Windows or MacOS user interfaces has many variations, with GNOME most popular provides access to the command line interface (CLI) through the Terminal program Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 13

Linux basic shell The basic command line shell (or just shell) : is much more powerful and versatile in Linux many programs only use this instead of a UI has many variations, tcsh and bash are very popular usually comes with helpful features, like: filename completion with Tab key command history with Up or Down arrow keys Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 14

Files and proccesses Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 15

Files and proccesses Everything in Linux is either a file or a proccess Process: executing program has a unique PID (proccess identifier) File: a collection of data created by the system or the user through programs its path is its location in the system plus its name files starting with. are hidden Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 16

Directory structure Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 17

Directory structure (1/2) In Linux, files are organised in groups called directories (folders). Directories can be nested (sub-folders) The result is a tree structure Every file and folder is located on that tree The top of the tree is always the root directory( / ) A folder is symbolized with / after its name e.g. Documents/ A file or folder s path is its location plus its name e.g. /home/tipech/documents/report.doc Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 18

Directory structure (2/2) Root directory: has various system folders (usr, bin, etc,...) has a folder called home has inside home a folder for every PC user lab PCs have virtual users, only your username appears this is your home directory Home directory: contains only your stuff (e.g. Documents, Pictures) has the alias ~, short for /home/username/ Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 19

Directory structure Root directory: / User home directory here: ee51vn Contains 2 folders: docs, pics Home contains 1 file: lab.c docs folder contains 1 file: report.doc File s full path: /home/ee51vn/docs/report.doc Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 20

Working with directories Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 21

1 2 Launching a terminal Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 22

user@ computer Terminal window Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 23

Working directory The terminal points at any time to a directory Just as a web browser points at a website or sub-page We can change directory to navigate the file system The current directory is symbolized with. The parent directory (one level up) is symbolized with.. Use pwd to print the working directory To change directory, use cd e.g. cd Documents Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 24

pwd & cd Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 25

List, clear To list files/folders in a directory, use ls (list) e.g. ls, ls /home/tipech you can also use ll to list files with details You can pass command arguments with -<arg> e.g. ls -a (prints everything, including hidden files) To clear the terminal screen, use clear Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 26

ls, ls -a, ll Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 27

Make directory, remove To make a new directory, use mkdir e.g. mkdir Test To remove files or empty folders, use rm/rmdir e.g. rm Documents/report.doc, rmdir Test If a folder has items inside, you need to use recursive removal with -r e.g. rm -r Documents Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 28

mkdir, rmdir Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 29

Copy, move To copy a file use cp (-r for non-empty folders) the usage is cp <original_path> <target_path> e.g. cp Documents/report.txt. this copies the file to the current directory,. don t forget the space between paths! Similarly, to move a file, use mv (-r) e.g. mv Documents/report.txt. Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 30

cp, mv Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 31

File contents To print a file s contents use cat (concatenate) e.g. cat Documents/report.txt. Alternatively, use head, tail or less head prints the first 10 lines of a file tail prints the last 10 less prints everything, one page at a time Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 32

cat, tail Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 33

Search To search for something in a file use grep use the -i argument for non case sensitive searches use -v to display lines that do not match use -n to print line numbers in results use -c to print the count of matches instead you can combine arguments, e.g. -ivc e.g. grep line -i report.txt To count the number of words, use wc Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 34

grep Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 35

Info, man pages, interrupt For help, man <command> or info <command> e.g. man ls If you are stuck in a program at any time, Ctrl+C sends an interrupt signal (stop) to it To copy or paste in Terminal, use Ctrl+Shift+C and Ctrl+Shift+V, respectively Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 36

Permissions, sudo Linux user permissions: As a regular user, you can only modify files and folders under your home directory. For many actions, super user (administrator) privileges are required Do that (in non-lab PCs) with sudo <command> e.g. sudo cp ~/report.txt /usr/ Alternatively, log in as SU with sudo su and run commands normally Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 37

Programming in C Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 38

Creating a program Steps for making a program in C: 1. Break your goal into smaller pieces 2. Write code (source) in a text editor for each one 3. Compile the source into an executable (program) 4. Run the program 5. Find out what went wrong/right (debugging) 6. Back to step 2 until you are done Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 39

Writing a program You need to create a C file (.c) with your code To do that, you use a text editor For this lab (and most Linux distros) you use gedit In gedit, you can write and save a file as <name>.c Save that file anywhere in your home directory Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 40

1 2 3 Launching gedit Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 41

gedit Text Editor Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 42

Compiling a program For the next step, compile the source: Open a Terminal window Navigate to where you saved the source code Compile it with the GNU C Compiler by typing gcc source.c or cc source.c This creates the executable a.out Alternatively, you can name the output file with: cc source.c -o executable Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 43

Running a program To run the executable, simply enter its name e.g. a.out If it doesn t terminate on its own, use Ctrl+C to stop These 3 steps are combined in an IDE program (Integrated Development Environment) There you can compile and run with a single button Such programs are Eclipse, Visual Studio, Geany You can use Geany for C development in the lab Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 44

Thank You! Sep 22 & 25, 2017 Tilemachos Pechlivanoglou 45