UNIT 1 Computing Fundamentals.

Slides:



Advertisements
Similar presentations
Legal Meetings: Extended Instructions on Movica and Screencast.
Advertisements

Introduction to the Omega Server CSE Overview Intro to Omega Basic Unix Command Files Directories Printing C and C++ compilers GNU Debugger.
Chapter One The Essence of UNIX.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
Dayu Zhang 9/8/2014 Lab02. Example of Commands pwd --- show your current directory This is home of venus, not your home directory Tilde: means you are.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Linux+ Guide to Linux Certification, Second Edition
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
CS1020: Intro Workshop. Topics CS1020Intro Workshop Login to UNIX operating system 2. …………………………………… 3. …………………………………… 4. …………………………………… 5. ……………………………………
Guide To UNIX Using Linux Third Edition
Virtual Machine and UNIX. What is a VM? VM stands for Virtual Machine. It is a software emulation of hardware. By using a VM, you can have the same hardware.
Unix Workshop Aug What is Unix Multitasking, multiuser operating system Often the OS of choice for large servers, large clusters.
Creating a Web Page HTML, FrontPage, Word, Composer.
Deployment Management The following screens demonstrate how to: 1. Access and view deployments 2. Create a new local deployment 3. Create and modify a.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
A crash course in njit’s Afs
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
BASIC IPAD SETUP ONLINE APPLE IPAD MANUAL. BUTTONS.
Welcome to the Southeastern Louisiana University’s Online Employment Site Applicant Tutorial!
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Overview of Linux CS3530 Spring 2014 Dr. José M. Garrido Department of Computer Science.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Unix Basics Chapter 4.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction Unix-like system is everywhere Linux Android for smartphones Google Chrome OS for Chromebook Web.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
FTP Server and FTP Commands By Nanda Ganesan, Ph.D. © Nanda Ganesan, All Rights Reserved.
1 N305 C Programming. 2 Objectives for the Lab ä Learn problem solving strategies ä Achieve intermediate knowledge of C Programming Language ä Gain experience.
1 ITI 1120 Lab # 1 An Introduction to the Lab Environment Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
Training Guide for Inzalo SOP Users. This guide has been prepared to demonstrate the use of the Inzalo Intranet based SOP applications. The scope of this.
Lesson 11: Looking at Files and Folders what a file or folder is on the computer how to recognize a file or folder on the desktop how to recognize the.
UNIX Workshop Freshmen Orientation UNIX workshop Before we begin…  Does everybody have a computer?  Does everybody have your account slips?
U3A Computing Beginners Class Leader – Brian Moore Week 2 of 10 weeks. Mondays 4:15 to 5:45 pm.
Compiling a C Program. Before we can begin we must open a telnet session to phobos. There are a number of ways to do this, but the easiest is to click.
Unix and Samba By: IC Labs (Raj Kidambi). What is Unix?  Unix stands for UNiplexed Information and Computing System. (It was originally spelled "Unics.")
Introduction To UNIX. FAQReferencesSummaryInfo Resources Introduction Learning Objectives Log on User Interface Commands List of Commands Useful Info.
Creating Programs on UNIX This term you can create programs on UNIX or you can create programs using a C++ compiler on your PC. This set of slides steps.
Compliance Assist Refresher Instruction Guide Adding or Editing Student Learning Outcomes.
Introduction to Programming Using C An Introduction to Operating Systems.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Unix Servers Used in This Class  Two Unix servers set up in CS department will be used for some programming projects  Machine name: eustis.eecs.ucf.edu.
1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile.
FTP COMMANDS OBJECTIVES. General overview. Introduction to FTP server. Types of FTP users. FTP commands examples. FTP commands in action (example of use).
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
The Kernel At a high level, the kernel in an operating system serves as the bridge between applications and the actual data processing of the hardware.
CSE 1320 Basics Dr. Sajib Datta
Introduction to UNIX and Linux.  Written by Dennis Ritchie and Ken Thomsom at Bell Labs in 1969  Initially written in assembly language and a high-level.
Getting Started with Unix Naomi Altman. Connecting to a PSU Linux Cluster click on SSH click on "quick connect" Host Name: lxcluster.tlt.psu.edu User.
BIF703 FTP (File Transfer Protocol) Utility vi editor Utility.
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
CACI Proprietary Information | Date 1 PD² v4.2 Increment 2 SR13 and FPDS Engine v3.5 Database Upgrade Name: Semarria Rosemond Title: Systems Analyst, Lead.
Assignprelim.1 Assignment Preliminaries © 2012 B. Wilkinson/Clayton Ferner. Modification date: Jan 16a, 2014.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
CS1010: Intro Workshop.
Web Programming Essentials:
CS1010 Programming Methodology
Assignment Preliminaries
An Introduction to Computers and Visual Basic
Intro to UNIX System and Homework 1
Web Programming Essentials:
Getting Started: Developing Code with Cloud9
Getting Started: Amazon AWS Account Creation
Introduction Paul Flynn
Computer Basics.
An Introduction to Computers and Visual Basic
CSCE 206 Lab Structured Programming in C
Presentation transcript:

UNIT 1 Computing Fundamentals

Unit 1: Computing Fundamentals 1.Hardware and Software 2.Program Development 3.Programming Environment 4.sunfire – a UNIX machine 5.vim – a text editor 6.File transfer CS1010 (AY2015/6 Semester 1)Unit1 - 2© NUS

CS1010 (AY2015/6 Semester 1)Unit1 - 3 Keyboard and mouse (input) Monitor and speaker (output) Houses processor, memory, buses, etc.  Set of instructions to perform tasks to specifications  Programs are software © NUS

CS1010 (AY2015/6 Semester 1)Unit1 - 4© NUS (Computer) Program  Sequence of instructions for a computer to execute Programming languages  Languages for writing programs

Types of Programs CS1010 (AY2015/6 Semester 1)Unit1 - 5 Machine code Assembly code High-level language program © NUS Program to which computer can respond directly. Each instruction is a binary code that corresponds to a native instruction. Eg: Low-level language with strong (generally one-to-one) correspondence between assembly code and machine code instructions. Eg: MIPS (add t1, t2, t3) Detailed knowledge of the machine is not required. High level of abstraction. Ease of writing and understanding. Eg: Java, C, C++, Python. Requires translation

Translation of Programs CS1010 (AY2015/6 Semester 1)Unit1 - 6 High-level language programs (eg: C) cannot be executed directly by the computer Require a translation process called compilation A special program called compiler is used The original C program is called the source code The compiled program is the executable code or machine code In general, executable codes generated on a certain machine cannot be executed on another machine with a different architecture The source code needs to be compiled on the new machine © NUS

The Edit, Compile and Execute Cycle CS1010 (AY2015/6 Semester 1)Unit1 - 7 Compile Execute Edit Process is iterative Use an editor to create/modify the source code Use a compiler to translate the source code into executable Execute/run the executable code © NUS

CS1010 Programming Environment (1/2) CS1010 (AY2015/6 Semester 1)Unit1 - 8 UNIX system – the sunfire server Every SoC student or student taking an SoC programming module can apply for a UNIX account To login to sunfire server, you need your SoC UNIX account user-name and password. If you don’t have a UNIX account yet, go to this link to create one (same link if you have forgotten your UNIX password) : © NUS

CS1010 Programming Environment (2/2) CS1010 (AY2015/6 Semester 1)Unit1 - 9 You can do many things with your sunfire account: Eg: Your account comes with paper quota see for your print quota allocationhttps://docs.comp.nus.edu.sg/node/1732 Some treat their sunfire account as a backup harddisk Refer to SoC Computing Facilities web page for more general information © NUS

CS1020 Intro Workshop - 10 sunfire UNIX server or © NUSCS1010 (AY2015/6 Semester 1)Unit SSH/Xshell are programs to allow users to access a remote host over a network. To download SSH for your home use, go to /2_resources/online.html /2_resources/online.html

Logging into sunfire (1/2) CS1010 (AY2015/6 Semester 1)Unit Click on “Quick Connect” to get the pop-up window. 1.Look for the SSH Secure Shell Client icon or Xshell icon on your desktop, and double click on it. We shall assume you are using the former here. or © NUS Enter “sunfire” for Host Name if connecting within campus or “sunfire.comp.nus.edu.sg” if connecting from off campus Enter your UNIX id as User Name.

Logging into sunfire (1/2) CS1010 (AY2015/6 Semester 1)Unit Click on “Quick Connect” to get the pop-up window. 1.Look for the SSH Secure Shell Client icon or Xshell icon on your desktop, and double click on it. We shall assume you are using the former here. or © NUS Enter “sunfire” for Host Name if connecting within campus or “sunfire.comp.nus.edu.sg” if connecting from off campus Enter your UNIX id as User Name.

Logging into sunfire (1/2) CS1010 (AY2015/6 Semester 1)Unit Click on “Quick Connect” to get the pop-up window. 1.Look for the SSH Secure Shell Client icon or Xshell icon on your desktop, and double click on it. We shall assume you are using the former here. or © NUS Enter “sunfire” for Host Name if connecting within campus or “sunfire.comp.nus.edu.sg” if connecting from off campus Enter your UNIX id as User Name.

Logging into sunfire (2/2) CS1010 (AY2015/6 Semester 1)Unit Enter your UNIX password. 5.To log out from your UNIX account, type “exit” or “logout”. © NUS 4.Once you log in successfully, you will see this screen (actual display may vary).

Change settings in SSH CS1010 (AY2015/6 Semester 1)Unit1 - 15© NUS You may change the settings in SSH (eg: font size, background colour, text colour, etc.) For example, to change background and text colours, click on “Edit”  “Settings” and change the desired settings accordingly.

Trying out some UNIX commands CS1010 (AY2015/6 Semester 1)Unit1 - 16© NUS Type ‘ls’ (list) to list out the files in your directory You see no list because your account is brand new. There are no files in there. Type ‘pwd’ (print working directory) to show the pathname of your current directory An example output: /root/home/h/happytan ls and pwd are just two UNIX commands. UNIX commands are case-sensitive.

File Directories in sunfire (1/2) CS1010 (AY2015/6 Semester 1)Unit1 - 17© NUS /home/h/happytan Check out the pathname of your own home directory by typing ‘pwd’

File Directories in sunfire (2/2) CS1010 (AY2015/6 Semester 1)Unit1 - 18© NUS When you log in, you are automatically placed in your home directory. You are allowed to create/modify/remove files or subdirectories only under your home directory. /home/h/happytan

Setting up your UNIX account CS1010 (AY2015/6 Semester 1)Unit1 - 19© NUS As your new account is currently bare, run the following set-up to configure your account: 1.~cs1010/workshop/setup (enter y when prompted) 2.source.bashrc (no response from the system is good news!) (1) does the following in your home directory Creates a ‘c’ subdirectory and puts a few C programs into the ‘c’ subdirectory Copies a number of system files into the home directory, including.vimrc (vim configuration file) You need to do this only ONCE.

Basic UNIX Commands (1/4) CS1010 (AY2015/6 Semester 1)Unit1 - 20© NUS In UNIX, typically you do a lot of typing but much less mouse clicking, compared with other operating systems like Windows UNIX commands are case sensitive Practice is the best way to recognize UNIX commands. Gradually you will be more and more familiar with UNIX commands – so don’t worry too much at the beginning In sunfire, you can use the up ↑ and down ↓ arrows to select (and optionally modify) a previous command in the command log

Basic UNIX Commands (2/4) CS1010 (AY2015/6 Semester 1)Unit1 - 21© NUS Following the “Getting Started with UNIX and CodeCrunch” document ( your lecturer will go through these basic UNIX commands with you in class. (We will introduce CodeCrunch in the next lesson.) Directory command Description pwdPrint Working Directory lsLiSt files in current directory cdChange Directory mkdirMaKe a subDIRectory rmdirReMove an empty subDIRectory File command Description cpCoPy file mvMoVe file, also to rename file rmReMove file catCATenate file (to view a file)

Basic UNIX Commands (3/4) CS1010 (AY2015/6 Semester 1)Unit1 - 22© NUS Command options Many UNIX commands come with options, preceded by ‘-’ [] ~ $ ls -F /c -F prefixes directory name with / [] ~ $ ls c The plain ls command [] ~ $ ls -l drwx happytan soc Jun 27 12:58 c -l displays info in long format [] ~ $ ls -a....bashrc.vimrc c -a displays hidden files (files beginning with ‘.’ in their names) [] ~ $ ls –al drwx happytan soc Jun 30 08:45. drwxr-xr-x 215 happytan root 8192 Jun 13 12:58.. -rwx happytan soc Jun 27 12:45.bashrc -rwx happytan soc Jun 27 12:45.vimrc drwx happytan soc Jun 27 12:58 c Options may be combined: ls –al or ls –a –l

Basic UNIX Commands (4/4) CS1010 (AY2015/6 Semester 1)Unit1 - 23© NUS Help using man command (‘man’ stands for ‘manual’) Type man command to find out more about a certain command Eg: man ls Press to read next screen, or enter ‘q’ to quit. [] ~ $ cd c [] ~/c $ ls example1.c example2.c example3.c [] ~/c $ cat e  press after typing ‘e’ and observe Filename auto-filling Provides auto-filling of filenames, handy for very long filenames Press for system to fill out the rest of the filename (as much as it can) System managed to fill filename up to ‘example’ and stopped, because there are 3 filenames that begin with ‘example’. Type ‘1’, ‘2’, or ‘3’ and press for system to fill the whole filename, then press.

Editing C source codes (1/3) CS1010 (AY2015/6 Semester 1)Unit1 - 24© NUS We use a text editor to create/modify C programs (source codes) We will use the vim editor Compile Execute Edit produces Source code first.c Editor eg: vim first.c vim is a powerful text editor. It has 2 modes Command mode: for issuing vim commands Insert mode: for typing in text To switch between command mode and insert mode Type i in command mode to get into insert mode Press key in insert mode to get into command mode

Editing C source codes (2/3) CS1010 (AY2015/6 Semester 1)Unit1 - 25© NUS Use vim to create this C program first.c Compile Execute Edit #include int main(void) { int a=27, b=6, c; c = a%b; printf("The value of c is %d.\n", c); return 0; }

Editing C source codes (3/3) CS1010 (AY2015/6 Semester 1)Unit1 - 26© NUS 4 videos on vim are available on IVLE IVLE  CS1010  Multimedia  vim Compile Execute Edit CS1010 “Online” page: Search the Internet

Compiling C programs (1/3) CS1010 (AY2015/6 Semester 1)Unit1 - 27© NUS We use the C compiler gcc in sunfire Compile Execute Edit produces Executable code a.out Compiler eg: gcc first.c Advisable to add the option –Wall (warnings all) for beginners: gcc –Wall first.c If there are compilation errors/warnings, you need to edit the source code first.c again (vim first.c), and re-compile (gcc –Wall first.c), until your code is clear of compilation errors/warnings. Remember to add option ‘-lm’ if your C program uses math functions Example: gcc –Wall –lm example1.c Type ‘ls’ to check that you have the executable code a.out

Compiling C programs (2/3) CS1010 (AY2015/6 Semester 1)Unit1 - 28© NUS The executable file has the default name a.out. However, all filenames in a directory must be unique, hence there can only be one a.out in a directory. Compile Execute Edit Since you have many C source codes in a directory (eg: example1.c, example2.c, example3.c), you might want to have their corresponding executable files all in the same directory, appropriately named. Two approaches: 1.Rename a.out after compilation 2.Indicate the desired name of the executable file during compilation

Compiling C programs (3/3) CS1010 (AY2015/6 Semester 1)Unit1 - 29© NUS 1.Rename a.out after compilation Compile Execute Edit [] ~/c $ gcc –Wall -lm example1.c [] ~/c $ mv a.out example1 [] ~/c $ gcc –Wall example2.c [] ~/c $ mv a.out example2 [] ~/c $ gcc –Wall example3.c [] ~/c $ mv a.out example3 2.Indicate the desired name of the executable file during compilation using the ‘-o’ option Executable files are named example1, example2, example3. [] ~/c $ gcc –Wall –lm example1.c –o example1 [] ~/c $ gcc –Wall example2.c –o example2 [] ~/c $ gcc –Wall example3.c –o example3 Be careful not to overwrite the source code accidentally! The following will replace the source code with the executable file, which is called example1.c now! The source code cannot be recovered! [] ~/c $ gcc –Wall –lm example1.c –o example1.c

Executing C programs CS1010 (AY2015/6 Semester 1)Unit1 - 30© NUS Compile Execute Edit Executing a C program is simple – just type the name of the executable file [] ~/c $ example1 The distance between the 2 points is 3.61 To run the executable file example1: We have gone through the Edit – Compile – Execute process produces Source code first.c Edit eg: vim first.c produces Executable code a.out Compile eg: gcc first.c produces Execute eg: a.out The value of c is 3. Program output

File Transfer (1/2) CS1010 (AY2015/6 Semester 1)Unit1 - 31© NUS To transfer files between your sunfire account and your local computer, click on the SSH Secure File Transfer icon

File Transfer (2/2) CS1010 (AY2015/6 Semester 1)Unit1 - 32© NUS Left: your local machine; right: sunfire Choose the format: ASCII, Binary or Auto Click on file(s) to transfer, and drag to the destination

Using Samba Service (1/2) CS1010 (AY2015/6 Semester 1)Unit1 - 33© NUS Samba service allows you to access your sunfire account directory on Windows when you are connected to the SoC network Enable this service at the following URL Open a command prompt on Windows Click on the Start button Type “cmd” in the search box, and press Enter

Using Samba Service (2/2) CS1010 (AY2015/6 Semester 1)Unit1 - 34© NUS Type in the following command net use \\stusambahost\ Replace with a drive letter of your choice Replace with your UNIX id Example: net use Z: \\stusambahost\happytan Login with your NUSNET account when prompted Username: nusstu\ Password: You will be able to access your sunfire account directory through the specified drive letter in Windows For a detailed user guide, visit

Introductory Workshop CS1010 (AY2015/6 Semester 1)Unit1 - 35© NUS After today’s sectional class, please go through the document ( again and try out the commands yourself. If you think you still need guidance, please attend the Introductory Workshop. Details on registration will be posted on the IVLE forum. Objective: To ensure that ALL students are ready to use the sunfire system, know basic UNIX commands, and able to edit, compile and execute C programs by next sectional class.

Summary CS1010 (AY2015/6 Semester 1)Unit1 - 36© NUS In this unit, you have Familiarised yourself with the programming environment Accessed the sunfire system and learned some basic UNIX commands Used the editor vim to create/modify your C programs Used the compiler gcc to compile your C programs Familiarised yourself with the edit – compile – execute process

End of File CS1010 (AY2015/6 Semester 1)Unit1 - 37© NUS

CS1010 (AY2015/6 Semester 1)Unit1 - 38