1 / 34

Chapter 5 Linux Shell

Chapter 5 Linux Shell. Before icons and windows took over computer screens, you typed commands to interact with most computers. On UNIX systems, from which Linux was derived, the program used to interpret and manage commands was referred to as the shell.

gwen
Download Presentation

Chapter 5 Linux Shell

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. Chapter 5Linux Shell

  2. Before icons and windows took over computer screens, you typed commands to interact with most computers. • On UNIX systems, from which Linux was derived, the program used to interpret and manage commands was referred to as the shell.

  3. Shell is the interface between end user and the Linux system, similar to the commands in Windows • The shell is a command language interpreter. • If you have used Microsoft operating systems, you’ll see that using a shell in Linux is similar to—but generally much more powerful than—the interpreter used to run commands in DOS or in the CMD command interface. • As you grow into Linux you will surely need to use the shell at some point to track down a problem or administer some features.

  4. It provides a way to • create executable script files • run programs • work with file systems • compile computer code • operate a system • manage the computer. • Most Linux experts consider the shell to be much more powerful than GUIs.

  5. Important of shell script • Shells have been around a long time, and many advanced features have been built into them. Several major reasons for learning how to use the shell are: 1) You will know how to get around any Linux or other UNIX-like system. For example, you can log in to my Red Hat Enterprise Linux MySQL server, bootable floppy router/firewall, or iMac and explore and use any of those computer systems from a shell.

  6. 2) Enable you to gather data input and direct data output between commands and the Linux file system. To save on typing, you can find, edit, and repeat commands from your shell history. Many power users hardly touch a graphical interface, doing most of their work from a shell.

  7. 3) Can gather commands into a file using programming constructs such as conditional checks, loops, and case statements to quickly do complex operations that would be difficult to retype over and over. Programs consisting of commands that are stored and run from a file are referred to as shell scripts. Most Linux system administrators use shell scripts to automate tasks such as backing up data, monitoring log files, or checking system health.

  8. Various Linux Shell • To find out what your current login shell is, type the following command: $ echo $SHELL /bin/bash • In this example, it’s the bash shell. • There are many other shells, and you can activate a different one by simply typing the new shell’s command (ksh, tcsh, csh, sh, bash, and so forth) from the current shell. For example, to change temporarily to the C shell, type the following command: $ csh

  9. You might want to choose a different shell to use because: • You are used to using UNIX System V systems (often ksh by default) or Sun Microsystems and other Berkeley UNIX–based distributions (frequently csh by default), and you are more comfortable using default shells from those environments. • You want to run shell scripts that were created for a particular shell environment, and you need to run the shell for which they were made so you can test or use those scripts. • You might simply prefer features in one shell over those in another. For example, a member of my Linux Users Group prefers ksh over bash because he doesn’t like the way aliases are always set up with bash.

  10. Types of shell • bash shell • tcsh shell • C shell • ash shell • korn shell

  11. BOURNE SHELL (sh commands) • The Bourne shell, or sh, was the default Unix shell of Unix Version 7, • It replaced the Thompson shell, but the executable file had the same name, sh. • It was developed by Stephen Bourne, and released in 1977 in the Version 7 Unix. • It remains a popular default shell for Unix accounts. • The binary program of the Bourne shell or a compatible program is located at /bin/sh on most Unix systems • Its command interpreter contained all the features that are commonly considered to produce structured programs. • Although it is used as an interactive command interpreter, it was always intended as a scripting language.

  12. BOURNE SHELL (sh commands) • The Bourne shell, or sh, was the default Unix shell of Unix Version 7, • It replaced the Thompson shell, but the executable file had the same name, sh. • It was developed by Stephen Bourne, and released in 1977 in the Version 7 Unix. • It remains a popular default shell for Unix accounts. • The binary program of the Bourne shell or a compatible program is located at /bin/sh on most Unix systems • Its command interpreter contained all the features that are commonly considered to produce structured programs. • Although it is used as an interactive command interpreter, it was always intended as a scripting language.

  13. C SHELL (csh commands) • The C shell is a Unix shell that was created by Bill Joy in the late 1970s. • It has been distributed widely in 1978. • The C shell is a command processor that's typically run in a text window, allowing the user to type commands which cause actions. • The C shell can also read commands from a file, called a script. • C shell has an interactive features and overall style. • Its new features made it easier and faster to use. • And the overall style of the language looked more like C and was seen as more readable.

  14. BOURNE-AGAIN SHELL (bash commands) • Bash is the shell, or command language interpreter, that will appear in the GNU operating system. • Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). • It offers functional improvements over sh for both programming and interactive use. • In addition, most sh scripts can be run by Bash without modification. • The manual is available online at www.gnu.org/software/bash/manual/. • BASH can be downloaded at http://ftp.gnu.org/gnu/bash/

  15. KORN SHELL (ksh commands) • The Korn shell (ksh) is a UNIX shell which was developed by David Korn in the early 1980s. • It is backwards-compatible with the Bourne shell but includes many features of the C shell as well, such as a command history • The main advantage of ksh over the traditional Unix shell is in its use as a programming language. • Several features were gradually added, while maintaining strong backwards compatibility with the Bourne shell.

  16. ALMQUIST SHELL (ash commands) • The Almquist shell (also known as A Shell, ash) was originally developed by Kenneth Almquist‘s • it is a fast, small, POSIX-compatible Unix shell designed to replace the Bourne shell in later BSD distributions. • Originally it did not feature line editingor command history mechanisms - should be moved into the terminal driver; • ash are installed as the default shell (/bin/sh) on FreeBSD, NetBSD, DragonFly BSD and Minix. • Debian's version of ash is known as Debian Almquist Shell (dash).

  17. METHODS TO GET SHELL INTERFACE • Shell Prompts • It looks like an MS-DOS screen. • Users type commands at a shell prompt, • the shell interprets these commands, • and then the shell tells the OS what to do. • Linux functions can be completed faster from the shell prompt than from a GUI.

  18. METHODS TO GET SHELL INTERFACE • Terminal Windows • synonymous with a command line shell or text terminal, the term terminal covers all remote terminals, including graphical interfaces. • A terminal emulator inside a GUI is often called as terminal window. • A terminal window allows the user access to Command Line Interfaces (CLI) and Text User Interface applications. • On Unix-like OS, it is common to have one or more terminal windows connected to the local machine.

  19. Here are two common ways to launch a Terminal window from a Linux desktop: • Right-click the desktop. In the context menu that appears, look for Shells, New Terminal, Terminal Window, Xterm, or some similar item and select it. In Fedora, rightclick on the desktop and click Open Terminal. • Click on the panel menu. Many Linux desktops include a panel at the bottom of the screen from which you can launch applications. For example, in systems that use the GNOME desktop, you can select Applications➪Accessories➪Terminal to open a Terminal window. For Mandriva, select System➪Terminals.

  20. METHODS TO GET SHELL INTERFACE • Virtual Terminal • In open systems, a virtual terminal (VT) is an application service that: • Allows host terminals on a multi-user network to interact with other hosts regardless of terminal type and characteristics, • Allows remote log-on by LAN managers for the purpose of management, • Allows users to access information from another host processor for transaction processing, • Serves as a backup facility. • ITU-T defines a virtual terminal protocol based on the OSI application layer protocols.

  21. Learning Outcomes • Upon completion this topic, student should be able to : 1.Understand Linux Text Editor

  22. 5.2 Linux text editor • Text editors are similar to word processors, providing various features for writing documents. • vi • pico • emacs 

  23. vi • Vi text editor comes with every version of Linux or Unix • Often the default editor that pops up when you're ready to write an e-mail message or when you're posting a News message.  • Vi is complicated and seems difficult to learn at first. • Vi provide a cryptic command and frustrated interface • The hardest thing to understand about vi is the concept of modes • Vi have a command and input mode. • There are no clue as to which mode is currently actice •  However, it is often the default for Unix and Linux systems.  This chapter explains the use of the Vi editor.

  24. In Command mode, you can move the cursor, search for characters, and delete existing text • But to enter or edit new text, you have to switch to Input mode. • When you start vi, you're in Command mode. • To enter Input mode, type the letter a (lowercase only) to signal that you want to add text after the cursor position.

  25. Example of using vi • Here's how to create a file from scratch using vi. To start, create a new file named cow.joke by typing : • vi cow.joke • You'll see a screen that looks like this:-

  26. Common vi Commands • Have a look at this list of common vi commands (there are many more, but these will at least allow you to get some basic work done). • Note: As with all of Linux, vi commands are case sensitive. Positioning the Cursor � Move cursor one space right. � Move cursor one space left. � Move cursor up one line. � Move cursor down one line. ctrl-F Move forward one screen.

  27. ctrl-B Move backward one screen. $ Move cursor to end of line. ^ Move cursor to beginning of line. :1 Move to first line of file :$ Move to last line of file / Search for a character string. ? Reverse search for a character string. x Delete the character at the cursor position. dd Delete the current line. p Paste data that was cut with x or dd commands. u Undo. • For further command please refer to : http://lowfatlinux.com/linux-editor-vi.html

  28. pico • Short for Pine Composer • pico is a fairly simple text editor that provides straight-forward options and easy-to-use commands.  • The pico text editor doesn't have a lot of fancy features, but it's a welcome alternative to the vi or Emacs editors because learning it is quick and easy • Cursor movement and text entry are straightforward, and--best of all--you don't have to learn any arcane commands • To start Pico, enter a command like this: pico bulb.joke

  29. In response, you should see the file bulb.joke displayed on your screen in Pico, ready for editing, as shown here:

  30. Getting around in Pico • Before we explore Pico commands, here's a summary of how to navigate your way around a file in Pico. • Positioning the Cursor � Move cursor one space right (also ctrl-N). � Move cursor one space left (also ctrl-P) � Move cursor up one line (also ctrl-F). � Move cursor down one line (also ctrl-B). del Delete character at cursor (also ctrl-D). ctrl-Y Move backward one screen (maybe F7). ctrl-V Move forward one screen (also F8). ctrl-A Move cursor to beginning of line. ctrl-E Move cursor to end of line. • Further command please refer to : http://lowfatlinux.com/linux-editor-pico.html

  31. emacs • The Emacs editor is a lot easier to use than vi. • Emacs falls somewhere between the straightforward Pico and the complicated Vi.  • There are no silly modes to trip you up--when you want to enter text, you just position the cursor and type. • It also has built-in help. • powerful commands themselves are difficult to remember. • Emacs is a vast improvement over vi, you'll still have to remember quite a few commands to be productive, and you'll probably get a little lost • Unlike vi commands, Emacs commands are not case sensitive •  Let's try creating a file from scratch using Emacs. To start, enter this command: $ emacs bulb.joke

  32. If you get into a situation where Emacs seems to be stuck, or if you don't know what to do, press ctrl-G and things will return to normal. • (The ctrl-Gkey cancels the current operation in Emacs.)

  33. mcedit editor (Midnight Commander Editor) • JOE is a full featured terminal-based screen editor • It is distributed under the GNU General Public License (GPL). • JOE has been around since 1988 • It is comes standard with many Linux distributions. • JOE is being maintained by its original author Joseph Allen • JOE is written in C and its only dependency is libc.

  34. joe (Joe’s Own Editor) • JOE is a full featured terminal-based screen editor • It is distributed under the GNU General Public License (GPL). • JOE has been around since 1988 • It is comes standard with many Linux distributions. • JOE is being maintained by its original author Joseph Allen • JOE is written in C and its only dependency is libc.

More Related