Linux sudo bang bang 到底是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15137461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 19:08:45  来源:igfitidea点击:

What exactly is sudo bang bang?

linuxbashterminalsh

提问by alestanis

What is the purpose of sudo bang bang (sudo !!) and when might one need to use it?

sudo bang bang ( sudo !!)的目的是什么,什么时候需要使用它?

make me a sandwich, sudo bang bang

make me a sandwich, sudo bang bang

采纳答案by alestanis

The bang bang (!!) command is a shortcut to repeat the previous command you entered in your terminal. This command is very useful when you forget that you need admin rights to make a certain action, and lets you repeat it with super-user rights just by typing

bang bang( !!) 命令是重复您在终端中输入的上一个命令的快捷方式。当您忘记执行某个操作需要管理员权限时,此命令非常有用,并且只需键入即可让您以超级用户权限重复该命令

sudo !!

instead of typing arrow-up, scrolling to the beginning of the line, adding sudoand hitting enter (imagine scrolling through those loooongapt-getcommands). So many seconds gained! Yay!

而不是键入向上箭头,滚动到行首,添加sudo并按回车键(想象一下滚动这些loooongapt-get命令)。获得了这么多秒!好极了!

sudo bang bang

sudo bang bang

There are many other bang-commands such as !x, !?x, !!:pand !!*. This blog postlists them and explains what they are for.

还有许多其他爆炸的命令,例如!x!?x!!:p!!*。这篇博文列出了它们并解释了它们的用途。