1 / 31

Pre-Assessment Questions Identify the command that enables you to delete a directory? mkdir rmdir

Pre-Assessment Questions Identify the command that enables you to delete a directory? mkdir rmdir pwd cd Angela needs to create a directory called data in her home directory. Identify the command that enables Angela to create a directory in the home directory?

karis
Download Presentation

Pre-Assessment Questions Identify the command that enables you to delete a directory? mkdir rmdir

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. Pre-Assessment Questions • Identify the command that enables you to delete a directory? • mkdir • rmdir • pwd • cd • Angela needs to create a directory called data in her home directory. Identify the command that enables Angela to create a directory in the home directory? • [Angela@localhost Angela]$ mkdir ~/data • [Angela@localhost Angela]$ mkdir home data • [Angela@localhost Angela]$ mkdir data home • [Angela@localhost Angela]$ mkdir ~/home/data Introduction to Linux

  2. Pre-Assessment Questions (Contd.) • Identify the command that is used to view the content of a file. • cat • cp • mv • rm • Identify the command that prompts before deleting a file. • a.     rm -f • b.      rm -v • c.      rm -R • d. rm -i Introduction to Linux

  3. Pre-Assessment Questions (Contd.) • Which of the following commands will change the permission of the file messages to 000 (----------) from 764 (-rwxrw-r--)? a.     chmod a-rwx messages • b.     chmod go-rwx messages • c.     chmod ugo+rwx messages • d. chmod ugo-rw messages Introduction to Linux

  4. Solutions to Pre-Assessment Questions • b. rmdir • a.[Angela@localhost Angela]$ mkdir ~/data • a. cat • d. rm -i • a. chmod a-rwx messages Introduction to Linux

  5. Objectives • In this lesson, you will learn to: • Identify functions and types of editors • Create and modify files in the vi editor using various commands • Work in emacs and joe editor • Configure the vi editor Introduction to Linux

  6. Editors • An editor is application software, which is usually bundled with an operating system (OS). • A text editor is used to create and manage text files and documents and has a wide variety of application, such as: • Creating and maintaining documents • Writing programs and utilities • Writing mail messages • A text editor allows you to perform some basic functions such as: • Creating a file • Opening an existing file • Copying and pasting text • Searching text • Handling large amount of data Introduction to Linux

  7. Editors Available with Linux • There are various editors available with Linux. Some of them are: • vi (visual editor) • vim (visual editor improved) • emacs (edit macros editor) • sed (stream editor) • ed (line editor) • red (restricted ed editor) • joe (joe’s own editor) • rjoe (restricted joe editor) • pico • jpico (version of the joe editor, which emulates the pico editor used in the Pine mail program) • jstar (version of the joe editor compatible with WordStar) Introduction to Linux

  8. The vi Editor • The vi editor: • Is a visual editor used for creating and editing text files containing data, documents, or programs • Is a symbolic link to the vim editor in Red Hat and Fedora Core2 Linux • Is invoked by giving the following command at the Linux prompt: • [steve@linuxpc1 steve]$ vi message.txt  • Works in the following three modes: • Command mode: Enables you to execute the commands that control cursor movement in a file • Input mode: Enables you to add content in the file that you have created using the vi editor • Escape mode: Enables you to perform save and substitution operations on a file Introduction to Linux

  9. Command Action h Move cursor to previous character l Move cursor to next character k Move cursor up one line j Move cursor down one line x Delete character at current cursor position dd Delete line :wq<Enter> Save all changes and quit :w<Enter> Save the file :q!<Enter> Quit without saving changes :e <filename><Enter> Open the specified file :w <filename><Enter> Write to a different file :w! <filename><Enter> Force write to another file :! <command_name><Enter> Execute a shell command • The Commands in vi • The following table shows some commonly used commands in vi: Introduction to Linux

  10. Command Action <Ctrl>d or D Scrolls down half screen <Ctrl>u or U Scrolls up half screen <Ctrl>F Goes one page forward <Ctrl>B Goes one page backward NG Goes to line number n 0 (zero) Goes to the beginning of the line $ Goes to the end of the line H Goes to the first line on the screen M Goes to the middle line on the screen L Goes to the last line on the screen z<Enter> Makes the current line the first line on screen z- Makes the current line the last line on screen • Cursor Movement Commands in vi • The following table shows the basic cursor movement commands: Introduction to Linux

  11. Command Description :r file_name Enables you to read another file, file_name, into the current file. The content of the file, file_name, is placed after the cursor position in a new line. :r !cmd_name Enables you to read the output of cmd_name command into the current file. The output of the command is placed after the cursor position in a new line. :5,10w file_name Saves lines 5 through 10 of the current file to the file, file_name. :5,10w >> file_name Appends lines 5 through 10 of the current file to the file, file_name. • Advanced Reading and Saving Commands • The following table shows the advanced reading and saving commands: Introduction to Linux

  12. Command Description :.,$w file_name Saves lines starting from the current cursor position to the end of the file in the file, file_name. :n file_name Enables you to edit a different file, file_name, which is other then the current file, without exiting the vi editor. :n# Enables you to edit the previous file if multiple files are open. This command enables you to toggles between two files. • Advanced Reading and Saving Commands (Contd.) • The following table shows the advanced reading and saving commands: Introduction to Linux

  13. Command Action a Appends after current character A Appends at end of line i Inserts before current character I Insert at beginning of line o Inserts blank line below and allows insertion O Inserts blank line above and allows insertion rx Replaces current character with character x Rtext<Esc> Replaces characters with text (until <Esc> is pressed). • The Insert and Replace Commands • The following table shows the insert and replace commands: Introduction to Linux

  14. Command Action w Moves to next word b Moves to previous word e Moves to end of word • The Word Movement Commands • The following table shows the word movement commands: Introduction to Linux

  15. Command Action dw Deletes word dd Deletes line cw Changes word cc Changes line X Deletes character before current cursor position J Joins lines u Undoes last change U Restores last change .(dot) Repeats last change • The Deletion and Modification Commands • The following table shows the deletion and modification commands: Introduction to Linux

  16. Command Action yy or Y Yanks or anchors current line, which needs to be copied Nyy or NY Yanks or anchors N lines, including current line, such as 5yy, which is used when 5 lines are to be copied p Puts yanked text after current cursor position P Puts yanked text before current cursor position • The Commands to Copy Lines • The following table shows the commands to copy lines: Introduction to Linux

  17. Command Action fx Finds the character x on current line after current cursor position Fx Finds character x on current line before current cursor position /pattern <Enter> Finds next line containing pattern ?pattern <Enter> Finds previous line containing pattern • The Pattern-Finding Commands • The following table shows the commands for finding characters or patterns: Introduction to Linux

  18. Demonstration-Creating Document Using vi • Problem Statement • The complaints reported by the customers calling up at the Front Office call center II of Deez Telecommunications Inc. have to be typed in and saved as files. One such customer calls up the Front Office of call center II on September 10, 2004 and reports the following: • Hello, I am David Goodman. I have recently purchased a cell phone with a charger set from your company. The invoice number is # 0000818 and the date of purchase is September 07, 2004. My charger set is not functioning properly. It seems to need recharging after every 10 minutes of talk–time and, therefore, my cell phone often dies out during a conversation. My address is #55/99 Sunnyvale St., PA – 828292, and my telephone number is 9632102832. I would like your Support personnel to resolve the problem as soon as possible. Introduction to Linux

  19. Demonstration-Creating Document Using vi (Contd.) • Problem Statement (Contd.) • Angela has been given the task of receiving the calls and typing the details of the complaints as separate files. Angela has recently joined the company. She may require some support in doing this task. Introduction to Linux

  20. Demonstration-Creating Document Using vi (Contd.) • Solution • The following tasks need to be performed: • Identify the name of the document. • Identify the command to be used for creating the document. • Identify the mode in which the content will be added to the document. • Verify the file content. Introduction to Linux

  21. Demonstration- Editing Document Using vi • Problem Statement • The entry details of a customer, David Goodman, are typed incorrectly in the file named Cust_Detail.00001 present under Angela’s home directory. There are also certain spelling errors in the file. Angela needs to resolve the errors in the file to reflect the correct status. The existing content of the file is as follows: Name : Mr. David Goodman Mobile Number : 9632102289 Addres: # 75 /99 Sunnyvale St. PA - 987613 Talk Time Allocted: 100 Hours Introduction to Linux

  22. Demonstration- Editing Document Using vi (Contd.) • Problem Statement (Contd.) • The content to be altered is as follows: Name : Mr. David Goodman Mobile Number : 9632102289 Address : # 55 /99 Sunnyvale St. PA - 987613 Talk Time Allocated : 100 Hours Introduction to Linux

  23. Demonstration-Editing Document Using vi (Contd.) • Solution • To edit the document, Angela needs to perform the following tasks: • Invoke the vi editor using the identified file name. • Edit the document. • Save and exit the file. • Verify the modifications done on the file. Introduction to Linux

  24. The emacs and joe Editors • The emacs editor: • Is easy to work with because it displays an online Help screen with commonly used commands. • Enables you to format the source code for several programming languages, such as C and C++. • Provides a much larger set of commands than the vi editor. • Is invoked by the following command from the shell prompt: • [steve@linuxpc1 steve]$ emacs  • The joe editor: • Is a full-screen editor. • Can be invoked by typing joe at the command prompt. You can also give a file name along with the joe command to open the file in the editor. Introduction to Linux

  25. Configuring vi • The three escape mode commands that change the behavior of the vi editor are: • set • map • abbr • The vimrc file: • Contains the preceding commands to control the behavior of the vi editor . • Is stored in the /etc directory within the home directory of the user. • You can use the cat command to view the content of the vimrc file as follows: • $ cat /etc/vimrc Introduction to Linux

  26. Options Description autoindent Specifies that the file content should be automatically indented for easier readability. ignorecase Activates or deactivates the case sensitivity for the search commands used in the vim editor. • The set Command • The set command: • Is used to specify the values of the environment variables of the vi editor environment. • Accepts the vi editor environment variables and their values as parameters and changes the behavior of the editor accordingly. For example, the abbreviation of the :set autowrite command is: • :set aw • The following table shows various options of set command: Introduction to Linux

  27. Options Description magic Enables the vi editor to treat regular expression characters, such as * and ?, as special characters during the pattern-matching searches. number Displays line numbers along with the lines displayed in the vi editor. showmode Displays a message when the vi editor is opened in the input mode showmatch Enables you to locate matching brackets in the file content. tabstop=n Defines the tab stop value according to user's choice. wrapscan Continues pattern search by moving to the beginning of a file so that the entire file is scanned or searched. • The set Command (Contd.) • The following table shows various options of set command (Contd.): Lesson 2A / Slide 27 of 31 Introduction to Linux

  28. The map Command • The map command: • Is also used to customize the vi editor. • Has the following syntax: • :map <the key, which needs mapping> <key sequence which is to be mapped> • Is of two types: • :map: Enables you to bind a set of vi commands to a single keystroke in the command mode.When the mapped keystroke is pressed, it expands to the command sequence. • Map!: Enables you to map keys in the input mode. As a result, you can press the mapped key while inserting or changing text. Introduction to Linux

  29. Using the abbreviate Command • The abbreviate command: • Enables you to define abbreviations for specific strings. • Has the following syntax: • :ab <string1> <string2> • Is used to view the list of abbreviations that you have created using the ab command. Introduction to Linux

  30. Summary • In this lesson, you learned: • An editor is application software used to create and maintain documents. • Some of the most commonly used editors are: • vi (visual editor) • vim (visual editor improved) • emacs (edit macros editor) • sed (stream editor) • ed (line editor) • red (restricted ed editor) • joe (Joe’s own editor) • rjoe (restricted joe editor) • pico • jpico • jstar Introduction to Linux

  31. Summary (Contd.) • The vi editor can be invoked by the vi command. • The vi editor works in three modes, the insert, command, and escape. The <ESC> key is used to switch between the modes. • The emacs editor is another very popular editor available on Linux machines. • You can display the online Help menu in the emacs editor. The emacs editor provides support for spell check and multiple document interfaces. • The joe editor can be invoked with the joe command. • You can customize the vi editor to suite your needs by configuring it using the map, set, and abbr commands. Introduction to Linux

More Related