In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "what is the Shell command". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Shell, also known as the command line interface, is the interface between users and computers under the * nix operating system. The word Shell refers to a program in an operating system that provides access to kernel services.
Popular science
First, popularize a few facts that you may not know:
Shell was born almost at the same time as the Unix operating system, and the first Unix Shell was rewritten by Ken Thompson in 1971, based on the model Shell on Multics, and named Thompson sh. Even the later popular bash (a variant of shell) is actually older than all the current popular Linux kernel, and it can be said that on the Linux system, there was Shell before Kernel. The default Shell in most of the current * nix and MacOS operating systems is bash,bash created by Brian Fox in 1987, the full name Bourne Again shell (bash). You may have heard that besides bash, there are Bourne shell (sh), Korn shell (ksh), C shell (including csh and tcsh), but did you know that there are about 50 different shell on this planet? To learn more about them, please refer to http://www.freebsd.org/ports/shells.html. Every month, a ranking of programming languages is given on tiobe to show the popularity of various languages. The ranking index combines the number of engineers using the language worldwide, the number of courses taught, and the number of third-party vendors. As of November 2012, bash ranked 22nd in tiobe's programming language rankings with an index of 0.56%. If you include its awk 0.21% and tcl 0.146%, it will probably rank 14th. Note that bash's homologous siblings such as csh and ksh are not included here. Counting them, the shell family is expected to be close to the top ten. It is worth mentioning that shell has always been a stable ranking, unlike some "nouveau riche" languages, such as objective-c, whose popularity is entirely due to the rise of the Apple family, but the craze is likely to come and go faster.
5. In Github, the largest source code repository in the world, the number of shell-related projects accounts for 8%, which is comparable to Java in the top 5, which shows that shell is invincible in actual combat engineering. For the source of the picture, see here
Some powerful commands.
Share some more shell usage and scripts that you may not know, simple & powerful!
Before reading the following sections, readers are strongly advised to open a shell experiment, which is not a major item in shell textbooks:)
1! $
$mkdir mydir
$mv mydir yourdir
$cd yourdir
It can be changed to:
$mkdir mydir
$mv! $yourdir
$cd! $
2 、 sudo!! Execute the previous command as root.
Scenario example: for example, root identity is required when installing software packages with apt-get in Ubuntu, and we often forget to add sudo before apt-get. Every time you have to add sudo and retype this command, you can easily use sudo! We're done.
[Chen Hao: shell blogger (@ left ear mouse) Note: under shell, sometimes you type a very long command, you can use! xxx to repeat the most recent command, for example, you typed vi / where/the/file/is before, you can use it next time! vi is as heavy as the last vi command. ]
3. Cd-go back to the last directory.
Scenario example: the current directory is / home/a, switch to / home/b with cd.. / b. You can then easily switch back and forth between / home/an and / home/b by repeatedly executing the cd-command.
(Chen Hao's note: cd ~ is to return to your Home directory, cd ~ user is to enter a user's Home directory.)
4. 'ALT+.' Or'. Hot-built alt+. Or esc+. You can repeat the parameters from the last command line.
5. ^ old ^ new replaces some of the strings in the previous command.
Scene: echo "wanderful", actually wants to output echo "wonderful". All you need is ^ a ^ o, which is of great help to the misspelling of long commands. (Chen Hao Note: it can also be used!: gs/old/new)
6. Du-s * | sort-n | tail
List the 10 largest files in the current directory.
7.: W! sudo tee%
Save a file in vi that only root can write
8. Date-dudes 1234567890
Time intercept time
9. > file.txt
Create an empty file that is shorter than touch.
10 、 mtr coolshell.cn
The mtr command is better than traceroute.
Add a space before the command line, and the command will not enter the history.
11. Echo "ls-l" | at midnight
Run a command at some time.
12. Curl-u user:pass-d status= "Tweeting from the shell" http://twitter.com/statuses/update.xml
Update twitter on the command line.
13. Curl-u username-silent "https://mail.google.com/mail/feed/atom" | perl-ne 'print"\ t "if / /; print" $2\ n "if / (. *) /;'
Check your gmail unread email
14. Ps aux | sort-nk + 4 | tail
List the first ten processes that consume the most memory
15 、 man ascii
Displays the ascii code table.
Scene: do you still need google when you forget the ascii code table? Especially in the case that the Chinese network is so "smooth", it is even more troublesome to apply the rules in GWF, just use the local man ascii.
16 、 ctrl-x e
Quickly launch your default editor (set by the variable $EDITOR).
17. Netstat-tlnp
Lists the port number on which the native process is listening. (Chen Hao Note: netstat-anop can show the process of listening on this port number.)
18. Tail-f / path/to/file.log | sed'/ ^ Finished: SUCCESS$/ Q'
Exit tail when Finished: SUCCESS appears in file.log. This command is used to monitor and filter the occurrence of a record in log in real time.
19. Ssh user@server bash < / path/to/local/script.sh
Run a script on the remote machine. The biggest advantage of this command is that you don't have to copy the script to the remote machine.
20. Ssh user@host cat / path/to/remotefile | / / img.jbzj.com/files/uploadimg/20121123/1109370.png-gravity NorthWest-background transparent-extent 720 × 200 output.png
Change the size of the picture
21. Lsof-I
View the activity status of the local network service in real time.
22 、 vim scp://username@host//path/to/somefile
Vim a remote file
23. Python-m SimpleHTTPServer
In a word, implement a HTTP service, set the current directory to the HTTP service directory, which can be accessed through http://localhost:8000, which is perhaps the simplest implementation of a HTTP server on the planet.
24. History | awk'{CMD [$2] +; count++;} END {for (an in CMD) print CMD [a] "" CMD [a] / count*100 "%" a}'| grep-v ". /" | column-c3-s "- t | sort-nr | nl | head-N10
(Chen Hao's note: it's a bit complicated, history | awk'{print $2}'| awk 'BEGIN {FS= "|"} {print $1}' | sort | uniq-c | sort-rn | head-10)
This line of script instincts to output the ten commands you use most often, so you can even gain insight into what kind of programmer you are.
25. Tr-c "[: digit:]" < / dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR= "1scape 32" grep-color "[^]"
Want to see the screen effect of Marix? Not very much, but also very Cool!
Do you understand the line of code? It doesn't matter, systematically learn * nix shell script, recommend "Linux command line and Shell script programming Daquan".
Finally, there is the wisdom of Shell: (Chen Hao Note: the mug below is very nice, 404null.com is very interesting).
"Where there is a shell,there is a way!"
Unix Shell discoloration mug
This is the end of the content of "what is the Shell Command". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.