Operating System Interaction via bash

Similar documents
Part I. UNIX Workshop Series: Quick-Start

Introduction to Unix

Examples: Directory pathname: File pathname: /home/username/ics124/assignments/ /home/username/ops224/assignments/assn1.txt

Principles of Bioinformatics. BIO540/STA569/CSI660 Fall 2010

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

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

Introduction to Unix and Linux. Workshop 1: Directories and Files

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

Unix Tutorial Haverford Astronomy 2014/2015

Session 1: Accessing MUGrid and Command Line Basics

Introduction to Linux Workshop 1

Mills HPC Tutorial Series. Linux Basics I

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

Introduction to Linux. Fundamentals of Computer Science

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois

Helsinki 19 Jan Practical course in genome bioinformatics DAY 0

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

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

Using the Zoo Workstations

User Guide Version 2.0

Introduction to Unix

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

Introduction to Linux

A Brief Introduction to the Linux Shell for Data Science

1 Getting Started with Linux.

CS 143A. Principles of Operating Systems. Instructor : Prof. Anton Burtsev

15-122: Principles of Imperative Computation

1. Open VirtualBox and start your linux VM. Boot the machine and log in with the user account you created in Lab #1. Open the Terminal application.

Introduction to Linux Spring 2014, Section 02, Lecture 3 Jason Tang

Operating Systems, Unix Files and Commands SEEM

The Command Shell. Fundamentals of Computer Science

Introduction to Unix: Fundamental Commands

CISC 220 fall 2011, set 1: Linux basics

Introduction. File System. Note. Achtung!

Using Ruby and irb in CSE 341 Winter 2015

CS CS Tutorial 2 2 Winter 2018

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

Getting Started with Command Prompts

Command Line Interface The basics

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Linux/Cygwin Practice Computer Architecture

Chapter-3. Introduction to Unix: Fundamental Commands

Scripting Languages Course 1. Diana Trandabăț

CS Fundamentals of Programming II Fall Very Basic UNIX

Essential Linux Shell Commands

Shell Programming Overview

About shells and command lines

Short Read Sequencing Analysis Workshop

Week 2 Lecture 3. Unix

Overview of the UNIX File System

Essentials for Scientific Computing: Bash Shell Scripting Day 3

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Introduction: What is Unix?

12.1 UNDERSTANDING UNIX SHELL PROGRAMMING LANGUAGE: AN INTRODUCTION Writing a Simple Script Executing a Script

Lab: Supplying Inputs to Programs

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

Unix basics exercise MBV-INFX410

COMS 6100 Class Notes 3

LAB #5 Intro to Linux and Python on ENGR

PROGRAMMAZIONE I A.A. 2015/2016

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

Physics REU Unix Tutorial

Overview of the UNIX File System. Navigating and Viewing Directories

Introduction to Network Operating Systems

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

Setting up my Dev Environment ECS 030

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

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

EKT332 COMPUTER NETWORK

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Remote Access to Unix Machines

Unix. Examples: OS X and Ubuntu

Getting Started With UNIX Lab Exercises

DATA 301 Introduction to Data Analytics Command Line. Dr. Ramon Lawrence University of British Columbia Okanagan

Why learn the Command Line? The command line is the text interface to the computer. DATA 301 Introduction to Data Analytics Command Line

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

INSE Lab 1 Introduction to UNIX Fall 2017

Introduction to Linux and Supercomputers

You can use the WinSCP program to load or copy (FTP) files from your computer onto the Codd server.

ENCM 339 Fall 2017: Editing and Running Programs in the Lab

Operating systems fundamentals - B02

UNIT 9 Introduction to Linux and Ubuntu

Introduction to the Linux Command Line

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Introduction. SSH Secure Shell Client 1

UNIX, GNU/Linux and simple tools for data manipulation

COSC UNIX. Textbook. Grading Scheme

Linux Introduction Martin Dahlö Valentin Georgiev

Introduction to UNIX command-line

The Directory Structure

Tutorial 1: Unix Basics

Working with Basic Linux. Daniel Balagué

Editors in Unix come in two general flavours:

Once you have installed MobaXterm, open MobaXterm. Go to Sessions -> New Session, and click on the SSH icon.

Lab Working with Linux Command Line

Chapter 4. Unix Tutorial. Unix Shell

Transcription:

Operating System Interaction via bash bash, or the Bourne-Again Shell, is a popular operating system shell that is used by many platforms bash uses the command line interaction style generally accepted as appropriate for advanced operating system use (i.e., efficiency over learnability) While bash is primarily associated with Unix-derived operating systems, there are bash implementations for other platforms, such as Cygwin for Windows Accessing bash (or Other Command-Style Shells) One can access bash, or any other operating system shell that uses the command line interaction style, in many ways: Operating systems that start up with a GUI shell typically have a terminal or console application that automatically runs bash inside a window Text-only operating systems usually run the commandstyle shell upon user login Text-based network connections like ssh also run the command-style shell upon [remote] user login

Anatomy of a Command Line Invocation 1. The computer indicates that it is ready for the next command (via a prompt) 2. The user (you) type in a command The arrow, backspace, and other keys (you d be surprised how many) can be used to edit what has been typed so far To completely start over, hold down the control or ctrl key then hit c (i.e., control-c ); this results in a fresh prompt When the command is fully specified, hit the Enter or Return key 3. The computer performs the command, showing you the result of that command 4. Rinse and repeat For Your Convenience: History and Autocomplete The command history keeps track of the commands that you have typed: Vertical arrow keys navigate through the history Backspace or the horizontal arrow keys stop at the current command and permit editing control-r triggers a history search; the history command displays the history itself, with each command assigned to some sequential number The tab key triggers autocomplete: When there is only one valid possibility, bash spells everything out for you With multiple choices, the first tab will do nothing (though on some systems you may hear a beep); hitting tab a second time will display these possibilities You can repeatedly type a few letters, then hit tab, until there is only one choice and that choice appears fully spelled-out on the command line

Command Discovery via Autocomplete The exit command ends your bash session You can use autocomplete to explore other available commands that start with ex first, type just ex, then, as stated previously, press tab twice; you should now see the other commands that start with ex Next, type i so that your partial command now reads exi, then press tab twice again; note how the list has either narrowed down, or resulted in spelling exit outright, since no other command starts with exi Command Discovery via man Most Unix-derived operating systems come with detailed, text-based documentation, accessible via the man command (short for manual) Invoking man k <keyword> will search for manual pages that match the given keyword Each manual page has a title (typically the name of the command); invoke man <command> to display its page Use space and b move forward and backward; q quits Yes, man man works; so does man bash and many more!

Navigating the File System A major component of our interaction with an operating system has to do with navigating its file system(s) typically, this is a hierarchical organization of files (i.e., individual sequences of bytes) and folders or directories (i.e., files that contain additional files) GUI shells usually display the file system in a window, with some indicator for the current folder and its position within the hierarchy On a command line, this concept is represented with a string called the working directory pwd, or print working directory, displays the working directory: folders/directories are separated or delimited with an OS-defined separator symbol / ( forward slash ) on most Unix derivatives; \ ( backslash ) on Windows The original Mac OS used the colon (:), and Mac OS X remains aware of this (try it) cd <directory> will change directory to directory, which can be specified in different ways Absolute paths, specified by using the file separator as their first character, start from the very top (or root) of the file system Relative paths start from the working directory Special shortcuts include. for the current directory,.. for the previous directory, ~ for your home directory, and ~<username> for username s home directory (see below) Yes, autocomplete via tab works with cd When bash first starts, the working directory is initialized to your user s home directory a folder designated specifically for your files and documents

Listing Files in a Directory The ls (list files) command displays the files in the working directory There are many ways to display a file list; current GUI shells typically offer view options or something similar On the command line, variations such as these are specified using command line parameters or switches By convention, these switches start with one or two dashes (-, --) followed by a keyword; non-boolean parameters also expect some value (e.g., --width=40) Recommendation: Use ls -F for your typical ls invocation; this appends a file type indicator (* = executable, / = directory, @ = link, etc.) to the filenames in the list The last argument to ls, if not a documented switch, is essentially what to list Like cd, you can specify a directory to list, using the same absolute, relative, or shortcut notation described previously In what you should now be noting as a recurring theme, tab autocompletion will work for this last what to list parameter Beyond cd, you can also specify filenames or filename filters, using * as wildcards; other filter variations are also available You d be surprised at what else you can get ls to do or display practice your man reading skills by invoking man ls and looking at what s available

Distinguishing the Shell from the Programs It Runs As seen, command line interaction is conceptually simple on the surface: type a command; look at the response; rinse and repeat Delving deeper, however, note that some commands are intrinsic to the shell, while others are simply invocations of programs that are on the system Fortunately, there s an easy way to tell: you can use which <command> or locate <command> if these command produce the path to a file, then that command is actually an executable program An exercise: Can you tell which of the commands described so far are actually executable programs in the operating system? A follow-up question, once you ve gotten a good idea of which commands are implemented internally by bash vs. which ones are actually external, executable programs: What do you think determines whether or not a command should be implemented within a shell as opposed to an external program? One of these internal commands is particularly tricky on some systems, there is, in fact, an executable version of this command; rest assured, though, that bash does not run that program, instead implementing its functionality internally and with good reason