Lesson 1. PC vs. Multi-user System  Personal Computer – each user gets his/her own processor (or multicore processor).  Multi-user system – The processor,

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

Jump to first page Unix Commands Monica Stoica Jump to first page Introduction to Unix n Unix was born in 1969 at Bell Laboratories, a research subdivision.
1 Introduction to UNIX Ke Liu
©Colin Jamison 2004 Introduction to Linux Colin Jamison.
Exploring the UNIX File System and File Security
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.
Information Networking Security and Assurance Lab National Chung Cheng University 1 What Linux is? Free Unix Like Open Source Network operating system.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Unix Basics. Systems Programming: Unix Basics 2 Unix Basics  Unix directories  Important Unix file commands  File and Directory Access Rights through.
Basic UNIX © McGraw Hill All rights reserved.
1 Some basic Unix commands u Understand the concept of loggin into and out of a Unix shell u Interact with the system in a basic way through keyboard and.
Systems Programming Concepts
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Guide To UNIX Using Linux Fourth Edition
Overview of Linux CS3530 Spring 2014 Dr. José M. Garrido Department of Computer Science.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
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”
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
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.
CHAPTER 1 UNIX FOR NONPROGRAMMERS By U ğ ur Halıcı.
Introduction to Unix Bent Thomsen Institut for Datalogi Aalborg Universitet.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Unix Basics Chapter 4.
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
1 N305 C Programming. 2 Objectives for the Lab ä Learn problem solving strategies ä Achieve intermediate knowledge of C Programming Language ä Gain experience.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
CS240 Computer Science II Introduction the Unix File System and File Related Utilities Based on “UNIX for Programmers and Users” by G.Class and K. Ables.
Chapter Two Exploring the UNIX File System and File Security.
Natawut NupairojAssembly Language1 Unix Survival Guide.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
Guide to Linux Installation and Administration, 2e1 Chapter 7 The Role of the System Administrator.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Reading None.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Chapter Two Exploring the UNIX File System and File Security.
Welcome to CS323 Operating System lab 1 TA: Nouf Al-Harbi NoufNaief.net.
1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem.
Introduction to Programming Using C An Introduction to Operating Systems.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
Linux Commands C151 Multi-User Operating Systems.
2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
A Mini UNIX Tutorial. What’s UNIX?  An operating system run on many servers/workstations  Invented by AT&T Bell Labs in late 60’s  There are many different.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
Operating Systems and Using Linux Courtesy of John Y. Park 1.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
Agenda The Linux File System (chapter 4 in text) Directory Structures / Navigation Terminology File Naming Rules Relative vs Absolute pathnames Unix Commands:
Overview of Linux Fall 2016 Dr. Donghyun Kim
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.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
CSE 374 Programming Concepts & Tools
Introduction to UNIX.
Exploring the UNIX File System and File Security
Web Programming Essentials:
Chapter Four UNIX File Processing.
Introduction Paul Flynn
Linux Shell Script Programming
January 26th, 2004 Class Meeting 2
Presentation transcript:

Lesson 1

PC vs. Multi-user System  Personal Computer – each user gets his/her own processor (or multicore processor).  Multi-user system – The processor, RAM, disk, and i/o devices are shared among several users. This can be accomplished through: multitasking timesharing

What is an Operating System? An OS is software (i.e. a computer program) that manages your computer. Its main jobs are:  Manage software  Enable interaction with a user  Control peripherals (e.g. disk, printer)

What is UNIX? Unix is an operating system for multi-user systems.  Developed originally at Bell Labs in 1969 by Thompson and Ritchie.  It is an Open System (no single company owns it).  It is portable – it can be installed on different types of machines.

Main components of UNIX OS:  Kernel. Master control program of the computer. In charge of managing resources and multitasking.  File System. Data is stored in files, which are organized in directories.  Shell. Accepts user commands and passes them on to the Kernel.  Utilities. These are the commands that UNIX understands.

Review: Jobs of an OS  Manage software…. Kernel.  Interact with User…. Shell (using utilities).  Control peripherals…. all peripherals are part of the UNIX File System. In summary: You type a “utility” into the UNIX Shell, which gets passed to the Kernel for processing.

Your UNIX Account  Since many users share one large disk, each user is given a “piece” of the disk, called an account.  Each part of the disk has permissions associated with it. You will have permission to view only your own files.  In order to work in your account, you will login with a username and password. (to be done before our next class.)

Shell Utilities % date % who % whoami % mail % pine (see chapter 20 of text for more mail details) % man

The UNIX File System (ch. 6)  The File System is used to organize data. In UNIX, anything from which data can be taken/sent is called a file. ordinary file on disk printer keyboard  Ordinary files are either of type: text – each character is stored as its ASCII value. binary – to be read only by computer.

Directories  A directory in UNIX corresponds to a Folder in Windows (a place on the disk that can hold files and directories).  When you are logged in to your account, you are always in some directory. That is called the current directory.  Your “home” directory is the directory that you are in by default each time you login.

Directory Tree  Directories have a hierarchical structure, represented by a Directory TREE. root / bin dev etc home tmp users1 ……. sokol …...

root / bin dev etc home tmp users1 ……. sokol …... courses forms papers CIS15 CIS23 CIS52 syllabus.htm hmwk1.htm

Pathnames  A pathname is the address of a file or directory. It is the path of the file (or directory) in the Directory Tree.  An absolute pathname is the path from the root to the specified file. e.g. /users1/sokol/courses/CIS15/syllabus.htm / represents the ROOT Note: in Windows, the backslash \ is used to separate levels of the tree. All web addressed, i.e. URL’s, use the forward slash as in UNIX.

Relative Pathname  A relative pathname is the path in the directory tree beginning with the “current directory.” e.g. Suppose I am working in my home directory. I can refer to syllabus.htm as: courses/CIS15/syllabus.htm Or, if my current directory is CIS15, I can simply say syllabus.htm

Naming Files and Directories  You do not have to use filename extensions, although you can if you wish. e.g. notes.txt myprogram.cpp  UNIX is CASE SENSITIVE!  Do NOT use spaces and special characters in your filenames (although. _, are allowed).

Some Shell Commands  pwd prints working (or current) directory  cd change directory [without arguments this brings you to home directory]  ls lists files in current directory Many commands take options. Example: ls –la detailed list, and includes hidden files, which are those whose name begins with a. (e.g..profile,.login)

How can you create a file? 1. Copy or move another file 2. Redirect standard output 3. Use a Text Editor 4. Computer program writes to a file cp pathname1 pathname2 mv pathname1 pathname2

2. Redirection  You can redirect the output of a command: e.g. ls > mylist spell > sperrs “funnels” the output to a file instead of screen.  > erases file if it exists  >> concatenates to end of existing file

3. Text Editor  emacs  vi  pico Choose one of these and learn it since you have to be able to type up a text file in UNIX.

4. Computer program We will cover files in C++ in detail (Chapter 12 of text) so stay tuned…

Permissions The permissions of each file and directory can be viewed as a sequence of 10 bits. d stands for directory r read permission w write permission x execute permission drwxrwxrwx owner group public

Changing Permissions  Your web page has to grant read and execute access to the public.  How can you change permissions? use the chmod command examples: chmod public_html chmod 711 public_html chmod a=rx mypage.html chmod a+r mp.html

More shell utilities for File Management  cat  more  less  pg  lpr  rm  mkdir  rmdir

Pipes  You can send the output of one utility to the input of another utility using | example: cat pgm1 | more who | sort (note: redirection using > sends to a FILE, piping sends to another command.) Use the ; to group commands. example: ls; who; cd

The grep Command grep will search for a word inside of files or directories. It is extremely useful example grep December pgm1.cpp [this will list every occurrence of December in the file pgm1.cpp] OR grep December pgm*.cpp [this searches all files that begin with pgm and end with.cpp]

Wildcard character (*) Other examples of using the * ls *.cpp // this lists all of your.cpp programs that are in the current directory. cp *.output outfiles // copies all files ending with.output into a directory called outfiles

Processes (ch 11)  Since UNIX is a multitasking system, a single user can also run several processes at once.  You can either open different windows or you can run a process in the “background.” For example: %netscape & This will open netscape but give you the shell prompt back in your window.

Processes  If you would like to see a list of all your active processes, use the command. Example: % ps PID TTY TIME CMD pts/11 00:00:00 ksh pts/11 00:00:00 tcsh pts/11 00:00:00 ps If you want to terminate a process: % kill 25177

Processes (cont)  If a process is running in the foreground, and you want to kill it: ^ C (Ctrl+C)  To suspend a process, use: ^ Z (Ctrl+Z) To resume the suspended process: % fg (for a foreground job) % bg (for a background job)

Symbols ~ /... & * > >> |

Programming under UNIX (ch32)  1 st level language = machine language (a binary sequence of 0’s and 1’s)  2 nd level language = assembly language Here, you can use English-like statements to represent machine level instructions. So, 1 assembly language instruction corresponds to one machine instruction.  3 rd level or “High” level languages easier to program portable

Program Translation Your high-level language program must be translated into machine language in order for it to be able to run. This is a 3 step process. 1. Preprocessing 2. Compilation 3. Linkage

1. Preprocessing  A preprocessor reads through your program and replaces all preprocessor directives.  A preprocessor directive is any line that begins with a # e.g. #include  Notice that preprocessor directives are not C++ statements, and therefore do not terminate in a ;

2. Compile  Compiling a program consists of translating a high level language to machine language, called object code.  Object code is NOT executable yet… To compile your C++ program, type: % g++ -c mypgm.cpp or % CC –c mypgm.cpp NOTE: the –c option says to only compile. The CC are capital (lowercase cc is for C).

Compiling in UNIX  When you compile your program, the compilation errors will display on the screen.  You should open your program in a different window to correct the mistakes.  If there are no compilation errors, a file called mypgm.o will be created. This is the object code of your program.

3. Linking There is still one more step to obtain your executable. It is called “linking.” Linking brings together all library functions that you included, all of your own functions, and your main function and an executable file is created. % g++ mypgm.o The same command is used for linking. [You can have linker errors, such as a function that is not found, or no main function, or multiply defined main’s.]

Running your program The output of the linker is an executable file called: a.out You can check that it has executable permission by typing _________. To run your program: % a.out Output will display on the screen. % a.out > myoutputfile Redirects your output to a file.

Compiling and Linking in 1 step You can invoke g++ to compile and link together, but this will be useful only for small programs. % g++ mypgm.cpp This will first compile and then link. Errors are labeled either as compiler or as linker errors.