UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Similar documents
Chapter-3. Introduction to Unix: Fundamental Commands

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

EECS2301. Lab 1 Winter 2016

Introduction: What is Unix?

Basic Unix Command. It is used to see the manual of the various command. It helps in selecting the correct options

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Chapter 9. Shell and Kernel

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

Introduction to Unix: Fundamental Commands

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

Welcome to Linux. Lecture 1.1

Perl and R Scripting for Biologists

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

The Online Unix Manual

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

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

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

Unix Handouts. Shantanu N Kulkarni

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

Introduction to Linux

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

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 UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Practical Session 0 Introduction to Linux

Week 2 Lecture 3. Unix

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

Unix Introduction to UNIX

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

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

Computer Systems and Architecture

Linux at the Command Line Don Johnson of BU IS&T

Linux Shell Script. J. K. Mandal

Week 5 Lesson 5 02/28/18

Introduction to Linux

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

Useful Unix Commands Cheat Sheet

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

Introduction of Linux

Introduction to UNIX Shell Exercises

Introduction to Linux. Fundamentals of Computer Science

System Programming. Unix Shells

Computer Architecture Lab 1 (Starting with Linux)

UNIX Essentials Featuring Solaris 10 Op System

Lab Working with Linux Command Line

The Unix Shell & Shell Scripts

Introduction to Linux

CS246 Spring14 Programming Paradigm Notes on Linux

UNIX System Programming Lecture 3: BASH Programming

CST Algonquin College 2

Scripting Languages Course 1. Diana Trandabăț

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

Lab 2: Linux/Unix shell

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

CISC 220 fall 2011, set 1: Linux basics

Computer Systems and Architecture

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

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

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

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

LOG ON TO LINUX AND LOG OFF

2) clear :- It clears the terminal screen. Syntax :- clear

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

Linux & Shell Programming 2014

Introduction to Linux

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

Introduction to Linux Workshop 1

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

UNIX Shell Programming

Name: Peter Lemieszewski Venue: Education

Introduction to Linux

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

ACS Unix (Winter Term, ) Page 21

Exercise 1: Basic Tools

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

Introduction to UNIX I: Command Line 1 / 21

Unix System Architecture, File System, and Shell Commands

Please choose the best answer. More than one answer might be true, but choose the one that is best.

5/20/2007. Touring Essential Programs

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Files

COMS 6100 Class Notes 3

Introduction to Linux

Introduction to Shell Scripting

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

UNIX Basics. UNIX Basics CIS 218 Oakton Community College

Lecture # 2 Introduction to UNIX (Part 2)

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved

CS CS Tutorial 2 2 Winter 2018

Linux Refresher (1) 310/ Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006)

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

Linux Command Line Interface. December 27, 2017

Introduction to Linux

System Programming. Introduction to Unix

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

Transcription:

UNIX COMMANDS AND SHELLS UNIX Programming 2015 Fall by Euiseong Seo

What is a Shell? A system program that allows a user to execute Shell functions (internal commands) Other programs (external commands) Shell scripts A psychic between kernel and users

Various Shell Breeds Bourne shell (sh) Written by Stephen Bourne at AT&T Proposed the concept of pipe, redirection, command substitution, variables, control structures and so on C shell (csh) Written by Bill Joy at UCB Incorporated many new features including C-style control structure and expression grammar, history, editing, aliases, directory stack, tilde notation and so on TENEX C shell (tcsh) Bourne again shell (bash) Being used by most Linux distros and Mac OS X

Command Format Format principle % commandname [arg1] [argn] % means prompt Types of arguments Options n Indication of modes of operations n Prefixed with - or -- (GNU style) Operands n Data to work with n Actual data or file names

UNIX Directory Structures Root Directory Directory Directory home Directory structure Sub-Directory File larry File joe

UNIX Directory Structures

UNIX Directory Structure Directory representation Tree-like structure /directory1/directory2/directory3/ Root directory Root of directory tree / Current working directory (CWD) Where you are currently working in./ Parent directory Parent of CWD../ Home directory For user s personal data ~

Traversing Directories

Shell Built-in Features

Help! help Display information about built-in commands help [-dms] [pattern] Without options, this will display the list of built-in commands Let s do help help RTFM!

Displaying Messages echo Write arguments to standard output echo [-nee] [arg ] Useful for shell scripting printf of shell

Directory Traversing Again pwd Print the name of the current working directory cd Change CWD cd [dir] Default DIR is the value of HOME environment variable

Environment Variables A set of dynamic named values Affect the way running processes will behave A part of operating system environment Examples HOME=/Users/euiseong PWD=/Users/euiseong/Documents/Papers/vbuffer PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin

Set and Unset Environment Variables Set an environment variable export [name[=value] ] [-p] Example n export TEMP=/tmp n export EMERGENCY Unset an environment variable export -n name Example n export -n TEMP Referring to an environment variable $variable_name Example n echo $PATH n export PATH=$PATH:./

Log In and Out Login shell A shell obtained from a connection channel such as terminal, ssh or telnet logout Exit a login shell Returns an error if not executed in a login shell exit Exit the shell Can you tell the difference between logout and exit?

Measuring Time for Processing time pipeline Report time consumed by pipeline s execution

External Commands

Manual Pages man Show manual pages First command to remember man man Layout Name Synopsis Description Example See Also

Directory and File Management ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file...] List of files in a directory -l option shows in the long format cp Copy files or directories cp -r n Recursive operation (for directory copy operations) rm Remove files or directories rm -f n Force operation

Directory and File Management mkdir Make a directory rmdir Remove a directory file Determine file type

Symbolic Links and Hard Links Data and metadata Metadata are what users see In UNIX, an inode entry is a file to a user

Symbolic Links and Hard Links Hard links Links between i-nodes and data blocks If you erase a link, the data will not be removed from disks when there is a remaining link to the data An inode without a link to data is an erased file

Symbolic Links and Hard Links Symbolic links A link between an inode and another inode n Very much like a shortcut n Automatically access Example Data when you access Example1.txt n Useful but problematic n Removal of Example2.txt? n Removal of Example1.txt? n Can form a cycle!

Symbolic Links and Hard Links ln source_file [target_file] Make links -s for symbolic links

Where to Find which program Show the location of a program Search for user-specific $PATH whereis program Show the location of a program Search for hard-coded directory list

Find Files find [options] [-f path] path [expression] Walk a file hierarchy Example n find. -name *hello* n find. -newer main.c

User Profile Management chsh Change user s login shell passwd Change user s login password

Date and Calendar cal Display a calendar and the date of easter date Display or set date and time

Screen Clear clear Clear screen CTRL+L is an alias for clear

Alias alias [name[=value]] A built-in command Make an alias of a command alias rm= rm -rf unalias Erase an alias

String Operations wc Word (or line) count of a file grep Generalized regular expression parser Search a word in a text file grep -r word./* cmp Compare two files Merely tells you whether two files differ diff Compare files line by line diff -rupn original/ new/ > original.patch for Linux patch creation

String Operations patch Apply a diff file to an original patch < patchfile cat [filename] concatenate and print files more (or less) [filename] Read a file page by page head and tail Display first and last lines of a file, respectively

Making Things Work Together

Redirection > < Redirect standard output/error to a file or a file stream to standard input Redirect output to a file ls > result >> Append redirected output to a file ls >> result Redirect a file to a standard input cat < /etc/passwd &> Redirect both input and standard error to a file ls >& /dev/null

Pipeline A set of processes Chained by their standard streams Output of a process feeds directly as input to next one Denoted by symbol Output of a program serves as input of another Combination of simple utilities can do more complex tasks ps A grep usr/local/bin wc -l