Basics of Linux shell tips _linux shell

Source: Internet
Author: User
Tags echo command

One, automatically padded: [Tab]

A lot of people should be able to do this by pressing the [TAB] key when entering commands, directories, or filenames. The system will help you fill in what you might want to enter, if more than one selection system will be listed. You can read and then enter one or more charactor, and then press [Tab].

Experiment:

$ EC

Press [Tab] to be padded with:

$ echo


second, find and execute history commands: [Ctrl + R], [Ctrl + P], [Ctrl + N]

In the terminal press [Ctrl] key at the same time [R] key, appear hint: (Reverse-i-search), at this time you try to enter the command you have entered before, when you input a character, the terminal will scroll to show your history command. When the appropriate history command is displayed to you, direct [Enter] executes the history command.

In addition, [Ctrl + P] or [Ctrl + N] quickly scroll forward or backward to find a history command that is useful for fast extraction of commands that have just been executed recently.

Experiment:

$ echo "Hello, World" [Enter]

$ Hello, world

[Ctrl + R] (then enter Echo)

(reverse-i-search) ' ch ': echo "Hello,world" [Enter]
$hello, world


Third, cancel this command input: [Ctrl + c]

This shortcut allows you to safely exit from a command that you may have been bored with!! It may be a trivial trick, but experience tells me it's useful. Many Unix beginners will habitually press [Enter] to get out of trouble, but there might be catastrophic events, such as deleting an important profile: (


Four, the cursor jumps the shortcut key:

In order to facilitate the memory, add some English mnemonics in the back:)
[Ctrl + A] jumps to the command line ahead the line
[Ctrl + E] jump to command line end of Line[ctrl + F] forward a character jump Forward one character
[Ctrl + b] jump back a character jump backward one character

[Alt + F] Jump forward to the first character of the next word
[Alt + b] jump back to the first character of the next word


shortcut keys for editing commands:
[Ctrl + W] Delete a word backwards to handle the error word just entered is useful [Ctrl + U] Remove all characters from the current position of the cursor to the beginning of the line
[Ctrl + K] Remove all characters from the current position of the cursor to the end of the line

[Ctrl + d] Deletes the character at the current position of the cursor

[Ctrl + y] paste the last deleted word

[Alt + d] Deletes the character from the current position of the cursor to the end of the current word


six, configuration tips;

If you are using Gnome's terminal window gnome-teminal, the Gnu Shell shortcuts above will conflict with Gnome's window shortcuts.

Then you need to do the following configuration:

In the Gnome-terminal menu bar, select "Edit"-] "keyboard shortcuts ..." To open the Keyboard Shortcuts dialog box and tick the following two options

"Disable all menu access keys (such as alt+f to open File menu)"
"Disable menu shortcut key (F10 by default)"

As to how KDE should match the terminal window of KDE, please be familiar with the KDE friends, I have not used KDE for a long time, nor installed.


seven, comprehensive exercise;

The shortcuts listed above, practice 2-3 days should be able to skilled, for everyone to quickly understand and memory, we do a small comprehensive exercise:

First step: Echo

$ echo "Hello, World." [Enter]

We first enter the echo "Hello, World", and then return to the output of the terminal:

$ Hello, world.

Step Two: [Ctrl + R]

Let's try to find the history command echo "Hello World." At this time, we press [E],[C],[H] These three keys, this historical command has probably been found,
The display of the terminal should be this way:

(reverse-i-search) ' Ech ': echo "Hello,world."

Now, if [Enter] will execute this command again, but let's practice the command line edit now.

Step three: [Ctrl + A]

In this way, we take out the history command echo "Hello, world." and position the cursor at the beginning of the line, at which point the cursor should be lit up on the e character of the echo command.
The display of the terminal should be this way:

$ echo "Hello,world"


Fourth step: [Alt + d]

The command echo was removed and the cursor is still at the beginning of the line, and the terminal appears as:

$ "Hello, world."


Fifth step: Enter command "printf"

Let's try to replace the shell command echo with a Posix system call printf, and enter [P][r][i][n][t][f], where the terminal appears:

$ printf "Hello, world."

And the cursor is highlighted behind the F character.

Sixth step: [Ctrl + E]

The cursor jumps to the command line tail.

Seventh Step: [Ctrl + b]

The cursor is back one character, and the cursor should be highlighted at the back double quotation mark.

Step Eighth: Enter the newline escape character "n"

Enter [][n], at which point the terminal display should be:

$ printf "Hello, WORLD.N"

can be executed [Enter].

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.