Class Introduction. Agenda Syllabus Topics Text etc.

Slides:



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

NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
Linux+ Guide to Linux Certification, Second Edition
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
Linux+ Guide to Linux Certification, Second Edition
CS 497C – Introduction to UNIX Lecture 36: - Customizing the Environment Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
Introduction to Linux/UNIX. History UNIX beginnings in 1969 (Linus Torvalds is born!) AT & T Bell Laboratories (Ken Thompson & Dennis Richie) Working.
Shell Script Examples.
Linux Shell. 2 Linux Command-Line Interface ■ Linux shells: A shell is a command interpreter that allows you to type commands from the keyboard to interact.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Shell The Shell The agency that.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Introduction to Computer Organization & Systems Topics: Intro to UNIX COMP John Barr.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 8 Shell.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
Shell Features CSCI N321 – System and Network Administration Copyright © 2000, 2005 by Scott Orr and the Trustees of Indiana University.
Shells. A program that is an interface between a user at a terminal and the computers resouces ▫The terminal may be real or an emulator The shell is.
Dedan Githae, BecA-ILRI Hub Introduction to Linux / UNIX OS MARI eBioKit Workshop; Nov , 2014.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Linux+ Guide to Linux Certification Chapter Four Exploring Linux Filesystems.
CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
Linux+ Guide to Linux Certification, Third Edition
Basic Shell Scripting - Part 1 Objective - Learn to: Read Start-up Files Edit Start-up Files Modify Your User Environment Communicate with Users Write.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Workbook 6 – Part 2 The Bash Shell
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
CSC 352– Unix Programming, Spring 2015 April 28 A few final commands.
Lesson 2 1.Commands 2.Filename Substitution 3.I/O Redirection 4.Command Grouping 5.Shell Responisibilites Review of the Basics.
Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces.
Introduction to sed. Sed : a “S tream ED itor ” What is Sed ?  A “non-interactive” text editor that is called from the unix command line.  Input text.
UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.
40 Years and Still Rocking the Terminal!
UNIX shell environments CS 2204 Class meeting 4 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
Chapter 5: The Shell The Man in the Middle. In this chapter … The command line Input, output, and redirection Process management Wildcards and expansion.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
Sed. Class Issues vSphere Issues – root only until lab 3.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Linux+ Guide to Linux Certification, Second Edition
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.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
Learning Unix/Linux Based on slides from: Eric Bishop.
Linux Administration Working with the BASH Shell.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
PROGRAMMING THE BASH SHELL PART III by İlker Korkmaz and Kaya Oğuz
Shells.
Introduction to Shells
Shell Features CSCI N321 – System and Network Administration
CSE 303 Concepts and Tools for Software Development
Tutorial of Unix Command & shell scriptS 5027
UNIX and Shell Programming (06CS36)
Basic UNIX OLC Training.
Tutorial of Unix Command & shell scriptS 5027
John Carelli, Instructor Kutztown University
Tutorial of Unix Command & shell scriptS 5027
Unix Talk #2 grep/egrep/fgrep (maybe add more to this one….)
Introduction to Linux/UNIX
Linux Shell Script Programming
CSE 303 Concepts and Tools for Software Development
Introduction to Bash Programming, part 3
LPI Linux Certification
Presentation transcript:

Class Introduction

Agenda Syllabus Topics Text etc

Homework/Lab File Format Word processor on PCs is OpenOffice, use “Save As” to convert to.doc I can read.pdf,.doc,.docx or.odt Please no screen shots in homework, plain text is fine! Assignment says “Provide References”, please do so or it’s points off

Intro To Linux

Unix History Developed at Bell Labs in the late 1960s. First O/S to run on multiple hardware types Original Open Source!

Linux History Written by Linux Torvalds as a free clone of Minix –Used the GNU tool chain with a custom kernel.1 came out in 9/ = 10/1991 Current Stable version: (as of 3/15/2012) content/uploads/unix_family_history_tree_1600x 1200.jpg

Timeline

Linux GUIs KDE = K Desktop Environment –Used QT which wasn’t “free” GNOME = GNU Object Model Environment –Totally “free” desktop environment There are tons of others

CLI CLI = Command Line Interface Typically a shell, much more powerful than a GUI but not near as user-friendly

File System File System Layout

Some Useful Commands ls – lists files cd – change directories cp – copy files mv – move files rm – remove (or delete) files etc, etc, etc

Bash

Acronym for Bourne Again Shell Default for Linux, available for most commercial Unixes. Advanced Bash Scripting: html

What does a shell do? Reads input Breaks input into tokens Use those tokens to create commands Do shell expansion, i.e. parse *,., ?, etc Check for redirection Return an exit status

Basic Token Parsing Typical command: –ls –a -l a* ls is a command -a -l are arguments for the command - = 1 letter arguments -- = human readable arguments a* gets expanded to match all files beginning with a in the current directory

Shell startup Reads the following in order to initialize shell variables: –/etc/profile –/etc/bashrc –Run the first one of these: ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc

Useful Variables HISTSIZE = # of commands stored PWD = the current directory OLDPWD = your old directory PATH = the path that’s searched for commands PS1 = your prompt Access via commands: set or env

Variable Rules Typically UPPERCASE, but don’t have to be No space when asssigning! –VAR=First (works)‏ –VAR = First (does not)‏

Aliases New name for a command, use alias to create, unalias to remove alias rm=“rm –i” – always prompt on rm

Expansion Brace or {} – used to generate lists Tilde or ~ - shorthand for home directory Command or `` - take the output of what’s in the `` and use it Pattern Matching or Regular Expression – foo* match everything that starts with foo

Special Characters \, $, ‘’, “”, `` - are the specials \ (or escape) removes special meaning $ access variables ‘’ means literal output “” means mostly literal output `` stores output from a command

Redirection I/O is typically keyboard/screen, shells allow redirection | means pipe one command to another > is overwrite >> is append < is redirect input << read until tag

Other features Tab completion History Command Line Editing (defaults to emacs, can use vi)‏ Help

Regular Expressions

What are they? A regular expression is a string of characters that matches a pattern of some kind. –000 –01010 –aabbcc –Stuart Usually used with meta-characters

Metacharacters. = match any character exactly 1 time * = match 0 or more characters + = match 1 or more characters ^ = match at start of line $ = match at end of line

Metacharacters II [chars] = match chars in bracket (not PATTERN)‏ [^chars] = ignore chars in bracket (not PATTERN)‏ \ = escape special characters, i.e. \^ | = or choices {this|or|that} {n} = match at least n occurances {n,m} = match at least n but not more than m

Metacharacters III: the examples ^[0-9] – matches lines that start with digits b.d – matches anything with a b followed by any character and a d (such as bad, bed, bid, bcd)‏ [a-z] – matches any lower case letter [a-zA-Z] – matches any letter [a-z]\{1,3\} – matches any string of 1 to 3 letters (ask, eee, q, be, bet, etc)‏ [tT][iI][fF]\{1,2\} – matches a t or T followed by an i or I followed by 1 or 2 f or Fs [a-z]\{3\}|[A-Z]\{3\} – matches any three letters as long as all three are upper case or lower case

RegExp and ls Can’t use ^, { }, +, or $, but most everything else works –ls *[0-9]* = match files with 0-9 in name. means match., not a single character!

grep

RegExp and grep grep = Grab REgular exPressions 4 different versions on Linux: –grep – limited regexp set –egrep – largest regexp set (also grep –E)‏ –rgrep – recursive grep (also grep -r) –fgrep (fast grep) – very limited regexp set metacharacters ( $, *, [, ^, |, (, ), \ ) translated literally!

Uses for grep Your company just got bought. How many files have the old company in them on the web server? What’s a 7 letter word for “Queens of Russia that starts with ts and ends with an a? How many files got changed in August of last year?

Useful grep arguments -c = shows a count of matches in the file(s)‏ -n = shows what lines the matches are on -l = just file names -v – negate the search -i – ignore case

More useful grep arguments --color=# - display in color –# = always, color, none

Advanced grep arguments -A, -B, -C = context to search –-A # = # lines after –-B # = # lines before –-C # = # lines around --regexp=PATTERN = Use PATTERN as the pattern; useful to protect patterns beginning with -.

Finding Words \< = blank space at beginning of word \> = blank space at end of word -w = find word, has to have white space