Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of basic Linux Shell skills

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the "basic Linux Shell skills summary", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "basic Linux Shell skills summary" bar!

1. Automatic completion: [Tab]

Many people should know this trick by pressing the [Tab] key when entering a command, directory or file name. The system will help you make up what you may have to type, and if there are multiple selections, it will be listed. You can enter one or more charactor after reading it clearly, and then press [Tab].

Experiment:

$ec

Press [Tab] to complete:

$echo

Find and execute historical commands: [Ctrl + r], [Ctrl + p], [Ctrl + n]

Press and hold the [Ctrl] key at the same time [r] key in the terminal, the prompt appears: (reverse-i-search), then you try to enter the command you have entered before, and each time you enter a character, the terminal will scroll through your history command. When the appropriate history command you are looking for is displayed, the history command is executed directly [Enter].

In addition, [Ctrl + p] or [Ctrl + n] quickly scrolls forward or backward to find a historical command, which is useful for quickly extracting commands that have just been executed.

Experiment:

$echo "hello, world" [Enter] $hello, world

[Ctrl + r] (then enter echo)

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

Cancel the command input: [Ctrl + c]

This shortcut allows you to safely exit from a command that you may already be bored with! It may be a trivial trick, but experience tells me it is very useful. Many Unix beginners habitually press [Enter] to get out of trouble, but catastrophic events may occur, such as deleting an important configuration file: (

Fourth, the cursor jumps shortcut keys:

In order to facilitate your memory, add some English mnemonics at the end:)

[Ctrl + a] Jump to command line header Ahead of line

[Ctrl + e] Jump to the end of the command line End of line [Ctrl + f] Jump forward one character jump Forward one character

[Ctrl + b] Jump back one character jump Backward one character

[Alt + f] Jump forward to the first character of the next word

[Alt + b] jumps back to the first character of the next word

5. Shortcut keys for editing commands:

[Ctrl + w] deletes a word backwards, which is useful for dealing with the wrong word just typed. [Ctrl + u] removes all characters from the current position of the cursor to the beginning of the line.

[Ctrl + k] removes 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] removes the character from the current position of the cursor to the end of the current word

VI. Configuration tips

If you are using the terminal window gnome-teminal under Gnome, the Gnu Shell shortcut above will conflict with the window shortcut of Gnome.

Then you need to do the following configuration:

Select "Edit" -] "Keyboard Shortcuts..." in the menu bar of gnome-terminal. Open the "Keyboard Shortcuts" dialog box and check the following two check options

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

As for how to match the terminal window of KDE under KDE, please add that I haven't used KDE for a long time and haven't installed it.

VII. Comprehensive practice

The keyboard shortcuts listed above should be proficient after practicing for 2-3 days. For everyone's quick understanding and memory, let's do a small comprehensive exercise:

Step 1: echo

$echo "hello, world." [Enter]

We first enter the command echo "hello, world", then enter, and we will see the output of the terminal:

$hello, world.

Step 2: [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 history command has probably been found.

The terminal should be displayed as follows:

(reverse-i-search) `ech': echo "hello,world."

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

Step 3: [Ctrl + a]

In this way, we take out the history command echo "hello, world." and position the cursor at the beginning of the line, where the cursor should be highlighted on the e character of the echo command.

The terminal should be displayed as follows:

$echo "hello,world"

Step 4: [Alt + d]

The command echo is deleted, the cursor is still at the beginning of the line, and the terminal displays as follows:

"hello, world."

Step 5: enter the command "printf"

Let's try to replace the shell command echo with Posix's system call printf, enter [p] [r] [I] [n] [t] [f], and the terminal displays:

$printf "hello, world."

And the cursor highlights after the f character.

Step 6: [Ctrl + e]

The cursor jumps to the end of the command line.

Step 7: [Ctrl + b]

The cursor goes back one character, and the cursor should be highlighted at the back double quotation marks.

Step 8: enter the newline escape character "n"

Enter [] [n], and the terminal display should be:

$printf "hello, world.n"

It can be executed [Enter].

Thank you for your reading, the above is the "basic Linux Shell skills summary" content, after the study of this article, I believe you have a deeper understanding of the basic Linux Shell skills summary of this problem, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report