Powerful shell commands

Source: Internet
Author: User

1. CTRL + W Delete the last word

2. CTRL + u delete a row

3. CD-Return to the last working directory

4. Cd ~ Return to the Home Directory

5 .! $

! $ Is a special environment variable, which represents the last string of the previous command.

Example:

Mkdir mydir

Mvmydir yourdir

CD yourdir

It is equivalent:

Mkdir mydir

MV! $ Yourdir

CD! $

6. sudo !!

Run the previous command as root.

Example:

For example, if we use apt-Get In ubuntu to install the software package as root, we may often forget to add sudo before apt-Get. Every time you have to add sudo and re-type this line of command, you can easily use sudo !! Done.

Note:

In Shell, sometimes a long command is entered, which can be used! Xxx to repeat the latest command. For example, if you have input Vim/home/Jibo/tiger before, you can use it directly next time! Vim repeats the last recent Vim command.

7. CD-

Return to the last directory.

For example, if the current directory is/home/a, use CD ../B to switch to/home/B. In this case, you can execute the CD-command repeatedly to switch back and forth between/home/a and/home/B.

8. 'alt +. "And <ESC> + ."

You can repeat the parameters of the last command line.

9. ^ old ^ new

Replace some strings in the previous command.

For example:

Echo "wandreful", in fact, wants to output echo "wonderful ". As long as ^ A ^ o is enough, it will be of great help for spelling long commands.

10. Du-S * | sort-N tail

List the top 10 files in the current directory.

11. Echo "LS-L" | at midnight

Run a command at a certain time.

 

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.