Red Hat [Electronic resources] : The Complete Reference Enterprise Linux Fedora Edition؛ The Complete Reference نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Red Hat [Electronic resources] : The Complete Reference Enterprise Linux Fedora Edition؛ The Complete Reference - نسخه متنی

Richard L. Petersen

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید








The Command Line


The Linux command line interface consists of a single line into which you enter commands with any of their options and arguments. From GNOME or KDE, you can access the command line interface by opening a terminal window. Should you start Linux with the command line interface, you will be presented with a BASH shell command line when you log in.

By default, the BASH shell has a dollar sign (

$ ) prompt, but Linux has several other types of shells, each with its own prompt. A shell prompt, such as the one shown here, marks the beginning of the command line:

$

You can enter a command along with options and arguments at the prompt. For example, with an

-l option, the

ls command will display a line of information about each file, listing such data as its size and the date and time it was last modified. In the next example, the user enters the

ls command followed by a

-l option. The dash before the

-l option is required. Linux uses it to distinguish an option from an argument.

$ ls -l

If you wanted only the information displayed for a particular file, you could add that file's name as the argument, following the

-l option:

$ ls -l mydata





Tip

Some commands can be complex and take some time to execute. When you mistakenly execute the wrong command, you can interrupt and stop such commands with the interrupt key- CTRL-C.



Command Line Editing


The BASH shell, which is your default shell, has special command line editing capabilities that you may find helpful as you learn Linux (see Table 8-1). You can easily modify commands you have entered before executing them, moving anywhere on the command line and inserting or deleting characters. This is particularly helpful for complex commands. You can use the CTRL-F or RIGHT ARROW key to move forward a character, or the CTRL-B or LEFT ARROW key to move back a character. CTRL-D or DEL deletes the character the cursor is on, and CTRL-H or BACKSPACE deletes the character before the cursor. To add text, you use the arrow keys to move the cursor to where you want to insert text and type the new characters. You can even cut words with the CTRL-W or CTRL-U key and then use the CTRL-Y key to paste them back in at a different position, effectively moving the words. At any time, you can press ENTER to execute the command. For example, if you make a spelling mistake when entering a command, rather than reentering the entire command, you can use the editing operations to correct the mistake.













































Table 8-1: Command Line Editing Operations


Key Commands


Operation


CTRL-F, RIGHT-ARROW


Move forward a character


CTRL-B, LEFT-ARROW


Move backward a character


CTRL-A


Move to beginning of line


CTRL-E


Move to end of line


CTRL-D, DEL


Delete character cursor is on


CTRL-H, BACKSPACE


Delete character before the cursor


CTRL-K


Cut remainder of line from cursor position


CTRL-W


Cut previous word


CTRL-U


Cut next word


CTRL-C


Cut entire line


CTRL-Y


Paste previously cut text






Tip

The editing capabilities of the BASH shell command line are provided by Readline. Readline supports numerous editing operations. You can even bind a key to a selected editing operation. You can find out more about Readline in the BASH shell reference manual at www.gnu.org/manual/bash.


You can enter a command on several lines by typing a backslash just before you press ENTER. The backslash "escapes" the ENTER key, effectively continuing the same command line to the next line. In the next example, the

cp command is entered on three lines. The first two lines end in a backslash, effectively making all three lines one command line.

$ cp -i \
mydata \
newdata


Command and Filename Completion


The BASH command line has a built-in feature that performs command and filename completion. If you enter an incomplete pattern as a command or filename argument, you can then press the TAB key to activate the command and filename completion feature, which completes the pattern. If more than one command or file has the same prefix, the shell simply beeps and displays a list of possible command completions and waits for you to add enough characters to select a unique command or filename. In the next example, the user issues a

cat command with an incomplete filename. Upon pressing the TAB key, the system searches for a match and, when it finds one, fills in the filename. The user can then press ENTER to execute the command.

$ cat pre tab
$ cat preface


/ 328