Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.

Slides:



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

Lecture 4 Shell environment III: - command alias & history; - job control; - editor (vim) CSE4251 The Unix Programming Environment 1.
Introduction to Unix – CS 21 Lecture 10. Lecture Overview Midterm questions Jobs and processes description The foreground and background Controlling jobs.
1 Introduction to UNIX Ke Liu
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Introduction to Unix – CS 21 Lecture 5. Lecture Overview Lab Review Useful commands that will illustrate today’s lecture Streams of input and output File.
Introduction to Linux and Shell Scripting Jacob Chan.
Linux Commands LINUX COMMANDS.
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.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Introduction to Shell Script Programming
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Chapter 6: Shell Programming
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
CS 2061 Shells Also known as: Unix Command Interpreter.
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
Shell Programming. Introducing UNIX Shells  Shell is also a programming language and provides various features like variables, branching, looping and.
Introduction to Unix – CS 21 Lecture 8. Lecture Overview More detail on emacs and vi Regular expression matching in emacs and vi.
Introduction to Unix Shell & Scripting with csh/tcsh  Brief Unix History  Unix Shell & Flavor  CSH/TCSH Scripts.
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.
L&T Infotech1 UNIX – Getting Started - Aneesh Ramani.
ITR3 lecture 6: intoduction to UNIX Thomas Krichel
INFO 320 Server Technology I Week 5 Shell environments and scripting 1INFO 320 week 5.
Unix Shell Environments February 23rd, 2004 Class Meeting 6.
UNIX shell environments CS 2204 Class meeting 6 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
UNIX shell environments CS 2204 Class meeting 4 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
CSC414 “Introduction to UNIX/ Linux” Lecture 5. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Customizing the Shell Environment. UNIX Shells Two characteristics of shells –Interactive: prompts ($) and waits for your response/requests –Noninteractive:
Chapter Six Introduction to Shell Script Programming.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
Linux Commands C151 Multi-User Operating Systems.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
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.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Introduction to Shells
Shell Features CSCI N321 – System and Network Administration
Andy Wang Object Oriented Programming in C++ COP 3330
The UNIX Shell Learning Objectives:
Some Linux Commands.
C151 Multi-User Operating Systems
Shell Environments.
UNIX and Shell Programming (06CS36)
Basic UNIX OLC Training.
Andy Wang Object Oriented Programming in C++ COP 3330
Shell Programming.
Linux Shell Script Programming
CSE 303 Concepts and Tools for Software Development
Unix Shell Environments
Linux Commands LINUX COMMANDS.
Presentation transcript:

Introduction to Unix – CS 21 Lecture 9

Lecture Overview Shell description Shell choices History Aliases Topic review

The Shell – It’s That Thing You’re Typing In The command line itself is just another Unix program that is running A program that runs other Unix commands An interface between the user and the system Called a shell That’s why in emacs the command is Meta-X shell

Different Shells sh Bourne Shell csh C shell tsch Turbo C Shell ksh Korn shell bash Bourne Again Shell

Why So Many Choices, And What Does It Mean? All shells run programs the same way A sort executed from csh works the same way a sort executed from bash does Shells differ in all the bells and whistles Different shells have different features that make them appealing Shell programming is a huge difference

Which Shell Are You Using? Most likely you are using bash You can check by printing the environment variable SHELL printenv SHELL echo $SHELL

Switching Shells Run the command and you’re in Must exit from multiple shells then chsh – a program to change your shell every time you login Checks the file /etc/shells

Startup Files.login.profile.bashrc.tcshrc

What’s In a Configuration File

When Do All These Files Get Executed?.profile and.login only get read once when you login.bashrc and.tcshrc get run everytime a new shell is created

Checking Out The Shell Environment

What Do All Those Environment Variables Mean? HOSTNAME TERM SHELL HISTSIZE USER PWD HOME VISUAL EDITOR

Customizing Your Prompt The environment variable PS1 determines the appearance of your prompt You can set the prompt to be anything you’d like Suggestion: don’t make it too confusing or cluttered

Special Prompt Symbols These only work when interpreting the prompt environment variables \H and \h \T and \t and \u \w and \W \!

Examples: What Do These Mean?

A Peek Ahead If you would like more advanced functionality in your prompt, you can add a program to execute with the ` (backtick) Example: export PS1=“\H: `pwd`\n>” This will print the working directory every time the prompt is generated

Subprompt: PS2 \ Continue on the next line ‘ Start of a quote – looks for another ‘ “ Start of a quote – looks for another “ Our system sets up “loop $” as the default PS2 I find this pretty confusing, as it really isn’t looping at all

Subprompt Examples

Question: What happens if you “unset PS1”? You have no prompt! Really confusing

Bash History Bash will keep track of the most recent commands you have entered This number can be set HISTSIZE Keeps track even after you logout

The.bash_history File The history is stored in a hidden file in your HOME directory called.bash_history It is updated after you logout Changes won’t appear until you logout If you have two terminal sessions, the last one you logout on will be the most recent history

The history Command Usage: history [NUMBER] Prints out all of your most recent commands Assigns a number to each of them Command number

History In Action

O.k., So I Can See What I’ve Done, So What? Bash gives you shortcuts to easily redo commands in your history !! Repeat the last command

Bash Shortcuts Into The History Directly execute a history command based on: Command number !123 First characters of the command !m Will always match the most recent command that matches, not necessarily the one you want

Examples

Getting More Out Of History !* Everything but the first word of the previous command Allows you to run a different command with the same arguments !$ Gets you just the last word of the previous command

Examples

Bash And Emacs Certain emacs commands work in bash Searching backwards will search through the history backwards ctrl-a and ctrl-e get you to the beginning and end of a line respectively

Aliases Making another name for some other command Useful for making sure certain flags are always used Could cause trouble as well…

Setting Aliases Usage: alias NAME=“COMMAND” Example: alias ll=“ls –l” Example: alias cp=“cp –i” Safe cp Usage: unalias NAME Example: unalias cp

Everything We’ve Looked At – Week 1 History of Unix Open source effect The directory structure What goes where How to move around Where to get help Man pages

Everything We’ve Looked At – Week 2 Disk space and compression du, gzip, zip, bzip2 Permissions and ownership chmod Copying, moving, and deleting files cp, mv, rm Checking out file content file, cat, more, less

Everything We’ve Looked At – Week 3 Input and output streams File redirection Piping Regular Expressions grep

Everything We’ve Looked At – Week 4 emacs Basic commands Buffers and switching Searching and r.e. searching vi Command mode versus insertion mode Various commands Searching and r.e. searching

Everything We’ve Looked At - Today Yes, I could ask a question regarding today’s material Shell definition and choices The history mechanism Using aliases

Coming Up… Midterm and lab practical this Thursday Next week Job control Beginning shell programming

Jobs

The Foreground and the Background

Running Jobs In The Background

Suspending Jobs

Switching Jobs To The Foreground

Switching Suspended Jobs To The Background

The nohup Command

Stopping Rogue Processes

Signals And What They Mean

The kill Command

The ps Command