Subscribe to How-To Geek Mag-subscribe sa Paano-Upang Geek

Important! This is an automatic machine translated page. If you can read english, you should Click Here to read the original English version of the article.

Add Sudo to Your Last Bash Command With "!!" Magdagdag ng Sudo sa iyong Last Bash Command Sa pamamagitan ng "!" Syntax Syntax

How often have you typed in a command in your linux shell, and then realized that you forgot to type sudo, so you end up with an error or editing the dreaded read-only file? Gaano kadalas mayroon kang nai-type sa isang utos sa inyong linux shell, at pagkatapos ay nabatid na nakalimutan mo mag-type ng sudo, kaya tapusin mo up sa isang error o pag-edit sa dreaded read-only file? This happens to me much more than I'd like to admit, so I'm writing about it. Ito ang mangyayari sa akin ang higit pa na gusto kong aminin, kaya ako ng sulat tungkol dito.

You have a couple of options, the easiest one is to just use !! Ikaw ay isang pares ng mga opsyon, ang pinakamadaling isa ay para lamang gamitin! to tell bash to use the last command. upang sabihin sa Bash na gamitin ang huling utos.

For instance, if you tried to type this, you'd get an error that you are editing a read-only file: Halimbawa, kung ang iyong sinubukang i-type ito, gusto mo makakuha ng isang error na ikaw ay isang pag-edit sa read-only ng file:

vi /etc/apt/sources.list vi / etc / APT / sources.list

Once that happens, then you can just use this command: Kapag na mangyayari, at pagkatapos ay maaari mo lamang gamitin ang command na ito:

sudo !! sudo!

Which bash will then expand into this command: Aling Bash ay pagkatapos ay mapalawak sa mga utos na ito:

sudo vi /etc/apt/sources.list vi sudo / etc / APT / sources.list

Screenshot of this in action: Screenshot ng mga ito sa aksyon:

imahen

An alternative method would be to just hit the up arrow key, hit either the Home key or Ctrl+A, and then type sudo. Isang alternatibong paraan ay upang pindutin lamang ang up arrow key, pindutin ang alinman sa mga Home susi o Ctrl + A, at pagkatapos i-type sudo.

This article was originally written on 07/30/07 Tagged with: Ang artikulong ito ay orihinal na isinulat sa 07/30/07 Tagged with: Linux Linux

Daily Email Updates Araw-araw na Updates Email

You can get our how-to articles in your inbox each day for free. Maaari kang makakuha ng aming kung-paano na mga artikulo sa iyong inbox sa bawat araw para sa libre. Just enter your name and email below: Ilagay lamang ang inyong pangalan at email sa ibaba:


Name: Pangalan:
Email: Email:

Comments (11) Comments (11)

  1. Oliver Oliver

    Thanks. Salamat.

  2. Thomas Thomas

    Thanks you very much, this is very usefull. Salamat sa inyo, ito ay lubhang kapaki-pakinabang.

  3. Nep'n Nep'n

    That is surprisingly useful, I like the way you give us more than one way to do a lot of these things, the alternative methods can be useful for other stuff too Iyan ang nakakagulat na kapaki-pakinabang, katulad ko ang mga paraan na bigyan ninyo kami ng higit sa isang paraan upang gawin ng isang pulutong ng mga bagay na ito, ang alternatibong pamamaraan na maaaring maging kapaki-pakinabang para sa ibang mga bagay-bagay masyadong

  4. lachlan lachlan

    the !! ang! also works with other commands like man din gumagana sa iba pang mga utos ng tao

  5. arch arko

    Just wondering if it would be possible to create a script that would execute this or an alias in ~/.bashrc or something. Nagtataka lang kung ito ay posible na gumawa ng isang script na pugutan ng ulo ito o isang alias sa ~ /. Bashrc o ng isang bagay. I'm super-lazy so “sudo !!” is too many characters to type. Ako pinaka-tamad kaya "sudo!" Ay masyadong maraming mga karakter na uri. Why not something like “sss” The issue is that when I try a script or alias, it doesn't execute the previous command. Bakit hindi isang bagay na tulad ng "sss" Ang isyu ay na kapag sinubukan kong isang script o alias, ito ay hindi execute ang naunang command. Any ideas? Anumang mga ideya?

  6. A554551N A554551N

    I've been working on heavily modding my Ubuntu desktop, and whatever I google, howtogeek.com comes up as a top result. Ako gumawa sa mabigat modding aking desktop ng Ubuntu, at kahit anong google ko, howtogeek.com lumapit up bilang isang top resulta. Your suggestions, tips, and tricks are spot-on and incredibly useful, and I just wanted to say thank you. Ang inyong mga mungkahi, tips, at tricks ay na spot-on incredibly at kapaki-pakinabang, at ako lamang ang nais na sabihin salamat sa iyo.

  7. blu blu

    great, i love this one great, i love ang isang ito :)

  8. lowell Lowell

    no emacs love, huh? walang emacs pag-ibig, huh? ;)

  9. Kalamadea Kalamadea

    This is so useful – thanks a lot. Ito ay upang kapaki-pakinabang - thanks a lot. It's *SO* annoying to have go all the way to the beginning of a command to add sudo after you forgot to the first time. It's * * * * * * SO nakakainis na pumunta ang lahat ng paraan upang ang simula ng isang utos na idagdag sudo pagkatapos mong nakalimutan sa unang pagkakataon.

  10. Sam Sam

    Yes!!! Oo! This is one of the most useful things I have ever heard Ito ay isa sa mga pinaka kapaki-pakinabang na mga bagay-bagay ba ako may narinig

  11. Samik Samik

    Thanks! Salamat! This would help me a lot. Ito ay makakatulong sa akin ng isang pulutong.


Our Friends Ang aming mga Friends
Getting Started Pagsisimula


About How-To Geek Tungkol sa Paano-Upang Geek
What Is That Process? Ano ba ang Proseso Iyon?
svchost.exe svchost.exe
jusched.exe jusched.exe
dwm.exe dwm.exe
ctfmon.exe ctfmon.exe
wmpnetwk.exe wmpnetwk.exe
wmpnscfg.exe wmpnscfg.exe
rundll32.exe rundll32.exe
wfcrun32.exe wfcrun32.exe
Ipoint.exe Ipoint.exe
Itype.exe Itype.exe
Wfica32.exe Wfica32.exe
Mobsync.exe Mobsync.exe
conhost.exe conhost.exe
Dpupdchk.exe Dpupdchk.exe Adobe_Updater.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. Copyright © 2006-2009 HowToGeek.com. All Rights Reserved. All Rights Reserved.