NETW-240 Shells Last Update 2013.04.09 1.4.0 Copyright 2000-2012 Kenneth M. Chipps Ph.D. www.chipps.com 1.

Slides:



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

CIS 118 – Intro to UNIX Shells 1. 2 What is a shell? Bourne shell – Developed by Steve Bourne at AT&T Korn shell – Developed by David Korn at AT&T C-shell.
1 Introduction to UNIX Ke Liu
1 The Shell and some useful administrative Unix Commands How Unix works along with some additional, useful administrative Unix commands you might need.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
Linux+ Guide to Linux Certification, Second Edition
CS 497C – Introduction to UNIX Lecture 36: - Customizing the Environment 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.
The Unix Shell. Operating System shell The shell is a command interpreter It forms the interface between a user and the operating system When you log.
CSE 303 Lecture 2 Introduction to bash shell
Guide To UNIX Using Linux Third Edition
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
UNIX By Darcy Tatlock. 1. Successful Log Into Unix To actively manipulate your website you need to be logged in. Without being logged in you cannot enter.
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.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
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”
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
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.
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.
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.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Linux Stuff Last Update Copyright 2014 Kenneth M. Chipps Ph.D. 1.
The Kernel At a high level, the kernel in an operating system serves as the bridge between applications and the actual data processing of the hardware.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Unix Fundamentals CS 127. File navigation cd - change directory cd /var/log cd /etc/apache2 cd ~/Desktop ~ is a shortcut for the home directory.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
Lesson 8-Specifying Instructions to the Shell. Overview An overview of shell. Execution of commands in a shell. Shell command-line expansion. Customizing.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
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.
SUSE Linux Enterprise Desktop Administration
Getting started with CentOS Linux
Introduction to Shells
Chapter 11 Command-Line Master Class
Shell Features CSCI N321 – System and Network Administration
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Andy Wang Object Oriented Programming in C++ COP 3330
The UNIX Shell Learning Objectives:
Some Linux Commands.
CSE 374 Programming Concepts & Tools
UNIX and Shell Programming (06CS36)
Basic UNIX OLC Training.
Introduction to UNIX.
John Carelli, Instructor Kutztown University
Getting started with CentOS Linux
Andy Wang Object Oriented Programming in C++ COP 3330
Linux Shell Script Programming
Linux Commands LINUX COMMANDS.
A shell is a user interface.
Presentation transcript:

NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1

Objectives of This Section Learn –What a shell is –How to use a shell Copyright Kenneth M. Chipps Ph.D. 2

What is a Shell It is a command line interpreter In other words if you type something on the command line and press enter, the shell will either do something with that command or tell you it cannot Copyright Kenneth M. Chipps Ph.D. 3

Common Linux Shells The most common shells on Linux and UNIX systems are the –sh - Bourne Shell –csh - C Shell –ksh - Korn Shell –bash - Bourne Again Shell bash is an advanced version of the sh shell first written for Unix systems Bash is the one most often used in Linux Copyright Kenneth M. Chipps Ph.D. 4

Common Linux Shells To leave a shell –Ctrl D or exit Copyright Kenneth M. Chipps Ph.D. 5

bash When Linux is started after the load finishes the shell presents a prompt such as Copyright Kenneth M. Chipps Ph.D. 6

bash Copyright Kenneth M. Chipps Ph.D. 7

bash A nice feature of bash is the command history It will keep track of a certain number of previously issued commands in the –~/.bash_history file The number of commands in the history is likewise customizable Copyright Kenneth M. Chipps Ph.D. 8

bash When bash is first started, the history list is initialized by the defined history file - ~/.bash_history The history list is kept in memory until you exit the shell, at which point the list is written to the history file, overwriting its current contents Even when you log in initially, you have a history of what you did during your last login session Copyright Kenneth M. Chipps Ph.D. 9

bash You can access the commands that are stored in the history file by using the up and down arrow keys to move to a previously issued command Once you've selected a command, you can edit it by inserting or deleting characters Copyright Kenneth M. Chipps Ph.D. 10

bash Another method of accessing the command history is to use the history command The history command, by default, lists the lines that are contained in the history file For example, issuing the command –history 10 displays the last 10 lines in the history file Copyright Kenneth M. Chipps Ph.D. 11

bash The command-line options for history are quite simple –-r Tells history to read the contents of the history file and use them as the current history list –-w Tells history to write the current history list to the history file and overwrite its current contents Copyright Kenneth M. Chipps Ph.D. 12

bash –-a Tells history to append the current history list to the history file –-n Causes the lines that are in the history file to be read into the current history list Copyright Kenneth M. Chipps Ph.D. 13

bash Pipes are a way to string a number of commands together The output from the first command is piped or sent into the second command as input, the output from the second command is piped into the third command as input, and so on The output from the last command is printed to the screen or redirected to a file Copyright Kenneth M. Chipps Ph.D. 14

bash In order to pipe commands, you must use the pipe - vertical bar, which is the | character It tells bash where one command ends and the next begins There's no limit to the number of pipes that can be used bash, like every other shell, supports redirection for commands Copyright Kenneth M. Chipps Ph.D. 15

bash You can redirect the output from a command to a file or device other than the local console Likewise, you can use a file or device to provide input to a command To redirect the output from a command to a new file, use the > symbol Copyright Kenneth M. Chipps Ph.D. 16

bash Another feature of bash is its ability to suspend currently running processes, known as Job Control Pressing –CTRL Z suspends the currently running process Copyright Kenneth M. Chipps Ph.D. 17

bash Then these two commands move the process to the background or back to the foreground –bg –fg To start a command in the background use the &, as in –commandname & Copyright Kenneth M. Chipps Ph.D. 18

bash Like everything in Linux bash uses several startup files One of these is a common file The other three are user specific The common file is –/etc/profile Copyright Kenneth M. Chipps Ph.D. 19

bash The user specific files are –~/.bash.profile Contains information about the user’s shell environment –~/.bash.login Executed at each login to the shell –~/.profile Copyright Kenneth M. Chipps Ph.D. 20

bash –~/bashrc A configuration file that is executed each time the bash shell is entered And also each time a subshell is generated –~/bash_logout Executed on user logout of the shell Copyright Kenneth M. Chipps Ph.D. 21

bash.bash_profile is executed at user login To reexecute it after a change to the file precede it with –. – a period As in –..bash_profile or –source.bash_profile Copyright Kenneth M. Chipps Ph.D. 22

bash The ~ means from the user’s home directory bash does it this make just to make it harder on you as an administrator or user /etc/profile –This is the main startup file for bash –It is used for the commands that all users need Copyright Kenneth M. Chipps Ph.D. 23

Common Commands pwd –Shows the current directory cd –Change directories cp –Copy mv –Rename Copyright Kenneth M. Chipps Ph.D. 24

Common Commands rm –Remove mkmir –Make a directory rmdir –Delete empty directories Copyright Kenneth M. Chipps Ph.D. 25

Common Commands ls –Show a list of whatever is in the directory –Switches -a –Show everything -F –List by type -l –Long listing -t –List by date Copyright Kenneth M. Chipps Ph.D. 26

Common Commands To show one screen full of filenames at a time –ls –l | less Copyright Kenneth M. Chipps Ph.D. 27

Common Commands ln –Create a link file –To find out what type of file the file is cat –Display what is inside a file Copyright Kenneth M. Chipps Ph.D. 28

Common Commands head –Show the first 10 lines of a file –As in head filename –Or specify the number of lines with head –n20 filename Copyright Kenneth M. Chipps Ph.D. 29

Common Commands tail –Show the last 10 lines of a file –As in tail filename –Or specify the number of lines with tail –n20 filename Copyright Kenneth M. Chipps Ph.D. 30

Common Commands more –Shows a file one page at a time less –Shows a file one page at a time –But allows scrolling through the file –q to quit it Copyright Kenneth M. Chipps Ph.D. 31

Common Commands grep –To search through a file –For example grep whattosearchfor filetolookin or grep ‘word word’ filetolookin find –Looks through directories for a file Copyright Kenneth M. Chipps Ph.D. 32

Getting Help locate –The same as find, but faster help –Basic information –Such as cat --help Copyright Kenneth M. Chipps Ph.D. 33

Getting Help man –More information –As in man apache –Switches -k –Shows commands Copyright Kenneth M. Chipps Ph.D. 34

Getting Help info –Provides more structure to the information than plain man does –But does not cover all man pages Copyright Kenneth M. Chipps Ph.D. 35