1 / 17

Welcome to CSE 4251

Welcome to CSE 4251. Description: Students will learn how to use the UNIX programming environment effectively to orchestrate processes and find information in files using basic shell programming methods. In addition, students will learn programming basics for utilities such as grep and make .

clark
Download Presentation

Welcome to CSE 4251

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Welcome to CSE 4251 • Description: Students will learn how to use the UNIX programming environment effectively to orchestrate processes and find information in files using basic shell programming methods. In addition, students will learn programming basics for utilities such as grep and make. • Level and Credits : U1 • Other: grading, labs, etc : • See web http://www.cse.ohio-state.edu/~lido/teaching/cse4251/

  2. Welcome to CSE4251 • Name: Dong Li • Email: lido@cse.ohio-state.edu • Classroom: Bolz 0311 • Class Time: Monday 9:10am – 10:05am • Office : DL274 • Telephone: 614-465-6899 • Office Hours: 10:05am-11:30am

  3. Lecture 1: Introduction to Unix Shell Brief Unix History Running Model and System Calls Unix Shell & Flavor

  4. Unix History • The first version of Unix came from AT&T in the early 1970s (Unix is old!). 1991

  5. Unix Motivation • Unix was developed by programmers and for programmers. • Unix is designed so that users can extend the functionality • To build new tools easily and efficiently • To customize the shell and user interface. • To string together a series of Unix commands to create new functionality. • To create custom commands that do exactly what we want.

  6. Running Model • User Mode • A process running in this mode can’t access kernel data structures and procedures • Kernel Mode • A process running in this mode can access kernel data structures and procedures • System call • Can be looked as the interface between user mode and kernel mode

  7. Layout of address space Of A Process (linux)

  8. Creating Processes • fork() • Create a duplicate of the calling process • exec() • Create a duplicate of the calling process • Load a executable program whose name is one of arguments of exec() into the address space of the new process • wait()- Cause a parent process to sleep until one of its child processes terminates • exit()

  9. What is Shell? • Shell is • Command Interpreter that turns text that you type (at the command line) in to actions: • Shell is a process; • User Interface: take the command from user • Programming Shell can do • Customization of a Unix session • Scripting

  10. Customization of a Session • Each shell supports some customization. • User prompt • Where to find mail • Shortcuts (alias) • The customization takes place in startup files • Startup files are read by the shell when it starts up • The Startup files can differ for different shell

  11. Startup files • sh,ksh: /etc/profile (system defaults) ~/.profile • bash: ~/.bash_profile ~/.bashrc ~/.bash_logout • csh: • ~/.login: executed when you logon • ~/.cshrc: executed when a new shell is spawned • ~/.logout: executed at logout

  12. Flavors of Unix Shells • Two main flavors of Unix Shells • Bourne (or Standard Shell): sh, ksh, bash, zsh • AT&T shell • Fast • $ for command prompt • C shell : csh, tcsh • Berkley Shell • better for user customization and scripting • %, > for command prompt • To check shell: • % echo $SHELL (shell is a pre-defined variable) • To switch shell: • % exec shellname (e.g., % exec bash)

  13. Popular Shells • sh Bourne Shell • ksh Korn Shell • csh,tcsh C Shell (for this course) • bash Bourne-Again Shell

  14. Your Best Friend • % man command (e.g., % man ls) • shows information about the command • usually space or ↓ for more information • q to quit • % man man

  15. Some Common Commands • ls –l • mv src dst // rename a file • rm file // delete files or directories • cp src dst // copy files • mail • write sb // send an message to sb • lpr // print something • wc file // word counting for a file • tail –n file // print out the last n lines of file • tail +n file // print out file starting from nth line • mkdir dir_name // create a directory • rmdir dir_name // delete a directory

  16. Recommended Reading • Chapter 1, sections 1.1 – 1.5

More Related