csc 140: introduction to it
DESCRIPTION
CSC 140: Introduction to IT. UNIX Shells. Objectives. To describe what a UNIX shell is. To describe briefly some commonly used shells. What is a shell?. A command interpreter. Runs external commands like cp and rm . Built-in commands change shell environment: cd – change directory - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/1.jpg)
CIT 140: Introduction to IT Slide #1
CSC 140: Introduction to IT
UNIX Shells
![Page 2: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/2.jpg)
CIT 140: Introduction to IT Slide #2
Objectives
• To describe what a UNIX shell is.
• To describe briefly some commonly used shells
![Page 3: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/3.jpg)
CIT 140: Introduction to IT Slide #3
What is a shell?
A command interpreter.– Runs external commands like cp and rm.
– Built-in commands change shell environment:• cd – change directory
• VAR=value
– I/O redirection.• cat /etc/shells >shells
– Ease of use• Command line editing, tab completion, history.
– Programming• Conditionals, loops, etc.
![Page 4: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/4.jpg)
CIT 140: Introduction to IT Slide #4
Environment Variables
![Page 5: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/5.jpg)
CIT 140: Introduction to IT Slide #5
Shell Initialization Files
• Configure shell settings at login.– Create aliases.– Set environment variables.
• bash initialization files– /etc/profile System-wide for sh and bash.– /etc/bashrc System-wide for bash.– ~/.bashrc User startup file.
![Page 6: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/6.jpg)
CIT 140: Introduction to IT Slide #6
sh/csh Differences
![Page 7: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/7.jpg)
CIT 140: Introduction to IT Slide #7
Which Shell Suits Your Needs?
![Page 8: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/8.jpg)
CIT 140: Introduction to IT Slide #8
sh/csh Similarities
![Page 9: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/9.jpg)
CIT 140: Introduction to IT Slide #9
How to change your shell?
• Change your login shell.> chsh zsh
• Run the other shell directly> echo $SHELL
/bin/bash
> zsh
%
![Page 10: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/10.jpg)
CIT 140: Introduction to IT Slide #10
Shell Metacharacters
• Non-alphanumeric characters that have special meaning to the shell.
• They cannot be used in shell commands.• Allow you to specify multiple files in
multiple directories in one command line.
![Page 11: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/11.jpg)
CIT 140: Introduction to IT Slide #11
![Page 12: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/12.jpg)
CIT 140: Introduction to IT Slide #12
![Page 13: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/13.jpg)
CIT 140: Introduction to IT Slide #13
Globbing
• ? Matches any one character.
• * Matches zero or more characters.
• [] Matches list of characters inside brackets.
![Page 14: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/14.jpg)
CIT 140: Introduction to IT Slide #14
Globbing> ls *htmlannounce.html guidelines.html readings.html sites.htmlassignments.html index.html schedule.html> cd assignments> ls a[2-3]?htmla2.html a3.html
![Page 15: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/15.jpg)
CIT 140: Introduction to IT Slide #15
Command History
Up-arrow Previous command
Down-arrow Next command
history List old commands
!! Previous command
!# Command #
!$ Last arg of previous command
![Page 16: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/16.jpg)
CIT 140: Introduction to IT Slide #16
Command line editing
Ctrl-a Beginning of line
Ctrl-e End of line
Left-arrow Move back one character
Right-arrow Move forward one character
Ctrl-u Erase line
![Page 17: CSC 140: Introduction to IT](https://reader036.vdocument.in/reader036/viewer/2022062407/56812ac4550346895d8e9573/html5/thumbnails/17.jpg)
CIT 140: Introduction to IT Slide #17
Filename completion
TAB Completes filename
TAB-TAB Show list of possible
completions.