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.

Slides:



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

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.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Lab6 CPCS361 I.Mona Alshehri. Working with Files and Directories Creating files Create a file with the cat command type the command cat > name_of_file.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Linux+ Guide to Linux Certification, Second Edition
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.
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
CMPE 151: Network Administration Spring Class Description Focus: system and network administration. Sequence of exercises. E.g., installing/configuring.
UNIX Utilities Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn Input/Output.
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.
"Two of the most famous products of Berkeley are LSD and Unix. I don't think that this is a coincidence.” Anonymous.
The file structure and related utilities CS240 Computer Science II.
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”
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
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.
Linux+ Guide to Linux Certification, Second Edition
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Jozef Goetz, expanded by Jozef Goetz, 2009 Credits: Parts of the slides are based on slides created by UNIX textbook authors, Syed M. Sarwar, Robert.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
1 Operating Systems Lecture 2 UNIX and Shell 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.
Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories:
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
UNIX Commands COMP 1090 Introduction to Unix Fall
40 Years and Still Rocking the Terminal!
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Introduction to Programming Using C An Introduction to Operating Systems.
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Linux Commands C151 Multi-User Operating Systems.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
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 ( >, >>,
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
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.
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.
Tutorial of Unix Command & shell scriptS 5027
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Linux file system "On a UNIX system, everything is a file;
Some Linux Commands.
C151 Multi-User Operating Systems
INTRODUCTION TO UNIX: The Shell Command Interface
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Linux Shell Script Programming
Chapter 3 The UNIX Shells
Linux Commands LINUX COMMANDS.
A shell is a user interface.
January 26th, 2004 Class Meeting 2
LPI Linux Certification
Presentation transcript:

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 in to a Unix system, a shell starts running. You interact with the shell

this is the shell prompt the SHELL environment variable tells which shell is being used this is where the shell program is located /bin/bash

Unix Shells Shell nameProgram (Command) namerc Bourne Shellsh C Shellcsh Bourne Again Shellbash Z shellzsh Korn Shellksh TCtcsh

Unix Shells Shell name description rca very simple shell - similar to sh Bourne Shelldeveloped at Bell labs - popular C Shellbsd unix - based on C language Bourne Again Shellopen source version of sh - linux/osX Z shellextended sh - very large shell Korn Shelllike sh but extensive scripting language TCc shell with emacs-like command line

you can change shells by typing the shell command return to the default shell by typing “exit”

The shell command line prompt shows current directory. ~ is your home directory command list of arguments

command options (usually preceded with a hyphen)

What happens when you type a command? The shell parses the command line It looks for a program that matches the command It starts a new process and runs that program While the program executes, the shell sleeps When the program is done, the shell wakes up It displays its prompt It waits for the user to type another command

Command stdin stdout Commands generally get their input from stdin and send their output to stdout

if you run the who command, the system tells you who is logged in and at what terminal. but... this is really a file in the Unix file system that represents a real device, in this case a terminal commands read from and write to this file!

the cat command is a good example. It takes its input from a file and outputs to stdout.

if you type the command with no parameters, it takes its input from stdin. It will do this until you type ctrl-D (end of file).

Redirection You can cause the shell to get its input from some place other than stdin or send its output to some place other than stdout by using redirection.

Redirecting standard output command [arguments] > filename

redirect output to newduh.txt

Concatenating Files with cat command

Redirecting standard input command [arguments] < filename

cat takes its input from the file supplies and writes to standard output

Appending standard ouput to a file command [arguments] >> filename

Pipes The shell uses a pipe to connect the output of one command to the input of another command.

Using a pipe command_a [arguments] | command_b [arguments]

The tr command translates each character in its input stream to the corresponding character in its output stream.

Running a command in the background command_a [arguments] & the & tells the shell to run the command in the background. This means that the shell prompt will appear immediately and you can type in new commands without waiting for the background command to finish.

Some useful Unix Commands

cal cal month year cal year cal displays a monthly calendar

cat cat [options] file-list concatenates files end to end -emarks end of each line with a $ -ndisplays line numbers

cd cd [directory] change to the specified directory cd with no arguments changes to your home directory

chmod chmod [options] mode file-list symbolic u user+ add permission g group- remove permission o other a all changes permissions

chmod chmod [options] mode file-list absolute xxx - a binary encoded value everyone can read, write, execute owner can read, write, execute, others can read, execute changes permissions

cp cp [options] source-file destination-file -iinteractive, prompt if this will overwrite an existing file -rrecursive, for directories, copies everything copies files

diff diff [options] file-1 file-2 compares files

find find directory-list criteria recursively searches in a given directory -name file-name -type file-type -user user-name

finger finger [options] user-list displays information for logged in users -ldetailed listing -sbrief listing

grep grep [options] pattern [file-list] searches files for a given pattern -cdisplay the number of lines that match -iignore case -ldisplay the filenames where a match is found -ndisplays each line with its line number in the file

grep uses regular expressions in its pattern matching Consider the file testregex that contains the lines ring ringing bringing talk talking walking

Simple strings Consider the file testregex that contains the lines ring ringing bringing talk talking walking > grep ring testregex ring ringing bringing

Period - represents any character Consider the file testregex that contains the lines ring ringing bringing talk talking walking > grep.ing testregex ring ringing bringing talking walking

[ ] - represents a set of characters Consider the file testregex that contains the lines ring ringing bringing talk talking walking > grep [tw] testregex talk talking walking

^ - matches a string at the beginning of a line Consider the file testregex that contains the lines ring ringing bringing talk talking walking > grep ^ri testregex ring ringing

$ - matches a string at the end of a line Consider the file testregex that contains the lines ring ringing bringing talk talking walking > grep ing$ testregex ring ringing bringing walking talking

head head [number] file-list displays the first number lines of a file

kill kill [signal-number] PID-list kills a process

ln ln [option] existing-file link-name create a link to a file by default ln creates a hard link. Hard links must be in the same directory as the file being linked to. the -s option creates a symbolic link. Symbolic links can be across file systems and directories.

ls ls [options] file-list list information about one or more files -alist all entries, including invisible files -lshow all file information -rshows all subdirectories

t r w x r w x r w x links owner group size date_last_modified filename type of file d directory - regular file b block device c character device l symbolic link p pipe s socket file owner group other

mkdir mkdir [option] directory-list make a new directory -pif the parent directory does not already exist, the create it.

more more [options] [file-list] display a file, one screenful at a time -nnumber output lines

mv mv [options] existing-name new-name move (rename) a file -fmoves regardless of file permissions -iprompts if move would overwrite an existing file

ps ps [options] displays the status of existing processes -adisplay all processes associated with a terminal -edisplays some environment information -llong display -xdisplays daemon processes

rm rm [options] file-list remove a file -fremoves files for which you do not have write permission -iprompts before removing each file -r recursive

rmdir rmdir directory-list remove an empty directory

tail tail [number] [file] display the last number lines of a file

who display logged in users