Вы находитесь на странице: 1из 17

RHCE Syllabus and topics

Nano tuto
GNU nano is a small and friendly text editor. Besides basic text editing, nano offers many extra features like an interactive search and replace, goto line number, auto-indentation, feature toggles, internationalization support, and filename tab completion.

Overview
nano [GNU long option] [option] +LINE [ file ... ] The original goal for nano was a complete bug-for-bug compatible emulation of Pico, but consistency is now a slightly higher priority. There is a flag to implement (nearly) complete Pico emulation, (option -p or GNU long option --pico). This can also be toggled from within nano by typing Meta-P. See section Pico Compatibility, for more info. Email bug reports to nano@nano-editor.org.

Command Line Options


nano takes the following options from the command line: -T [num, --tabsize=[num] Set the displayed tab length to [num] columns. -R, --regexp Turns on regular expression search and search/replace. -V, --version Print the version number and copyright and quit. -c, --const Constantly display the cursor posititon and line number on the statusbar. -h, --help Print the usage and exit. -i, --autoindent Automatically indent new lines to the same number of spaces and tabs as the previous line. -k, --cut Makes ^K cut from the current cursor position to the end of the current line. -l, --nofollow When writing files, if the given file is a symbolic link it is removed and a new file is created. -m, --mouse Enables the use of the mouse to select text (currently only useful for running under the X window system). -p, --pico Emulate Pico as closely as possible, sacrificing consistency for correct emulation. See section Pico Compatibility, for more info. -r [#cols], --fill=[#cols]. Wrap lines at column #cols. By default this is the width of the screen, less eight. -s [prog], --speller=[prog] Invoke [prog] as the spell checker. By default, nano uses its own interactive spell checker that requires the spell program be installed on your system. -t, --tempfile Do not ask whether or not to save the current contents of the file when exiting, assume yes. This is most useful when using nano as the composer of a mailer program. @anchor{Expert Mode} -x, --nohelp In Expert Mode, the Shortcut Lists will not appear at the bottom of the screen. This affects the location of the statusbar as well, as in Expert Mode it is located at the very bottom of the editor. Note: When accesing the help system, Expert Mode is temporarily disabled to display the help system navigation keys. -v, --view Do not allow the contents of the file to be altered. Note that this flag should NOT be used in place of correct file permissions to implement a read-only file. -w, --nowrap Do not wrap long lines at any length. This option overrides any value for -r. -z, --suspend

Enable suspend ability of nano using the system's suspend keystroke (usually ^Z). +LINE Start at line number LINE instead of the default of line 1.

Linux / Unix sed command


Quick links About sed Syntax Examples Related commands Linux / Unix main page About sed Sort for Stream Editor sed allows you to use pre-recorded commands to make changes to text. Syntax sed [ -n ] [ -e script ] ... [ -f script_file ] ... [ file ... ] -n -e script Suppress the default output. script is an edit command for sed . See USAGE below for more information on the format of script. If there is just one -e option and no -f options, the flag -e may be omitted. Take the script from script_file. script_file consists of editing commands, one per line. The sed commands to perform. A path name of a file whose contents will be read and edited. If multiple file operands are specified, the named files will be read in the order specified and the concatenation will be edited. If no file operands are specified, the standard input will be used

-f script_file commands file

Script: A script consists of editing commands, one per line, of the following form: [ address [ , address ] ] command [ arguments ] Zero or more blank characters are accepted before the first address and before command. Any number of semicolons are accepted before the first address. In normal operation, sed cyclically copies a line of input (less its terminating NEWLINE character) into a pattern space (unless there is something left after a D command), applies in sequence all commands whose addresses select that pattern space, and copies the resulting pattern space to the standard output (except under -n) and deletes the pattern

space. Whenever the pattern space is written to standard output or a named file, sed will immediately follow it with a NEWLINE character. Some of the commands use a hold space to save all or part of the pattern space for subsequent retrieval. The pattern and hold spaces will each be able to hold at least 8192 bytes. sed Addresses: An address is either empty, a decimal number that counts input lines cumulatively across files, a $ that addresses the last line of input, or a context address, which consists of a /regular expression/. A command line with no addresses selects every pattern space. A command line with one address selects each pattern space that matches the address. A command line with two addresses selects the inclusive range from the first pattern space that matches the first address through the next pattern space that matches the second address. Thereafter the process is repeated, looking again for the first address. (If the second address is a number less than or equal to the line number selected by the first address, only the line corresponding to the first address is selected.) Typically, address are separated from each other by a comma (,). They may also be separated by a semicolon (;). Examples sed G myfile.txt > newfile.txt In the above example using the sed command with G would double space the file myfile.txt and output the results to the newfile.txt. sed = myfile.txt | sed 'N;s/\n/\. /' The above example will use the sed command to output each of the lines in myfile.txt with the line number followed by a period and a space before each line. As done with the first example the output could be redirected to another file using > and the file name. sed 's/test/example/g' myfile.txt > newfile.txt Opens the file myfile.txt and searches for the word "test" and replaces every occurrence with the word "example". sed -n '$=' myfile.txt Above this command count the number of lines in the myfile.txt and output the results. Linux / Unix awk command Quick links About awk Syntax Examples

Related commands Linux / Unix main page About awk Short for Aho, Weinberger, and Kernighan, awk is a script processing language also known as oawk, gawk, mawkand nawk allows for pattern scanning and processing. Syntax awk [program | -f program file] [flags / variables] [files] -f program file Run an awk script from the specified file instead of from the command line. variable Initializes the awk variable with the specified. Syntax is variable=value The awk program can consist of one or more awk commands separated by a \n or semicolons. Examples awk myscript.sh In the above example this command would execute the awk script "myscript.sh".

Running Vim
When installation is complete, you are now ready to play around with vim. So lets start by opening vim, which a new file. vim newfile Now, you can type away, and your text will not appear on the screen as you would expect. There are different operating modes that vim has to offer, the mode you are in now is command mode. The command mode is the most useful mode to use to mess with your file, ie save, exit, search etc. To be able to type, and edit files like you would do normally, pressing i or the insert button, and this will place you into insert mode. To get back to the command mode, press <Esc>. So you have loaded vim, with the file you want to create, and you have entered insert mode, typed to your hearts consent, and now you want to save. Enter Esc mode, and type ':' this will create a prompt at the bottom, to save, you type w after the: . To save and exit, you would enter command mode, and type:wq. You guessed it, to exit without saving, you just type :q. To force a quit, do a :q! I have listed all the vim commands that you will find useful:

VIM Commands
Key: <Esc> i R a :w :q x dw dd Action: Enter command mode Enter insert mode Enter overwrite mode Enter append mode Save File Exit vim without saving Delete the character under the cursor Delete the current word Delete the current line

d$ yy yw p u ^r G /text

Delete everything Right of the cursor Yank the current line onto the clipboard Yank the current word onto the clipboard Paste the clipboard Undo Redo Jump to bottom of file Search for the textfrom the cursor

Programming Essential.
All programmers love the use of colors and identation. Heres how you do it: vim ~/.vimrc Press i to enter Insert mode, then add these lines to the file set autoindent syn on set cindent Press <Esc>, enter:wq now test it, try using vim with the extension of the language you are using (ie perl, html, c) and start typing a bit of code, and watch the preety colors and indentation. vimtutor is a good way to learn vim too.

Vi - Linux Editor

Can A Text Editor Be Evil?


The vi editor comes with every version of Linux or Unix. It's a terribly unfriendly beast of an editor, but you should know about it because someday you're likely to find yourself on a system where you have no other choice but to use it. A friend of mine calls vi the Heart of Evil, but that might be just a bit harsh--you decide. Using vi is similar to using other editors in that you can see your file on the screen (this is not the case with a line editor, for example), move from point to point in the file, and make changes. But that's where the similarities end. Cryptic commands, a frustrating user interface, and the absence of prompts can all drive you up a wall. Still, if you focus on a few basics, you'll get the job done. Command and Input Mode The hardest thing to understand about vi is the concept of modes. When using vi,you're always in either Command or Input mode. Unfortunately there's no clue as to which mode is currently active. 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 lettera(lowercase only) to signal that you want to add text after the cursor position. Pressescto switch back to Command mode at any time. Here's how to create a file from scratch using vi. To start, create a new file namedcow.jokeby typing vi cow.joke You'll see a screen that looks like this: | ~ ~ ~ ~ ~ ~ ~ ~ ~ "cow.joke" [New file] Adding New Text to Your File Your cursor (the vertical bar at the top of the figure below is in the upper-left corner of the screen, and the message at the bottom tells you that a new file calledcow.jokewas just created. The tilde characters in the first column are just placeholders for empty lines. Now press the letterato enter Input mode and type the lines shown in here. Pressenterat the end of each line to go on to the next. Jane: Knock, knock... Bill: Who's there? Jane: The Interrupting Cow. Bill: The Interrupting Cow wh... Jane: MOOOOOO!

| ~ ~ ~ ~ "cow.joke" [New file] Saving Your Work So far, so good--let's save this little masterpiece. You're still in Input mode, so pressescto enter Command mode; then typeZZ(to put your file to sleep). You won't see any Z's on the screen, but after you've entered the second Z, your file will disappear, your Linux command prompt will return, and you'll see this message, indicating that your file was successfully saved: "cow.joke" 6 lines, 113 characters. Congratulations--you've just survived your first encounter with vi. You know that theacommand switches to Input mode,escgets you back to Command mode, andZZsaves the file, but you'll have to expand this limited repertoire to get any real work done. 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). Then we'll do one more exercise before moving on. Note: As with all of Linux, vi commands are case sensitive. Positioning the Cursor ctrl-F ctrl-B $ ^ :1 :$ / ? x dd p u Move cursor one space right. Move cursor one space left. Move cursor up one line. Move cursor down one line. Move forward one screen. Move backward one screen. Move cursor to end of line. Move cursor to beginning of line. Move to first line of file Move to last line of file Search for a character string. Reverse search for a character string. Delete the character at the cursor position. Delete the current line. Paste data that was cut with x or dd commands. Undo.

Entering Input Mode a Add text after the cursor. i Insert text before the cursor. R Replace text starting at the cursor. o Insert a new line after the current one. Entering Command Mode esc Switch from Input mode to Command mode. Exiting or Saving Your File :w ZZ :q! Trying Write file to disk, without exiting editor. Save the file and exit. Quit without saving. Out Some vi Commands

Here's another example to try out some of the vi commands. Enter the following command to fire up vi again, and you should see the file as we left it in the last example: vi cow.joke Changing Text Let's change Bill's name to Biff on the second line. To do so, use the arrow keys to position your cursor on the third character of line 2 (the letter "l"in Bill); then pressxtwice (to delete the two l's). Now pressi(to enter Input mode) and then typeffto complete the change from Bill to Biff. Tip: Be careful about pressing the arrow keys while you're in Input mode. In some versions of vi you can position the cursor only in Command mode. Yuck. You could also have used theRcommand to do this job of replacing text, so use it to change the other Bill now. Pressescto enter Command mode; then type/Billto search for the wordBill.The cursor should move to line 4, right to where Bill is located. Now position your cursor on the third character (the letter "l"), pressRto replace the characters, and typeff. Both Bills should now be Biffs. Adding and Deleting Lines Here's how to add or delete a line. Pressescto enter Command mode; then press theokey to add a new line. You're in Input mode again, so you can type whatever you like on this new line. But that would ruin the joke, so delete this new line by pressingescand then entering theddcommand. The line you just added should go away. Quitting without Saving Your Changes Hmmm. . . . "Biff" just doesn't have that wholesome ring to it, so let's forget about all the changes we've made in this editing session and exit vi without saving the file. Make sure you're in Command mode, enter the:q!command, and then pressenter. Your Linux prompt should return, and thecow.jokefile will be just as it was before. Parting Words about vi Using vi can be frustrating, but it really isn't rocket science once you get used to the concept of the two modes and get the hang of when it's okay to move your cursor or enter text. If you're ever unsure about which mode you're in, simply pressesconce or twice, and you can be sure you're in Command mode.

There are some powerful (but arcane) commands that diehard vi users use to get things done quickly in this relic-of-the-sixties text editor. Theman vicommand will tell you a lot more about vi if you decide you want to become proficient. The Usenet newsgroup comp.editors is a good place to discuss vior ask questions. You can find the vi FAQ (Frequently Asked Questions) file on the Web at http://www.faqs.org/faqs/editor-faq/vi/. For more information on thevicommand, see thevi manual.

Read more:http://lowfatlinux.com/linux-editor-vi.html#ixzz1OZHhvIXN

Chapter 7. Email Applications Email is a very popular way of communicating with others over the Internet. An application that allows users to send, receive, and read email is called anemail client. Red Hat Enterprise Linux includes several email applications, including graphical email clients like Evolution and Thunderbird, and text-based clients like mutt. Each of the email client applications is designed to suit specific types of users; so, you can choose one with the features that best suits your particular needs. The purpose of this chapter is to demonstrate how to use some of the popular email applications included in Red Hat Enterprise Linux. Since all email clients perform the same basic tasks (send and receive email), you should choose one that is convenient and easy to use. This chapter briefly discusses the following email clients: Evolution Thunderbird

Mutt, a text-based email client


Before you launch an email client, you need information from your Internet Service Provider (ISP) to configure the client properly. The following is a list of important configuration information: Your email address The email address you use to send and receive mail. This is usually in the form of <yourname>@<example.com>. In this example, <yourname> is your user name and <example.com> is the domain name for your ISP. Server type for receiving email In order to receive mail, you must know what type of server the ISP is using, POP or IMAP. POP, short for Post Office Protocol, is used to send email from a mail server to your email client's inbox, the place where incoming email is stored. Most ISP email servers use the POP protocol, although some use the newer IMAP protocol. POP mail is

downloaded to your email client directly anddoes not stay on the server by default (although most email clients can be configured to leave email on the server as well). IMAP, short for Internet Message Access Protocol, is a protocol for retrieving email messages from your ISP's email server. IMAP differs from POP in that email from IMAP servers are stored on the server and not downloaded to the mail client. Address for receiving email In order to receive mail, you must obtain the address of the POP or IMAP server from your ISP. This address is usually in the form ofmail.example.com. Server type for sending email (SMTP) The Simple Mail Transfer Protocol (SMTP) is a protocol for sending email messages between mail servers. Most email systems use SMTP to send messages over the Internet; the messages can then be retrieved with an email client using either POP or IMAP. SMTP is also used to send messages from a mail client to a mail server. This is why you need to specify both the POP or IMAP server and the SMTP server when configuring an email application. If you have any questions regarding what information you need, contact your ISP or network administrator. Unless properly configured, you cannot make full use of the email clients discussed in this chapter. 7.1. Evolution Evolution is more than just an email client. It provides all of the standard email client features, including powerful mailbox management, user-defined filters, and quick searches. Additionally, it features a flexible calendar/scheduler which allows users to create and confirm group meetings and special events online.Evolution is a full-featured personal and work group information management tool for Linux and UNIX-based systems, and is the default email client for Red Hat Enterprise Linux. To launch Evolution from the desktop panel, go to Applications => Internet => Email, or click on the Email icon on your Panel.

Figure 7-1. Evolution Welcome Screen The first time you start Evolution you are presented with the Welcome Screen (Figure 7-1), which allows you to configure your email connection. Follow the on-screen instructions and fill in the information you collected from your ISP or administrator in the text boxes provided. When you are done, click Finish.Evolution proceeds to the Main Screen as shown in Figure 7-2.

Figure 7-2. Evolution Main Screen To view what is in your inbox or to send an email, click on the Mail button in the left toolbar, then select the Inbox icon from the list of folders.

7.2. Thunderbird This section briefly covers the basic steps for sending and receiving email with Thunderbird. For more information about using Thunderbird, the Helpcontents are located under Help on the main menu. To start Thunderbird, select Applications => Internet => Thunderbird Mail. You are presented with a New Account Setup screen. You are first asked whether you would like to import information from other email programs. Make your selection and click on the Next >> button. On the next screen, select Email account, which allows you to configure your email connection. Follow the on-screen instructions and fill in the information you collected from your ISP or administrator in the text boxes provided. Figure 7-5. Account Setup Figure 7-6. Thunderbird Mail

To create a new email message, click the Write button. A blank message will open in a new window. Enter the address(es) of the recipient(s) of your email in the To field(s). Enter the subject of your email in the Subject field. In the large bottom pane, enter the text of your email. You can spell check your email by clicking on the Spell icon or by pressing --. You can attach files by clicking on the Attach icon, or by going to File => Attach => File(s). Finally, when you are finihsed with your email, click the Send icon. The email window closes and returns you to the main screen. Figure 7-7. Thunderbird Mail New Email Message Screen To read email, click on the Get Mail icon to check for new mail. Click on the folders in the left sidebar to open them. If there are any messsages in that folder, they appear as a list in the top-right pane of the window. As you click on each email in the list, a preview of its contents appears in the pane directly below. If there are any attachments to your email, a field labelled Attachments lists the names of the files. Double-click the file name to open or save the file. Once you read a message, you can delete it, save it to a separate folder, and more. 7.2.1. Thunderbird and Newsgroups Newsgroups are Internet discussion groups with specific topics. The discussions are in threaded format (which means all topics and responses to the topic are sorted and organized for convenient reading) and subscribing to a group is easy. You are not required to post messages; instead, you can just lurk, which is a Newsgroup term for reading without posting messages. There are a great many newsgroups on the Web with topics ranging from politics to computer games to random strange thoughts. You can even post and download pictures and files to Newsgroups (although your ISP may restrict Newsgroups to text-based postings only). To join a newsgroup, you first need to set up a newsgroup account. Click on your mail account name in the sidebar and select Create a new account from the options that appear on the right of the screen. The New Account Setup screen appears again. Select Newsgroup account and then click Next. Enter your name and email address in the blank fields and click Next. On the following screen, enter the name of your news server (if you do not know the name of your news server, contact your Internet service provider or network administrator for this information). On the last few screens, you can determine the name of this account and review your settings. The newsgroup account you created appears in the sidebar of the Thunderbird mail screen. Right-click on this account name and select Subscribe. A dialog box appears, listing all the newsgroups available. Select the groups you are interested in reading and click Subscribe. When you are done, click onOK. Double-click on the newsgroup account name and the list of groups you are subscribed to appears beneath. Select the newsgroup you want to access and a dialog box appears with information about downloading and reading existing messages. Posting to a newsgroup is just like writing an email, except that the newsgroup name appears in the To field rather than an email address. To unsubscribe from a newsgroup, right-click on the group name and selectUnsubscribe.

Figure 7-3. Evolution Inbox Screen To compose a new message, click on the down arrow beside the New icon. Select Mail Message from the drop-down list. You can also press--. Enter the address of the recipient in the To field, the subject of the email in the Subject field, and the text of your message in the large pane below. You can spell check your email before sending by going to Edit => Spell Check Document or by pressing --. You can attach documents by clicking on the Attach icon. A window opens that allows you to navigate to the file you would like to attach. Click on the name of the file to highlight it, then click on the Open button. Finally, when you are finished, click the Send button to send.

Figure 7-4. Evolution New Email Message Screen While Evolution does much more than read and send email, this chapter focuses exclusively on its email capabilities. To learn more about Evolution's other features, refer to the Help text.

7.3. Plain Text Email Clients Most modern email clients allow the user to select whether they want to send their emails in plain text or in HTML. HTML formatted email can contain formated text, graphics, and interactive links to Web sites. The particular font can be specified, the layout is very controllable, textures, and pictures or backgrounds can be added; all this makes for a visually appealing message when it gets to the recipient. On the other hand, plain text email is just that plain text. There is nothing fancy, there are no pictures embedded in the email, and there are no special fonts. The term plain text refers to textual data in ASCII format. Plain text (also called clear text) is the most portable format because it is supported by nearly every email application on various types of machines. This chapter discusses the mutt plain text email client.

7.3.1. Using Mutt Mutt is a small but very powerful text-based mail client for UNIX operating systems. The configuration file for Mutt, ~/.muttrc, is highly configurable. Because a user can control nearly all of the functions within Mutt, new users sometimes run into problems with initial configuration. Most of the options for Mutt are invoked using the set or unset commands, with either boolean or string values, e.g. set folder = ~/Mail. All configuration options can be changed at any time by typing a followed by the relevant command. For example :unset help turns off the keyboard command hints at the top of the screen. To turn those hints back on, type :set help. If you cannot remember the command, there is always tab-completion to help. You do not have to type all your preferred configuration commands each time you run mutt, you can save them in a file which is loaded every time the program starts up. This configuration file must exist in your home directory, and it must be named either ~/.muttrc or ~/.mutt/muttrc. When you launch mutt (by typing mutt at a shell prompt), a screen appears with a list of email messages. This initial menu is called the index.

Figure 7-8. mutt Main Screen These messages are in a default mail folder, called the inbox or mailspool. Use the and keys on your keyboard to move the highlighted cursor up and down the list of messages. In the index or pager views, use the key to reply to a message or the key to create a new one. Mutt prompts for the To: address and the Subject:line. A text editor (defined by your $EDITOR environmental variable in the configuration file) then launches, allowing you to compose your message. Type your message, save your file and exit the editor.

After editing the email, Mutt displays the compose menu, which allows you to customize your message headers, change the encoding, add file attachments or press the key to send your email on its way. To learn more about mutt, refer to the man pages for muttrc and mutt (type man muttrc or man mutt at the shell prompt). You may also find the muttmanual to be very helpful. The mutt manual is installed in /usr/share/doc/mutt-1.2.x/, where x is the version number of mutt installed on your system.

http://www.linuxtopia.org/online_books/redhat_linux_step_by_step_guide/ch-docs.html

Вам также может понравиться