1. Trang chủ
  2. » Công Nghệ Thông Tin

debian gnu linux bible phần 4 potx

68 131 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 68
Dung lượng 1,18 MB

Nội dung

182 Part II ✦ Working with Debian Line commands Line commands provide methods of searching through a file to execute the line edi- tor or shell commands. You can type these commands at any time. When a user presses the command character ( /, ?, :, and so on), the cursor moves to the status line where the user can enter the rest of the command (see Table 9-2). Table 9-2 Line commands Command Action /pattern Searches forward for a pattern. The pattern may be a simple word or string that you’re searching for, or a regular expression. ?pattern Searches backward for a pattern : Invokes an ex command. ! Invokes a shell command that uses the buffer as the input and replaces it with the output from the command Movement commands by character Navigating through the screen (that is, moving the cursor to a specific position) requires that you not be in insert mode. Instead, you must be in command mode. Table 9-3 lists the commands used to move the cursor one character at a time when in command mode. Table 9-3 Single-character movement commands Command Action h Left one character j Down one character k Up one character l, SPACEBAR Right one character Movement commands by text The commands listed in Table 9-4 enable you to move the cursor through the text more quickly by jumping to the next word, sentence, or paragraph. 4710-0 ch09.F 4/10/01 11:23 AM Page 182 183 Chapter 9 ✦ Essential Tools Table 9-4 Multi-character movement commands Command Action w, W Forward by one word b, B Backward by one word ), ( Beginning of the next or previous sentence from the current sentence }, { Beginning of the next or previous paragraph from the current paragraph ]], [[ Beginning of the next or previous section from the current section Movement commands by lines The commands listed in Table 9-5 enable you to maneuver through the screen line by line. Table 9-5 Line movement commands Command Moves to 0 (zero) The first position of the current line $ The last position of the current line ^ The first nonblank character of the current line +, RETURN The first nonblank character of the next line - (dash) The first nonblank character of the previous line H The top line on the screen nH n lines from the top line M The middle line on the screen L The last line on the screen nL n lines from the bottom line Movement commands by screens You may also move through your document quickly by moving an entire screen at a time. Table 9-6 summarizes these commands. 4710-0 ch09.F 4/10/01 11:23 AM Page 183 184 Part II ✦ Working with Debian Table 9-6 Screen movement commands Command Action CTRL+F Scrolls forward one screen CTRL+B Scrolls backward one screen CTRL+D Scrolls down one-half screen CTRL+U Scrolls up one-half screen CTRL+E Scrolls down one line at the bottom CTRL+Y Scrolls up one line at the top of the screen z, RETURN Repositions with the cursor at the top of the screen z. Repositions with the cursor in the middle of the screen z- Repositions with the cursor at the bottom of the screen CTRL+L, CTRL+R Redraws the screen Searching through files Table 9-7 contains one of the most helpful groups of commands when working with large documents. You can search for text patterns found in the document to quickly display that section on the screen. Table 9-7 Searching commands Command Action /pattern Searches forward in document for pattern / Repeats last forward search /pattern/+n Goes to line n after finding pattern ?pattern Searches backward in document for pattern ? Repeats last backward search ?pattern?-n Goes to line n before finding pattern n Repeats previous search N Repeats previous search in the opposite direction % Finds the match of the current parenthesis, brace, or bracket 4710-0 ch09.F 4/10/01 11:23 AM Page 184 185 Chapter 9 ✦ Essential Tools Saving your files and exiting the editor There are different methods for saving documents and quitting the editor, as listed in Table 9-8. You may find that selecting a few methods serves you best. Table 9-8 File commands Command Action ZZ, :x Writes the file to disk only if changes were made, then quits :wq Writes the file to disk and quits :w Writes the file to disk :w filename Writes a copy of the file to filename :q Quits only if no changes were made :q! Quits unconditionally, discarding any changes :e filename Edits filename without leaving vi Options used by the :set command On occasion, you need to set options used in the editor. You can set them from within the editor (see Table 9-9). Table 9-9 Options for :set Command Action :set all Shows all available options :set option Enables option :set nooption Disables option :set option=value Sets the value for option :set option? Shows the value of option Alternatively, you can set options in the .exrc file you create in your home direc- tory. If the file doesn’t exist, then create it and add the settings you desire. You can put your :set commands in it, one per line. 4710-0 ch09.F 4/10/01 11:23 AM Page 185 186 Part II ✦ Working with Debian Learning to use Emacs Another popular editor is Emacs, which refers more to the family of editors rather than a specific editor. Most people think of GNU Emacs when you mention Emacs. GNU Emacs was developed by the Free Software Foundation and released under the General Public License (GPL) to the general public. You can install Emacs from the Debian package manager. Emacs is a large and versatile editor. This chapter gives you an overview. If you need more detailed information on a particular subject, you may access the Emacs Info documentation by pressing Ctrl+H and then i or the Emacs tutorial with Ctrl+H . Emacs dates back to the days before graphical windows. By the time the graphical desktops were common, Emacs already incorporated many windowing features. In fact, Emacs was much more advanced than most applications. It incorporated text editing, shell command execution, and even e-mail access. The same Emacs works through a remote terminal connection or via an X server. Figure 9-1 shows Emacs running in an X Window environment. Figure 9-1: Emacs showing two windows: an e-mail message in one and a calendar in the other 4710-0 ch09.F 4/10/01 11:23 AM Page 186 187 Chapter 9 ✦ Essential Tools Best used for creating, modifying, and compiling source code, the Debian GNU Emacs includes many useful features such as an interface to the Concurrent Version System (CVS), source code compiling, and debugging. The Emacs menus The Emacs’ menus change, depending on which window buffer is active and the specific task that’s running that window. You can click each window to make it active. You can then select the Buffers menu to select the buffer displayed in the active window. Continuing on across the top menu, you come to the Files menu. Here you can open, save, or discard the buffers and manage the windows. You can split windows or combine them into one. You can also launch additional frames, which are essen- tially new instances of Emacs. The Tools menu offers a number of advanced tools, mostly for programmers. From here, you can compare buffers, read news and e-mail, or compile and debug a pro- gram. You can also open a calendar showing the current, previous, and next months. The Edit menu option contains the standard editing features (undo, cut, copy, and paste). The Search menu also contains many of the searching features people like to use such as search, replace, and repeat search. One of the interesting features that Emacs offers is multilingual support. To use this feature, you’ll need to install one of the “mule” Emacs packages such as emacs20- mule. Then, you can access the multilingual support through the Mule menu option. You can use this option to change the language used while working in Emacs. Finally, there is the Help menu. This menu enables you to configure Emacs, set options, and get help for the program. These are the basic menu options available in Emacs. When using one of the many special functions, you have access to even more options because the menus dynamically change to fit the environment. Other editors include vim, jed, and zed. Look through the Debian packages under the category of editors for these and other editors you can install on your system. Note 4710-0 ch09.F 4/10/01 11:23 AM Page 187 188 Part II ✦ Working with Debian Using Commands and Programs Besides the skill of using an editor, you, as an administrator or even as an end user, should know how to use a few commands and programs. Even though there are many more commands than what this chapter covers, this is a good start for your administrative tool belt. alias One of the complaints I’ve heard from novice users of UNIX and Linux is the use of cryptic command names. The alias program enables you to turn those cryptic commands into ones you can remember. It can also take frequently used, long strings of commands and shorten them to something easier to type. The syntax for alias is: alias [-p] name=’command’ This is actually a shell command, making it dependent on the shell you use. See Chapter 14 for more information on shells. Most common shells use the alias com- mand because it is very useful. The -p option prints the list of aliases. Here’s one example you might use: alias longlist=’ls -l’ After typing this command, in the future, you may use the longlist command to get a directory listing. The shell will actually run ls -l for you, but you don’t have to remember that. grep Sometimes it is necessary to locate a pattern within a file. This is where grep is par- ticularly useful. grep searches through a given file and, by default, prints the line that contains the matched pattern. The syntax for the grep command is: grep [option] pattern [file] The only required argument for grep is the pattern. It must have a pattern or it has nothing to find. Table 9-10 lists some of the options available for use with grep. As an example, if you want to scan for system errors in today’s logs, you might use the command grep -i error /var/log/syslog. The -i option asks for a case- insensitive match. The result of this command will be each line that contains the word “error.” 4710-0 ch09.F 4/10/01 11:23 AM Page 188 189 Chapter 9 ✦ Essential Tools Table 9-10 Options for grep Option Description -c, count Prints a count of matching lines for each input file instead of the normal output -E, extended-regexp Interprets the pattern as an extended regular expression -e pattern, Uses pattern; this is useful to protect patterns regexp=pattern beginning with a hyphen (-) -F, fixed-strings Interprets the pattern as a list of fixed strings, separated by new lines, any of which is to be matched -f file, file=file Obtains the search patterns from file, containing one pattern per line. An empty file contains no patterns and therefore matches nothing. help Outputs a brief help message -r, recursive Reads all files under each directory, recursively There are two other commands related to grep — egrep and fgrep. Using egrep is the same as using grep with the -E option (from Table 9-10). Likewise, using fgrep is the same as using grep with the -F option. You can use the remainder of the options for any of these commands. grep is very useful for programmers and coders. If you want to list all the lines of the source file that contain the variable newfile, you use the following command: grep newfile mysource.c grep then searches through mysource.c and displays each line that contains the text newfile. All other data in the file is ignored. In this example, the information is sent to the screen, but it can also be piped to another program or sent to a file. find Use find when you are looking for a file—whether you seek a file with a specific timestamp, a particular filename, or you are just looking for the location of a known file. Table 9-11 lists useful find expressions. find [path] [expression] 4710-0 ch09.F 4/10/01 11:23 AM Page 189 190 Part II ✦ Working with Debian Table 9-11 Useful find expressions Expression Description -empty The file is empty and is either a regular file or a directory. -follow Deference symbolic links. Implies -noleaf -help, help Prints a summary of the command-line usage of find and exits -user uname The file that is owned by user uname (or the numeric user ID) -group groupname The file belongs to group groupname (the numeric group ID also allowed). -fstype type The file is on a filesystem of type type. -name pattern Searches base of the filename that matches pattern -newer file The file was modified more recently than file. -iname pattern Like -name, but the match is case-sensitive for pattern. For example, the patterns `mo*’ and `M??’ match the same filenames. -version, version Prints the find version number and exits -mount Doesn’t descend the directories on the other filesystems. An alternate name for -xdev, for compatibility with some other versions of find -xdev Doesn’t descend directories on other filesystems When faced with using the find command, you may wonder how it can specifically help you. Here are some applications in which find can come in handy: ✦ When searching for modified files to back up, use: find /home/jo -newer /home/jo/lastbackup ✦ When looking for a file with a specific name, use: find / -name picture ✦ When finding files belonging to a specific group, use: find / -group users 4710-0 ch09.F 4/10/01 11:23 AM Page 190 191 Chapter 9 ✦ Essential Tools This is only the beginning of what find can do when searching through the files on your system. You can link find with other programs, such as tar, to perform tasks on the found set of files. locate When all you want to do is track down a file, locate is very easy to use. locate lists the file paths of any file matching the given pattern. If no file exists, the prompt is returned. Otherwise, each file path is printed to the display. Here is the syntax for the locate command: locate [-d path] pattern The -d path option enables you to search a different path database instead of using the default database; however, the need for this is extremely rare. The pattern can be any pattern, and it can include wildcards. Here is an example of finding the filenames that contain locate: # locate locate /usr/bin/locate /usr/lib/locate /usr/lib/locate/bigram /usr/lib/locate/code /usr/lib/locate/frcode /usr/share/emacs/20.7/lisp/locate.elc /usr/share/man/man1/locate.1.gz /usr/share/man/man5/locatedb.5.gz /usr/X11R6/man/man3/XtAllocateGC.3x.gz /var/lib/locate /var/lib/locate/locatedb /var/lib/locate/locatedb.n cat The cat command allows one or more files to be combined (or concatenated) and printed to the screen. This is a very simple program that has many uses. Here is the syntax: cat [options] files Table 9-12 lists the cat command options. 4710-0 ch09.F 4/10/01 11:23 AM Page 191 [...]... 1 root -rwxr-xr-x 1 root root root root root root root root root root root root root root 311 3030 45 0 42 7 277 51 238 41 48 5 383 2259 660 157 May Apr Jul Apr Jul Sep Mar Jul Jul Jun Mar Jul May 25 29 18 29 28 12 15 28 28 20 29 28 19 14: 13 03 :48 10:03 19:07 17 :46 1999 1999 17 :46 17 :46 21:07 21:16 17 :46 04: 26 0anacron apache calendar exim find logrotate man-db modutils netbase samba standard sysklogd... list The form will change again 4 Now you can fill in the fields with the appropriate information When you get to the Select OS box again, select Linux 2.x (libc6 i386) from the list 5 After the information is entered in the fields, click the download button It will take you to the download location page 213 47 10-0 ch10.F 2 14 4/10/01 11:23 AM Page 2 14 Part II ✦ Working with Debian 6 Click a location, usually... become available in a stable version All in all, there is no reason why a Debian GNU/ Linux workstation cannot be used as a multimedia workstation using the tools discussed in this chapter ✦ ✦ ✦ 47 10-0 ch11.F 4/ 10/01 11:23 AM Page 217 11 C H A P T E R Games E veryone needs time to play — what better way to take a break than with Linux? To some, gaming means taking a few minutes out of the day to play... prompted for the PID of the process and the kill signal to send to it A normal kill uses the signal of 15; for a sure kill, use the signal of 9 q Quits the top program 193 47 10-0 ch09.F 1 94 4/10/01 11:23 AM Page 1 94 Part II ✦ Working with Debian Note Zombie processes are those processes that are stopped but not completely gone These processes are already dead, so you cannot kill them In most cases, a zombie... and talk live with others Also included with the cards are various connections: Listening to and creating streamed audio Watching videos Using live voice chat ✦ ✦ ✦ ✦ 47 10-0 ch10.F 2 04 4/10/01 11:23 AM Page 2 04 Part II ✦ Working with Debian ✦ Line-in — This port enables the use of external audio devices such as cassette decks, LP turntables (old-fashioned records), or any other device to connect to... the job executes Times displayed are in the format “1997-02-20 14: 50” -l Creates a listing of all the jobs scheduled to run for this user (the same as using the atq command) -c Concatenates the jobs listed on the command line with the standard output, usually the screen 197 47 10-0 ch09.F 198 4/ 10/01 11:23 AM Page 198 Part II ✦ Working with Debian Time is a mandatory component of the at command, with the... /dev/sndstat The previous command results in the following output: OSS/Free:3.8s2++-971130 Load type: Driver loaded as a module Kernel: Linux hoth 2.2.17 #1 Sun Jun 25 09: 24: 41 EST 2000 i686 Config options: 0 Installed drivers: Card config: Audio devices: 0: Sound Blaster 16 (4. 13) (DUPLEX) Synth devices: Midi devices: 0: Sound Blaster 16 Timers: 0: System clock Mixers: 0: Sound Blaster This code shows which... the command line, use gtcd This application is loaded as part of the GNOME desktop 207 47 10-0 ch10.F 208 4/ 10/01 11:23 AM Page 208 Part II ✦ Working with Debian XMMS Another application that will play audio CDs is XMMS, formerly known as X11Amp You can install this application using the xmms package found among the Debian package archives This application has the look and feel of the popular WinAmp application... tedious xcdroast uses a graphical interface to control the settings when recording CDs You can doanload this package from one of the Debian mirror archives listed on the Debian Web site Figure 10 -4 shows what this interface looks like from the startup screen Figure 10 -4: Introduction screen to xcdroast The buttons along the left side take you to different control panels from which you can copy data,... Connecting to server localhost on port 8001 47 10-0 ch10.F 4/ 10/01 11:23 AM Page 213 Chapter 10 ✦ Multimedia Logging in Activating signal handlers Starting main source streaming loop Playing from /tmp/shout/shout.playlist, line 1 No bitrate or command specified, using autodetect Checking mpeg headers Filename: /cdrom/technohe.mp3 Layer: III Version: MPEG-1 Frequency: 44 100 Bitrate: 128 kbit/s Padding: 0 Mode: . 17 :46 find -rwxr-xr-x 1 root root 51 Sep 12 1999 logrotate -rwxr-xr-x 1 root root 238 Mar 15 1999 man-db -rwxr-xr-x 1 root root 41 Jul 28 17 :46 modutils -rwxr-xr-x 1 root root 48 5 Jul 28 17 :46 . calendar in the other 47 10-0 ch09.F 4/ 10/01 11:23 AM Page 186 187 Chapter 9 ✦ Essential Tools Best used for creating, modifying, and compiling source code, the Debian GNU Emacs includes many. through the Debian packages under the category of editors for these and other editors you can install on your system. Note 47 10-0 ch09.F 4/ 10/01 11:23 AM Page 187 188 Part II ✦ Working with Debian Using

Ngày đăng: 14/08/2014, 04:21