Shell script, simple & powerful, shell script

Source: Internet
Author: User

Shell script, simple & powerful, shell script
This is a Shell that you may not know. It is taken from the Linus and Linux journal added by codenon. After reading this book recently, I think there is a lot of good content. This is one of the Shell desserts. I will share it with you and add some of my own testing content. I wrote this essay to share and improve everyone's interest in Shell. Before reading the following sections, we strongly recommend that you open a shell experiment. These are not big commodities in shell textbooks. :) 1. sudo !! Run the previous command as root. Scenario example: for example, if you use apt-get In Ubuntu to install the software package, you need the root identity. We 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 !! Complete. 2. cd-Return to the last directory. Scenario example: 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. 3. ^ old ^ new replaces some strings in the previous command. Scenario: echo "wandreful", in fact, is to output echo "wonderful ". You only need ^ a ^ o, which is helpful for spelling long commands. 4. man ascii display ascii code table. Scenario: Do I still need google when I forget the ascii code table? Especially when the tianchao network is so "smooth", it is more troublesome to apply the rules once in GWF. Use local man ascii. This function is very useful and often involves fuzzy coding and memory. 5. ctrl-x e to quickly start your default EDITOR (set by the variable $ EDITOR ). 6. netstat-tlnp: list the port numbers listened to by local processes. 7. tail-f/path/to/file. log | sed '/^ Finished: SUCCESS $/Q' when file. when Finished: SUCCESS appears in log, tail is exited. This command is used to monitor and filter logs in real time. 8. ssh user @ server bash </path/to/local/script. sh runs a script on a remote machine. The biggest advantage of this command is that you do not need to copy the script to a remote machine. 9. screen-d-m-S some _ name ping my _ router the background runs a program that does not stop and can view its status at any time. The-d-m parameter starts the "separation" mode, and-S specifies the ID of a session. You can run the-R command to re-mount the session of an identifier. For more details, see screen usage man screen. 10. wget -- random-wait-r-p-e robots = off-U mozilla http: // www. example. com download the entire www. example. com website. 11. curl ifconfig. me when your machine is on the Intranet, you can use this command to view the Internet IP address. 12. lsof-I can view the activity status of the local network service in real time. 13. python-m SimpleHTTPServer implements an HTTP server in one sentence and sets the current directory as the HTTP service directory. You can use http: // localhost: 8000 access may be the simplest HTTP server implementation on the planet. 1 [cdh42 @ master httpTest] $ python-m SimpleHTTPServer 2 Serving HTTP on 0.0.0.0 port 8000... 3 192.168.153.128-[27/Dec/2014 19:10:46] "GET/HTTP/1.1" 200-4 192.168.153.128--[27/Dec/2014 19:10:46] code 404, message File not found 5 192.168.153.128-[27/Dec/2014 19:10:46] "GET/favicon. ico HTTP/1.1 "404-6 192.168.153.128--[27/Dec/2014 19:10:46] code 404, message File not found 7 192.168.153.128-[27/Dec/2014 19:10:46] "GET/favicon. ico HTTP/1.1 "404-8 192.168.153.128--[27/Dec/2014 19:12:22]" GET/HTTP/1.1 "200-9 192.168.153.128--[27/Dec/2014 19:13:03] "GET/HTTP/1.1" 200-10 [cdh42 @ master httpTest] $ netstat-lnpt11 (Not all processes cocould be identified, non-owned process info12 will not be shown, you wowould have to be root to see it all .) 13 Active Internet connections (only servers) 14 Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name 15 tcp 0 0 0.0.0.0: 22 0.0.0.0: * LISTEN-16 tcp 0 127.0.0.1: 631 0.0.0.0: * LISTEN-17 tcp 0 0 127.0.0.1: 25 0.0.0.0: * LISTEN-18 tcp 0 0 0.0.0.0: 8000 0.0.0.0: * LISTEN 2574/python 19 tcp 0 0: 22: * LISTEN-20 tcp 0 0: 1: 631: * LISTEN-21 tcp 0 0 :: 1: 25: * LISTEN-View Code writes an index.html file in the directory. The result is as follows, it's fun.1

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.