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

Similar documents
Programming and Data Structure Laboratory (CS13002)

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

Introduction: The Unix shell and C programming

Introduction to Linux

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

Introduction to Linux

CS370 Operating Systems

Intermediate Programming, Spring Misha Kazhdan

Lab 1 Introduction to UNIX and C

Introduction: What is Unix?

Introduction to Linux. Fundamentals of Computer Science

CENG393 Computer Networks Labwork 1

CS Fundamentals of Programming II Fall Very Basic UNIX

CS 261 Recitation 1 Compiling C on UNIX

CISC 220 fall 2011, set 1: Linux basics

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

CENG 334 Computer Networks. Laboratory I Linux Tutorial

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

Saint Louis University. Intro to Linux and C. CSCI 2400/ ECE 3217: Computer Architecture. Instructors: David Ferry

Exercise 1: Basic Tools

Lecture P3: Unix. Overview. Operating Systems. Layers of Abstractions in Unix. Background

Lab 1 Introduction to UNIX and C

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

CMPUT 201: Practical Programming Methodology. Guohui Lin Department of Computing Science University of Alberta September 2018

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

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

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

Unix and C Program Development SEEM

3/13/2012. ESc101: Introduction to Computers and Programming Languages

Parallel Programming Pre-Assignment. Setting up the Software Environment

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

Lab 3a Using the vi editor

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

Practical Session 0 Introduction to Linux

Chapter-3. Introduction to Unix: Fundamental Commands

COSC UNIX. Textbook. Grading Scheme

EKT332 COMPUTER NETWORK

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

A Genomics View of Unix

Introduction to Linux

Helpful Tips for Labs. CS140, Spring 2015

Getting started with Hugs on Linux

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

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

EL2310 Scientific Programming

Using echo command in shell script

The Unix Shell & Shell Scripts

Introduction to Supercomputing

Mills HPC Tutorial Series. Linux Basics I

Introduction to Linux

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

CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A

Computer Science & Engineering 150A Problem Solving Using Computers

Laboratory 1 Semester 1 11/12

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

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

CSC111 Computer Science II

Working with Shell Scripting. Daniel Balagué

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

Using the Unix system. UNIX Introduction

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

Introduction to Linux Environment. Yun-Wen Chen

Using the Zoo Workstations

Introduction of Linux

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

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

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.

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

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

INF322 Operating Systems

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

Introduction to the Command line. Introduction to the command line. Introduction to the Command line. GNU/Linux at South Wales

Chap2: Operating-System Structures

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

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

Unix Shells and Other Basic Concepts

First steps on Linux and programming

Intro to Linux & Command Line

1. The Mac Environment in Sierra Hall 1242

Introduction to Unix and Linux. Workshop 1: Directories and Files

Linux/Cygwin Practice Computer Architecture

Getting Started With UNIX Lab Exercises

CSE 391 Lecture 1. introduction to Linux/Unix environment

Unit 10. Linux Operating System

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

Lec 1 add-on: Linux Intro

UNLV Computer Science Department CS 135 Lab Manual

Introduction to Linux

1. The Mac Environment in SIE 1222

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

Introduction to Linux Workshop 1

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

Getting started with UNIX/Linux for G51PRG and G51CSA

AMS 200: Working on Linux/Unix Machines

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

Unix Workshop Aug 2014

Linux Bootcamp Fall 2015

Unit 13. Linux Operating System Debugging Programs

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

Transcription:

Lecture 1 Introduction to Computing A. Sahu and S. V. Rao Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1

Outline Computer System Problem Solving and Flow Chart Linux Command ls, mkdir, cp, mv, rm, cat,.. Editor: vi, pico, gedit, kwrite, emacs How to program Write, Compile eand Execute e Explanation of C program Demonstration: if possible 2

What Is A Computer? An electronic device Operates under control of instructions (software) Stored in its own memory unit It can Accept data (input), Manipulate data (process), Produce output from the processing. A collection of devices that function together A collection of devices that function together as a system. 3

Computer System I/P Processing O/P Keyboard, Mouse : Input Speaker, Monitor/Display : Output CPU Box : Processing 4

Computer System: Von Newman Memory I/P Processing O/P Input and Output Processing Memory : Where it store Instruction, Data, Intermediate compute 5

Inside PC : Motherboard 6

Inside PC: Memory Card 7

Inside PC : Hard Disk 8

Inside PC : Processor 9

Computer System: When you Switch on Operating System boots from Hard disk OS : Give you an environment where you work Different OS Window XP/Vista/7 Linux: Fedora, Ubuntu, Debian Application can be invoked by clicking some icon Application: Word, Excel, Internet Explorer, Mozilla, MediaPlayer 10

Screen shot : Window & Linux Both are equally Good and Powerful Window: User friendly, prone to Virus, Commercial (Not Free: you have to Pay Money) Linux : Robust and Freely available 11

Application Software Application Software consists of programs That tell a computer how to produce information. Someofthemorecommonlyusedpackages are: Word processing, Spreadsheet Database Presentation graphics 12

Word Processing Used to create and print documents. A key advantage of word processing software Users easily can make changes in documents. 13

Electronic Spreadsheets Allows the user can do on rows and columns of numbers Add, Subtract, user defined calculations These numbers can be changed Spreadsheet quickly recalculates the new results 14

Database Software Allows the user to enter, retrieve, and update data In an organized and efficient manner With flexible inquiry and reporting capabilities. 15

Presentation Graphics Allows the user to create documents slides to be used in making the presentations. Using special projection devices to Project Slides display as they appear on the computer screen 16

Internet Browsing Allows the user to browse website View HTML pages Play internet video, games, do many things 17

How to create your own Application? Operating System : Linux, Window Applications: Word/Excel, Media Player, Mozilla, Explorer, etc We use it to do some tasks, but don t know inside contents Programming helps us to create our own application Already solution approach is known Draw the flow chart, writepseudocode Write code, compile, run and test 18

Programming: Purpose? Programming Purpose : to create a program that performs specific operations or exhibits a certain desired bh behavior. Computer Language (C, C++, Java, Fortran, Cobol) Design our own application Almost from the beginning Understanding how software/application works 19

How to do programming Problem: Specification Example: Compute sum of firstn natural number Define Input {N}, Output {SUM} How to do : Flow chart Write the C/C++/{*} Code in Note/Paper Program Sequence of Instructions and Data Can be run by Compiling and running Interpreting 20

How to do programming OS, Shell, IDE, Editor: Linux, Bash Shell, gedit/vi/pico Word Processor is not used to write program Integrated Development Environment: GUI Based TurboC/VisualC++/Kdevelop/Dev GUI Use the Program (Method 1) Compiling: GCC, TCC, VCC Running:./a.out Use the Program (Method 2) Interpret the program and run 21

Interpreter Interpreter Vs Compiler Examples: Shell/Command Prompts, ML, Perl, Python, Matlab Read code line by line and execute, sequential Basic syntax Errors occur at run time Compiler Example: C, C++, Java Read whole code together, make an executable and run the executable tbl Basic syntax Errors don t occur at run time, only logical and runtime error occurs 22

Interpreter Interpreter Example Examples: basic command line calculator l of Linux $bc 3*4 12 6+ (3+2)^2 31 Doing small computation easier Interpreter can read from file and execute line by line, example shell script 23

Writing and Compiling C Program #include <stdio.h> int main(){ under Linux printf( Hello world ); Header file: Standard Input/Output Starting of program } return 0; Printing message End of program 24

Compiling program: test.c Compiling : $gcc test.c Listing : $ls test.c aout a.out Execute the program : $./a.out Hello world 25

Example 1: Adding two number Flowchart START Step 1: Input A and B Step 2: S A + B Step 3: Print S Input A and B S A + B Print S STOP

Sum A+B : Input and output #include <stdio.h> int main(){ int A,B, S; printf( Enter two numbers ); scanf( %d %d,&a,&b); S=A+B; printf( Res=%d, B); return 0; } Header file: Standard Input/Output Printing message Asking for inputs Compute Output Result logical mistake, should 27 be S

Compiling program: test.c Compiling : $gcc Wall test.c It is advisable di to use Wall Wlloption to raise all warnings of the code Listing using $ls test.c aout a.out Executing : $./a.out Input two numbers 5 7 Res=12 28

C Programming in Liunx Environment We will be using Linux environment in CS110 Lab Editor : vim and gedit Compiler: GCC (Gnu Compiler Collection) You should ldknow a bit of Linux and Linux Command 29

Linux Basics Freely Downloadable from websites Available as sets of DVDs and IIT internal site Installation is very simple After installation you can create logins for different users

Linux Basics Each user may login by his/her own login and passwd own login area Upon login, default directory is home directory of the user In Computer center, We will provide machine withlinux installed.

Screen shot : Window & Linux Both are equally Good and Powerful Window: User friendly, prone to Virus, Commercial (Not Free: you have to Pay Money) Linux : Robust and Freely available 32

Linux basics: Command, Shell Basic

Linux basics: Command, Shell Basic Whatever you can do by clicking using GUI Same can be done by textual command Doing using GUI and mouse click Is easy and convenient for layman users Internally : Mouse click convert get converted to textual command and execute Textual commands are Faster and easy to understand

Linux basics: Shell Basic Command Prompt Linux/Unix i is case sensitive i.e. WHO is not same as who Shell is a command program to communicate with a computer Shell interprets the command that you enter on keyboards Shell commands can be used to automate various programming gtasks

Linux commands Usually short and cryptic like vi or rm Commands may also have modifiers for advance options like: ls l and mv R are different that ls or mv respectively

Important commands ls: listing of the current directory cp: Copy file from source to destination mv: Move file from source to destination vi, Edit a file. vi is one of the most powerful text editors

Important Linux Commands chmod, Change file permissions mkdir, rmdir Make/Remove a directory cd, Change directory rm, Remove a file. Can also remove directory tree man ls, Get help for ls.

Command: ls Command to list files and directory ls [user1@localhost] $ ls Command : ls *.c list all file with extension.c List all C file in the current dirctory Command: ls a* list all the file/directory started with a

Wildcards You can substitute the * as a wildcard symbol for any number of characters in any filename. You can mix the * with other characters to form a search pattern: ls a*.txt will list all files that start with a and end in.txt The? wildcard d stands for any single character: ls draft?.doc will list draft1.doc, draft2.doc, draftb.doc,, etc.

Control characters You type Control characters by holding down the control key while also pressing the specified character. While you are typing a command: ctrl W erases the previous word ctrl U erases the whole command line Control commands that work (almost) any time ctrl S suspends (halts) output scrolling up on your terminal screen ctrl Q resumes the display of output on your screen ctrl C will abort any program

Text Editors Available on Linux Systems Vi/vim Non graphical (terminal based) editor. Guaranteed to be available lbl on any system. Requires knowledge of arcane keystroke commands. Distinctly unfriendly to novices. emacs, gedit, kwrite, pico Window based editor Primitive menus make it slightly more friendly to novices. Emacs: Still need to know keystroke commands to use. Installed on all Linux distributions and on most other Unix systems.

File Type and permission $ls l list all file in detail $file test.c executable, text, media, library Attribute of file and directory User, group and others 43

Help on command line: Manual page Best local resources in the Linux System man :Typeman and the name of a command to read the manual page for that command. e.g. man ls man mv You can find many web resources on Linux command Basic Linux Command References @ http://jatinga.iitg.ernet.in/~cs110/pdf/linux_cmd_refer ence.pdf

Thanks 45