Unix Shell Basics Edited from Greg Wilson's "Software Carpentry"

Slides:



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

1 Introduction to UNIX Ke Liu
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
CMPE 151: Network Administration Spring Class Description Focus: system and network administration. Sequence of exercises. E.g., installing/configuring.
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction to UNIX GPS Processing and Analysis with GAMIT/GLOBK/TRACK T. Herring, R. King. M. Floyd – MIT UNAVCO, Boulder - July 8-12, 2013 Directory.
Shell Scripting Basics Arun Sethuraman. What’s a shell? Command line interpreter for Unix Bourne (sh), Bourne-again (bash), C shell (csh, tcsh), etc Handful.
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.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
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.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Content Management Systems …mostly Umbraco ALL ABOUT.
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”
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Unix Basics Chapter 4.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
CENT 305 Information Systems Security Linux Introduction.
Dedan Githae, BecA-ILRI Hub Introduction to Linux / UNIX OS MARI eBioKit Workshop; Nov , 2014.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
March 2, 2005Wah-kai Ngai1 Installation of Geant4 1st HK Simulation Meeting.
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.
Pipes and Filters Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
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.
Files and Directories Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Lecture 24CS311 – Operating Systems 1 1 CS311 – Lecture 24 Outline Final Exam Study Guide Note: These lecture notes are not intended replace your notes.
Chapter 1 : The Linux System Part 2 Lecture 2 11/14/
Unix/Linux for beginners:
Lab 3 + Using the Terminal 1. "Under Linux there are GUIs (graphical user interfaces). where you can point and click and drag, and hopefully get work.
UNIX shell environments CS 2204 Class meeting 4 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
Introduction to Programming Using C An Introduction to Operating Systems.
Chapter 2. Bourne Shell (sh) Use sh instead of bash (Bourne Again Shell), to make your scripts more portable. sh – csh – tcsh - bash.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
1 CS3695/M6-109 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
Linux A practical introduction. 1)Background and Getting Started Linux is an operating system with multiple providers Red Hat/CentOS (our version) Ubuntu.
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.
Operating Systems and Using Linux Courtesy of John Y. Park 1.
Unix Lab Fall Shell Scripting ●Through the shell (LXTerminal) you can: ●Run programs. ●Interact with the file system. ●Change settings. ●Send/receive.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
UNIX  Portable (common to many computer architectures), multitasking, multi-user operating system  Introduced by Bell labs in mid-1960’s  Thus, much.
Overview of Linux Fall 2016 Dr. Donghyun Kim
Introduction to the Command Line for Data Analysts Gus Cavanaugh
Introduction to the Linux Commandline
Jester – The JUnit Test Tester
Welcome to Linux Chap#1 Hanin Abdulrahman.
Andy Wang Object Oriented Programming in C++ COP 3330
Some Linux Commands.
The Command Prompt Commands are the way to “do things” in Unix
The Linux Operating System
Introduction to UNIX Directory structure and navigation
INTRODUCTION TO UNIX: The Shell Command Interface
Basic UNIX OLC Training.
Operating Systems and Using Linux
Lecture #3 Modern OS characteristics
LING 408/508: Computational Techniques for Linguists
Unix : Introduction and Commands
Operating Systems and Using Linux
Andy Wang Object Oriented Programming in C++ COP 3330
Operating Systems and Using Linux
Welcome to Linux Chap#1.
Presentation transcript:

Unix Shell Basics Edited from Greg Wilson's "Software Carpentry"

Introduction Most modern tools have a graphical user interface (GUI) But command-line user interfaces (CLUIs) still have their place Easier to build a simple CLUI than a simple GUI Higher action-to-keystroke ratio Easier to see and understand what the computer is doing on your behalf Which is part of what this course is about Most important: it's easier to combine CLUI tools than GUI tools Small tools, combined in many ways, can be very powerful This lecture focuses on Unix

The Shell The most important command-line tool is the command shellcommand shell Usually just called “the shell” Looks (and works) like an interactive terminal circa 1980 (or cmd in Windows)

Varieties of Shell The shell is just one program among many Many different shells have been written The Bourne shell, called sh, is an ancestor of many of them It's still a lowest common denominator that you can always rely on We'll use bash (the Bourne Again Shell) in this course Even on Windows (thanks to Cygwin)Cygwin Others include C shell (csh), TC shell (tcsh), etc.

Paths Files and Directories are items in the file system A path is a description of how to find something in a file systempath An absolute path describes a location from the root directory downabsolute path  Equivalent to a street address  Always starts with "/"  /home/hpotter is Harry Potter's home directory  /courses/swc/web/lec/shell.html is this file A relative path describes how to find something from some other locationrelative path  Equivalent to saying, “Four blocks north, and seven east”  From /courses/swc, the relative path to this file is web/lec/shell.html

Current Directory Every program (including the shell) has a current working directorycurrent working directory pwd. Every directory has a parent cd.. Every user has a home cd ~

Navigating pwd cd ls

Options ls –F ls –a ls –l ls –l -t

Viewing Files cd /usr/include cat math.h more math.h

Getting help man – the Unix Manual if installed correctly! man ls man more

Grep grep extern math.h grep –v extern math.h

Word Count wc math.h

Doing Instead of Looking cd ~ mkdir mydir cd mydir cp /usr/bin/math.h. ls

Optimization Example Download SimulationApp.class Put in local directory, and run java SimulationApp look in coarse_grid_script runs simulation many many times Too much output to handle!

Redirection coarse_grid_script > result_file /usr/bin/sort result_file /usr/bin/sort –g –k 8 result_file Don’t re-invent the wheel! Don’t code sorting routines into your own code unless absolutely necessary

awk awk '{print $7}' result_file awk '{print $7 $8}' result_file awk '{print $7" "$8}' result_file

Pipes awk '{print $7" "$8}' result_file | /usr/bin/sort -g –k 2 > sorted_outputs

License Copyright © Python Software Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.