Unix. Unix Intro. We use the Unix labs for CSCI213 Your backgrounds and knowledge vary, some of you are: –already Unix proficient, :-) –just starting.

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.
Chapter One The Essence of UNIX.
1 Introduction to UNIX Ke Liu
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.
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.
Linux+ Guide to Linux Certification, Second Edition
Guide To UNIX Using Linux Third Edition
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
What is Unix Prepared by Dr. Bahjat Qazzaz. What is Unix UNIX is a computer operating system. An operating system is the program that – controls all the.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
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.
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.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Lesson 1. PC vs. Multi-user System  Personal Computer – each user gets his/her own processor (or multicore processor).  Multi-user system – The processor,
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.
An Introduction to UNIX System --- Cosc513 Presentation n Instructor: Morteza Anvari n Author: Yonghong Pan n ID#: n Date: Jan.29, 2001.
CENT 305 Information Systems Security Linux Introduction.
UNIX and Shell Programming (06CS36) Unit 1 Continued… Shrinivas R. Mangalwede Department of Computer Science and Engineering K.L.S. Gogte Institute of.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
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.
CS 390 Unix Programming Summer Unix Programming - CS 3902 Course Details Online Information Please check.
Guide to Linux Installation and Administration, 2e1 Chapter 7 The Role of the System Administrator.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
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.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
Chapter 1 : The Linux System Part 2 Lecture 2 11/14/
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.
Basic UNIX Concepts. Why We Need an Operating System (OS) OS interacts with hardware and manages programs. A safe environment for programs to run is required.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
Introduction to UNIX CS 2204 Class meeting 1 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
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.
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.
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.
UNIX U.Y: 1435/1436 H Operating System Concept. What is an Operating System?  The operating system (OS) is the program which starts up when you turn.
Overview of Linux Fall 2016 Dr. Donghyun Kim
Andy Wang Object Oriented Programming in C++ COP 3330
Unix Shells.
C151 Multi-User Operating Systems
Chapter 2: System Structures
The Linux Operating System
Exploring the UNIX File System and File Security
Chapter 2: System Structures
Unix : Introduction and Commands
Chapter Four UNIX File Processing.
Andy Wang Object Oriented Programming in C++ COP 3330
Linux Shell Script Programming
Presentation transcript:

Unix

Unix Intro. We use the Unix labs for CSCI213 Your backgrounds and knowledge vary, some of you are: –already Unix proficient, :-) –just starting Unix in CSCI204 where you will study it in some detail, :-| –only using Unix for CSCI213, :-( So, a minimal intro to Unix Operating System

Unix –origins –organization kernel, libraries, tools and utilities, shell –shell command interpreter, shell scripting language, commands start other programs, some standard program libraries, extensibility –time-share system controls on users

Unix origins 1960s “time shared” computer systems –pioneered at MIT, first useful system developed, –multiple users logged on via terminals systems offers facilities for editing files, compiling code, and running small programs system allocates small amount of time (0.1 second to each user); when time is up, user’s code and data “swapped out” of memory onto fast disk storage allowing another user to run

Unix origins By late 1960s, much more elaborate systems were under construction - with features like shareable code and data segments, multiple levels of security and access control, … Multics project involved work by MIT, GE- Honeywell, ATT labs,...

Unix origins Multics - too costly, too slow, and basically around 1969/1970 it still didn’t work. ATT group split off from Multics They ( Thompson & Ritchie ) wanted a system –run on readily available small machines –specifically intended for small groups of software developers working together on interrelated projects

Unix origins ATT guys idea: –a small core to Operating System (OS) that provides essential facilities –additional functionality to be provided by libraries, –users (all accomplished professional programmers) to provide additional components and tools –want a means to build complex programs by combining simple components

Unix origins ATT approach was novel at the time –write all the OS in a high level language –small, well defined core of essential facilities as “system calls” –make things uniform - same code to work for I/O to disk file, terminal, … –

Unix: first implementations Around 1969/1971, ATT guys did some prototyping on a PDP7 ( 8K words - approx. 20 Kbytes - main memory, small disk ~64Kbytes, Dectapes, single terminal ) using BCPL, B, and early dialects of C. First real implementation for DEC PDP11 computer using C; published around 1973.

Unix –origins –organization kernel, libraries, tools and utilities, shell –shell command interpreter, shell scripting language, commands start other programs, some standard programs, extensibility –time-share system controls on users

Unix: core (kernel) Twenty or so “system calls” –read, write, create, open, link“file” access –fork, exec, exit, brkprocess (program) control –signal, kill, pipe, dupinterprocess communication –… Rather more than 20 now. “chapter 2 of ‘man’ (manual) pages”

Unix libraries stdio –C’s I/O library ( can be used from C++, but iostreams preferred ) makes use of read, write, open, create etc systems calls provides programmer with much higher level facilities - formatted I/O of numbers, strings etc; efficient buffering of I/O,...

Unix libraries stdlib –an assortment! random numbers, malloc and free (the C free storage, “heap”, management functions, can involve OS system calls like brk - request to expand heap) math string See “chapter 3 of ‘man’ pages”

Unix: tools and utilities Little programs –fgrep and grep - programs that search files for occurrences of particular words or patterns of characters –diff - a program to report difference in text files –wc - a program to count number of characters, words, and lines in a text file –In “chapter 1 of ‘man’ pages” along with details of ‘shell’ facilities

Unix shell It is the “shell” that accepts and acts on the commands of a Unix user. When people say they “know how to use Unix” what they usually mean is that they know how to make simple use of a Unix shell ( there are several “shells” that differ slightly, each is someone’s favorite - you will use “sh” by default, many students change this to “bash”, other quite popular shells are “ksh” and “csh” )

Unix shell Shell? Well, it went around the lower levels of Unix –shielding users from low level kernel –shielding low level kernel from users

Unix –origins –organization kernel, libraries, tools and utilities, shell –shell command interpreter, shell scripting language, commands start other programs, some standard program libraries, extensibility –time-share system controls on users

Unix ‘shell’ When working interactively, you have to be able to tell the operating system what program you want to run, and what data it is to use. Original (1960s) time-share systems had simple “command line interpreters” –commands defined by keyword (e.g. EDIT, COMPILE, PRINT, RUN) and took arguments COMPILE CODE=MYPROG OPTIMIZE=3 RUN TIME=20 INPUT=MYDATA OUTPUT=PRINT

Unix ‘shell’ Unix developers wanted something much more sophisticated –handle repetitive tasks (e.g. run program XXX for each data file in a given directory) –use output from one program as input to next –run program X1, if successful continue with program Y1, otherwise print message and run program Z1, –...

Unix shell Unix guys decided that what they basically needed was an interpreter for a slightly simplified “programming language” (based on C) variables (“environment variables”) –loop and test constructs –mechanisms for starting programs and passing “command line arguments” ( this part much the same as commands in earlier operating systems ) –mechanism for putting programs together so output from a program could go to terminal, or to a file, or be used as input for another program

Unix shell The “shell” is an interpreter program. –prompts the user for input –reads the inputs that the user types at a terminal –identifies commands, sorts out arguments and starts appropriate programs –deals with any of the more complex looping and selection constructs available in the shell language

Unix shell Typical use is: –enter a single command ( with arguments as needed ) –wait for shell to process it But: –can set environment variables –can type in a little “shell code” and then have the shell interpret it immediately –write “shell scripts” ( programs in shell language ) and store these in files, these scripts can then be used as extra commands

Unix shell A small number of commands are actually built into the shell interpreter program itself. Most require “shell” to start another program –the programs that you can start with shell commands are mainly kept in a few standard file directories (folders)

Unix shell Command repertoire is easily extended. All those little utilities - grep, wc, … - become commands by simply moving the programs into the standard directories used by shell. You can add your own programs as commands (compiled C, C++, Java, or ‘shell scripts’) - ( you have to note, in an environment variable, details of where you store your extra programs so shell knows where to find them )

Unix shell You can build up special purpose “commands” by using the shell’s facilities to combine simpler commands –e.g. you need to count the number of calls to some function Foo() in a file so you use grep to find the lines with calls to Foo() pass the output from grep to wc which will count the number of lines

Unix –origins –organization kernel, libraries, tools and utilities, shell –shell command interpreter, shell scripting language, commands start other programs, some standard program libraries, extensibility –time-share system controls on users

Unix as a time-share system Unix is intended to be a multi-user system –multiple terminals can be connected –computers have sufficient memory to keep many users’ programs in main memory, ( but some code and data are still “swapped” to/from disk ) –time-slicing applied your program may get up to 0.1 seconds of CPU time, then CPU switches to another user

Unix as a time-shared system All time-shared systems have to have controls on users –users identify themselves (password controlled login) –system keeps track of user-id determines which files can be accessed determines how many programs can be run (you can have several running at same time) determines limits on number of files and total storage used

Unix users Two levels of user: –“root” the system’s administrator (or “guru”) who controls all aspects of Unix use (including users’ passwords, files, programs,..) –everyone else subject to restrictions

Unix users and “groups” Unix also defines “groups” ( remember, Unix meant to help groups of cooperating programmers ) –Individual users can be members of more than one group ( a command changes your effective group ) –Groups members can be given shared access to certain files. –You have a default group ( all undergraduates in same group ). –You may be allocated to extra groups for subjects like CSCI205, CSCI311 and CSCI321,

Unix users Controls on users (and groups) are tied in with the way Unix organizes files. Recorded with every file are details of –owner (user) –group Controls on access to files distinguish user, group, and other (“root” has unrestricted access to all files )

Unix –time-share system controls on users –file system

File system The Unix file system is a little more elaborate than the systems that you are used to on Macs and PCs. There you have: –disk folders on disks –files in folders –folders in folders etc

Unix file system The Unix file system has a similar hierarchical arrangement; –rather than files and folders on disks, its described in terms of a tree structured hierarchy Differences? –Unix file system integrates everything! all mounted disks form part of single hierarchy all devices represented by files,...

/ /tmp /dev/bin/packages/usr/pub Some directories tmp a place for temporary files dev “files” for devices like terminals, disks, etc bin directory where many of simple command programs are kept (‘ binary’ ) packages directory for Sun’s compilers etc pub public files (some general info. etc) usr /usr/bin more shell commands /usr/include “header” files for libraries

Unix file system Each individual user has own directory ( traditionally, individual directories were subtrees of /usr, but more likely your directories will be located in another part of the file system ). Files and directory access –read( for directory this means you can get a list of files it contains ) –write ( change contents of file, add/remove files from directory ) –execute ( access subdirectories, run a file if it’s a program )

Access to files and directories Directory access settings will keep you out of those parts of the file system that you shouldn’t see - most of file hierarchy is actually accessible as Unix traditionally let users explore. Your own directory will have access controls keeping others from seeing your files; files that you create will be created so that only you can read and change them.

Unix –time-share system controls on users –file system –using Unix

You and Unix On Unix, you are represented by –your “home directory” and its subdirectory –entries in a number of system files /etc/password –your user id (e.g. ds01), a unique identifier number used by the system (e.g. 1745), your default group number, your actual name, your “shell”, (but not your password) –When you login, Unix checks your password, notes details of user and group, starts a shell with current directory set to your home directory

Customisation of Environment You can “customise” your Unix environment, –setting things like prompt string –changing directories where shell will look for programs (will have to make some change here relating to use of Java) –… You do this by defining any special features that you want, the definitions go in a file in your home directory named.profile

Communicating with Unix Traditionally, Unix is “text oriented” –all communication in terms of typed commands and textual responses Desktop environments for graphics terminals? –Available, similar to Mac/Windows but usually less complete and less integrated –Generally, have to revert to command line operation for some tasks anyway

Default Unix environment Unix lab has graphics X-terminals –can use “desktop” style environments –default is “FVM2” windowing environment multiple windows –command window (“xterm” window) –textedit (or dtpad) simple unsophisticated editor –…. Popup menu in background, lets you create more of these windows Each xterm window is associated with a running “shell” program accepting commands

xterm $ pwd /home/cs_ug/ds01 $ ls A1 note test.cc $ mkdir JavaStuff $ cd JavaStuff

Not an Xterminal? If you use anything other than a graphics Xterminal (Mac, PC, old text-only terminal, dial-in line, …) –much the same as working with a single “xterm” session on an Xterminal –no access to other programs like textedit

Unix commands You will have to learn at least: –some basic commands commands for moving around file system, copying and moving files commands to display or print files … –use of one (or more) editor programs –use of (limited) on line help facilities on Unix

File system commands directories pwd“print working directory” cdchange directory lslist names of files and subdirectories option -l details of size and access controls for files option -a all files (files starting with “.” not normally shown) … mkdir“new folder”

File system commands files cp copy mv move rm remove (delete) pg page ( display contents of text file one “page” at a time ) cat can be used to display contents of file (like pg) or copy files (like cp) or copy several files into a single output file lp send (text) file to line printer

Information man display manual page for specified topic xman another version of man, may not have information on as many topics, uses a separate window to display details of topics that it knows about netscape (some of Sun documentation as files that you can display using netscape, there is a link from departmental home page to these Sun documents; most of Java documentation is in files best read via netscape)

Editors textedit easy to use, similar to Mac/PC-Windows editor, mouse actions, cut and paste (only works on Xterminals) ed, vi, sed standards for Unix environment, available everywhere (ed and sed are for “hackers”, too cryptic for average user) jove popular editor pico ? Learn jove or textedit for use in labs; if log in remotely, you will need to learn vi, pico, or ed as well

Starting Unix? Login Use commands like pwd, cd ( specify source as one of directories with subject information, e.g. /share/cs- pub/121 ), ls, … Create subdirectories in own home directory (cd, mkdir) Copy some example files into own directory (cp) Print a file (lp)

Starting Unix Look up info on a simple command (e.g. diff, fgrep, time, date, du, …) using man ( some programs don’t have entries in the manual ) Try “elm” (Unix mail system) –“w” and “finger” give information about other users so that you can mail them Try “nn” (news reader) Try “netscape”

Starting Unix Editors –textedit should have no difficulties –jove there is a special program “teachjove” that takes you through a tutorial on the use of this editor –others? Buy a book on Unix!

Working with Unix Plan on a hierarchy of subdirectories –one for each subject, 204, 212, 213, etc –within each subject directory have a subdirectory for each assignment In lab, use multiple xterm sessions –run netscape (viewing Java documentation) –textedit and an xterm window for compiles of Java code –you can close (iconise) windows to clear up screen space