Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review."— Presentation transcript:

1 Introduction to Unix – CS 21 Lecture 9

2 Lecture Overview Shell description Shell choices History Aliases Topic review

3 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

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

5 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

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

7 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

8 Startup Files.login.profile.bashrc.tcshrc

9 What’s In a Configuration File

10 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

11 Checking Out The Shell Environment

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

13 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

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

15 Examples: What Do These Mean?

16 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

17 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

18 Subprompt Examples

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

20 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

21 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

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

23 History In Action

24 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

25 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

26 Examples

27 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

28 Examples

29 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

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

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

32 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

33 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

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

35 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

36 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

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

38 Jobs

39 The Foreground and the Background

40 Running Jobs In The Background

41 Suspending Jobs

42 Switching Jobs To The Foreground

43 Switching Suspended Jobs To The Background

44 The nohup Command

45 Stopping Rogue Processes

46 Signals And What They Mean

47 The kill Command

48 The ps Command


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

Similar presentations


Ads by Google