Common Linux commands (version 2) -- Shell application skills

Source: Internet
Author: User

Common Linux commands (version 2) -- Shell application skills
Shell application skills

TIPS:

1. Command completion function: <Tab> key

2. Clear screen: Ctrl + l

3. Delete all content before the cursor: Ctrl + u

4. Command history: history

At this time :! The command number listed by history to execute the command.

Example :! 188

In addition, you can press the arrow keys "dig" and "dig" to find commands previously executed.

 

Important skills:

1. Command alias:

Purpose: Make operations easier, and make commands easier to remember.

Alias: displays the alias defined by the system.

Define alias:

Alias copy = cp

Alias drm = "rm-rf" # defines the alias combination, which must be caused ""

Delete alias:

Unalias copy

Appendix-in most cases, these aliases are not set in UNIX systems!

2. Input/Output redirection:

0 (STDIN)-standard input, keyboard;

1 (STDOUT)-standard output, display;

2 (STDERR)-standard error output, display.

> Or> output redirection

Ls-l/tmp> test.txt // clear the original file content

Ls-l/tmp> test.txt // append

<Input redirection

Wall <test.txt // input redirection

2> error output redirection

Cp-R/usr/backup/usr. bak 2>/bak. error

3. Pipeline: Send the output of one command to another as the input of another command.

Ls-l/etc | more

Ls-l/etc | grep init # grep init/etc/inittab

Ls-l/etc | grep init | wc-l # The wc command is a counter.

4. Command Connector

1); # use; the separated commands are executed in sequence

Pwd; ls; date

2 )&&

Command1 & command2

Executed successfully

Failed to execute

# There is a logic and relationship between the execution of commands before and after the command is executed. Only after the successful execution of the command before and after the command is executed will the command be executed.

E. g.

Write Mary

Ls & pwd

Lskkk & pwd

3) |

Command1 | command2

Execute not run

Do not execute

# There is a logic or relationship between the execution of the preceding and following commands. Only after the execution of the preceding command fails is the execution of the preceding command.

E. g.

Write Mary

Ls | pwd

Lskkk | pwd

For details, refer to another series of blogs-four days proficient in Shell programming series:

Http://blog.csdn.net/zjf280441589/article/details/17455515

Http://blog.csdn.net/zjf280441589/article/details/17467069

Http://blog.csdn.net/zjf280441589/article/details/17487351

Http://blog.csdn.net/zjf280441589/article/details/17503985

5. Command replacement character

Command 1 'COMMAND 2' # Use the output of command 2 as the parameter of command 1 to simplify the operation.

E.g. ll 'which touch' # production view touch command details

Appendix-cat/etc/shells # list all shells supported by the current system

In Linux, bash/bin/bash is used by default.

Older UNIX bin/sh

Appendix-wc

Wc-l msg # check the number of lines in the msg File

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.