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

Similar documents
Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Perl and R Scripting for Biologists

Introduction to Linux

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

Introduction to Unix: Fundamental Commands

Introduction to Linux

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Chapter-3. Introduction to Unix: Fundamental Commands

CSCI 2132 Software Development. Lecture 4: Files and Directories

commandname flags arguments

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

EECS2301. Lab 1 Winter 2016

The UNIX Operating System. HORT Lecture 2 Instructor: Kranthi Varala

5/20/2007. Touring Essential Programs

INTRODUCTION TO LINUX

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

Linux Systems Administration Getting Started with Linux

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you.

Computer Systems and Architecture

Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny.

Unix System Architecture, File System, and Shell Commands

Mills HPC Tutorial Series. Linux Basics I

CS197U: A Hands on Introduction to Unix

Overview of the UNIX File System. Navigating and Viewing Directories

Overview of the UNIX File System

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

Introduction to Linux

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Lecture 2: The file system

UNIX Concepts COMPSCI 386

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

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

Working With Unix. Scott A. Handley* September 15, *Adapted from UNIX introduction material created by Dr. Julian Catchen

Introduction to Linux. Roman Cheplyaka

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Filesystem Hierarchy and Permissions

Introduction to Linux

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Linux Essentials. Smith, Roderick W. Table of Contents ISBN-13: Introduction xvii. Chapter 1 Selecting an Operating System 1

Essentials for Scientific Computing: Bash Shell Scripting Day 3

Manage Directories and Files in Linux. Objectives. Understand the Filesystem Hierarchy Standard (FHS)

Lec 1 add-on: Linux Intro

The Unix Shell & Shell Scripts

UNIX System Programming Lecture 3: BASH Programming

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

Introduction Into Linux Lecture 1 Johannes Werner WS 2017

Introduction: What is Unix?

Introduction to UNIX command-line

Introduction to Linux

Filesystem and common commands

Files

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE

CSE 390a Lecture 2. Exploring Shell Commands, Streams, and Redirection

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

Part I. UNIX Workshop Series: Quick-Start

Filesystem Hierarchy and Permissions

Files and Directories

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

File System Hierarchy Standard (FHS)

5/8/2012. Creating and Changing Directories Chapter 7

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

Week 5 Lesson 5 02/28/18

Introduction of Linux

Basics of Linux, gnuplot, C

CS197U: A Hands on Introduction to Unix

Linux for Beginners. Windows users should download putty or bitvise:

A Brief Introduction to Unix

The landscape. File hierarchy overview. A tree structure of directories The directory tree is standardized. But varies slightly among distributions

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Caja File Manager. Desktop User Guide

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

1 Installation (briefly)

Introduction To Linux. Rob Thomas - ACRC

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

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

Unix Workshop Aug 2014

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

Scripting Languages Course 1. Diana Trandabăț

Review of Fundamentals

Computer Systems and Architecture

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Introduction to the Linux Command Line

GNU/Linux: An Essential Guide for Students Undertaking BLOSSOM

Bash Shell Programming Helps

Introduction to Linux

Linux Command Line Interface. December 27, 2017

Basic Survival UNIX.

Chapter 1 - Introduction. September 8, 2016

Getting your department account

A shell can be used in one of two ways:

Getting Started with Linux

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

Session 1: Accessing MUGrid and Command Line Basics

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

Chapter 02 Linux Installation and Usage

h/w m/c Kernel shell Application s/w user

Transcription:

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

Generic computer architecture Memory Storage Fig. 1.2 From Designing Embedded Hardware, 2 nd Ed. by John Catsoulis

OS concepts Shell interprets typed commands GUI interprets mouse! and keyboard events Applications Excel, R, Perl scripts Operating system (e.g. Linux, Unix, MacOS The file system Devices e.g. Keyboard, printer screen, ethernet, mouse, etc. Processes e.g. editors, word processors, spreadsheets, scripts, etc.

The Operating System (OS) orchestrates and coordinates computing on the machine n Unix n Linux n OS X, MacOS n Windows n CPM

Unix Phylogeny

Essential unix (operating system) concepts 1. A process Everything that runs under unix is a process, e.g. commands, spreadsheets, terminal windows, etc. Relevant commands: ps, top 2. A file & the hierarchical file system directories(folders), data files, applications. On the disk, everything is a file. Even directories! Files are not processes! Relevant commands: ls, df 3. A shell A shell is a process. The shell accepts command lines and feed them to the unix kernel. Command lines consist of commands or programs to execute along with information needed to execute them

Processes What processes am I running from my shells?! ps What processes is everyone running from shells?! ps -a What processes of all kinds are running?! ps -ax Which processes are using the most cpu?! top

File system concepts

The hierarchical file system / The file system is a tree bin boot dev etc home2 home lib mnt opt proc root sbin tmp usr var vmlinux 140.636F08 faculty public bin local fernando stu08-00 stu08-01 stu08-02 Stu08-03 public_html private_html example.txt /home2/140.636f08/stu08-00/private_html

Navigating the hierarchical file system 1. Navigation commands n ls -- list directory contents n pwd -- prints the absolute path to the working directory n cd -- change directory to a directory specified by a path n df -- free disk space n du -- disk usage statistics 2. Paths n Absolute path n n A fully qualified path must be specified from the root directory / is the symbol for the root directory n n Relative path n Always defined relative to the working directory n. is the symbol that means the working directory n.. is the symbol that means the directory above the working directory Executing an executable that resides in the current working directory n./filename

Review: commands to get around the file system n pwd the command that tells you where you are, i.e. print working directory n ls the command that lists the contents! of the current directory n cd the command that changes the! current directory. In other words! it is how you move around the! file system Memorize these three navigation commands or die!

Files permissions n to see what permissions a file has use ls command with -l option: n ls -l filename filetype user read write execute group read write execute other read write execute d r w x r - x r - x n to change file permissions use the chmod command (see linux quickstart notes)

Basic Bash shell commands

n n n n Commands simple commands n examples: clear, cd, ls, man, wc n Syntax: command [options] parameters! Options n An option is a way of telling Linux to perform a command in a particular way (like pressing alt-key while clicking a mouse) n Typically a minus sign followed by one or more characters! and sometimes an argument! Parameters n Often filenames or arguments for the command! Wildcards n used to represent filenames n? matches any single character n * matches any number of characters

some example commands wc helloworld.pl wc -l helloworld.pl wc -l *.pl ls *.*

On-line help for commands n man command n command -help n apropos keywords

Standard input & output two very important Unix concepts that you absolutely must understand

! Standard I/O n Commands are processes, so they have a default standard input and a default standard output!!! standard input process standard output n For commands executed in shell window: n n standard input is connected to the keyboard standard output is connected to the screen STDIN shell process STDOUT Keyboard device graphics device

When you invoke the Perl interpreter it is a process! STDIN perl process STDOUT Keyboard device graphics device

Redirection and pipes two more very important and related ideas that you absolutely must understand

Standard i/o streams can be Redirected n The standard output of a command can be redirected to a file by the > redirector ls -l > results.txt ls -l STDIN ls process STDOUT Storage device graphics device results.txt file

Standard i/o streams can be Redirected n a file can be redirected to the standard input of a command by the < redirector. wc -l < results.txt wc -l results.txt STDIN wc process STDOUT Keyboard device file graphics device

a pipeline of processes process1 STDOUT STDIN process2 STDOUT STDIN process3 file1.txt file2.txt

a pipeline of processes! (without the intermediate files) process1 STDOUT STDIN process2 STDOUT STDIN process3

Pipes The standard output stream of one command can be piped to the standard input of another command by using the pipe symbol. No intermediate file is required. Example: What does this do? ls -l wc -l ls -l STDOUT STDIN wc -l

Let s use perl to illustrate pipes! 1 st recall that the Perl interpreter is a process STDIN perl process STDOUT Keyboard device graphics device In the shell start the perl interpreter and feed it a text file of perl statements (examine the file of perl statements) perl helloworld.txt In the shell start the perl interpreter and feed it another text file of perl statements (examine the file of perl statements) perl helloperl.txt

What does this command line do? perl hello.txt perl helloperl.txt perl process perl STDOUT STDIN STDIN STDOUT process demo

Execution of unix commands and scripts

How the shell executes commands and applications 1. If the shell does not recognize the command name as one of it s built-in commands, it starts a search for an executable file with the same name. 2. An executable file is either an application binary or a special kind of text file called a script 3. The shell searches through all the directories on the disk specified by the PATH shell variable (demo) 4. And executes the first executable that it finds with the specified name. 5. The file must have execute permission in order to be executed, otherwise you will see a permission error

How the shell executes a script 1. If the executable is a text file, the shell treats it as a script. A script must have a special first line 1. The first line must start with #!, the rest of the first line is the path to an executable 2. The executable is launched 3. The file itself is passed to the standard input (STDIN) of the the executable. 2. Examples helloworld.pl helloperl.pl

Equivalent command lines perl hello.txt perl helloperl.txt./helloworld.pl./helloperl.pl Perl scripts are the standard way of invoking the perl interpreter. You almost never see perl invoked by hand, we did it just to illustrate what is going on under the hood.