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 "!!" Dodaj Sudo to Your Last Bash ukaz s "!" Syntax Sintaksa

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? Kako pogosto ste vnesli v vašem linux ukaz v lupini, nato pa spoznal, da si pozabil na vrsto sudo, tako da boste na koncu z napako ali urejanje bal samo za branje datoteke? This happens to me much more than I'd like to admit, so I'm writing about it. To se zgodi, da mi veliko več, kot bi rad priznam, da pišem o tem.

You have a couple of options, the easiest one is to just use !! Imate nekaj možnosti, ena je najlažji šele raba! to tell bash to use the last command. povedati, bash za uporabo zadnji ukaz.

For instance, if you tried to type this, you'd get an error that you are editing a read-only file: Na primer, če ste poskusili s tem tipom, bi vi zaslužiti zmota to urejate samo za branje datoteke:

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

Once that happens, then you can just use this command: Ko se to zgodi, torej vi moči šele raba to zapoved:

sudo !! sudo!

Which bash will then expand into this command: Kateri bash bo nato razširi v ta ukaz:

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

Screenshot of this in action: Screenshot to v praksi:

image

An alternative method would be to just hit the up arrow key, hit either the Home key or Ctrl+A, and then type sudo. Alternativno metodo bi bila šele zadeti puščico gor ključ, zadeti niti ključ Home ali Ctrl + A in nato vnesite sudo.

This article was originally written on 07/30/07 Tagged with: Ta članek je bil prvotno napisan na 07/30/07 Tagged with: Linux Linux

Daily Email Updates Dnevni Email Updates

You can get our how-to articles in your inbox each day for free. Lahko dobite našo kako do člankov v vašo mapo »Prejeto vsak dan brezplačno. Just enter your name and email below: Preprosto vpišite vaše ime in e-pošto spodaj:


Name: Ime:
Email: E-pošta:

Comments (11) Komentarji (11)

  1. Oliver Oliver

    Thanks. Hvala.

  2. Thomas Thomas

    Thanks you very much, this is very usefull. Hvala lepa, to je zelo koristen.

  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 To je presenetljivo uporaben, mi je všeč način, ki nam jih več kot en način, da to veliko teh stvari, lahko alternativne metode, uporabne za druge stvari preveč

  4. lachlan lachlan

    the !! ! also works with other commands like man sodeluje tudi z drugimi ukazi, kot človek

  5. arch arch

    Just wondering if it would be possible to create a script that would execute this or an alias in ~/.bashrc or something. Šele začuden če bi bilo mogoče ustvariti skript, ki bi izvršiti to, ali alias v ~ /. Bashrc ali kaj podobnega. I'm super-lazy so “sudo !!” is too many characters to type. Jaz sem super-leni tako "sudo!" Je preveč znakov na vrsto. Why not something like “sss” The issue is that when I try a script or alias, it doesn't execute the previous command. Zakaj ne bi nekaj podobnega "sss", problem je, da ko sem se scenarij ali drugo ime, ne izvršiti prejšnji ukaz. Any ideas? Vse ideje?

  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. Sem delal na zelo modding svoj Ubuntu pult, in karkoli sem google, howtogeek.com pride gor kot top rezultat. Your suggestions, tips, and tricks are spot-on and incredibly useful, and I just wanted to say thank you. Vaši predlogi, nasveti in zvijače so na kraju samem in neverjetno koristna, in sem hotel reči hvala.

  7. blu blu

    great, i love this one velik, jaz ljubezen to ena :)

  8. lowell Lowell

    no emacs love, huh? no Emacs ljubezen, kajne? ;)

  9. Kalamadea Kalamadea

    This is so useful – thanks a lot. To je tako uporabno - hvala veliko. 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 * siten, da gredo vse do začetka ukaz dodati sudo potem ste pozabili, da prvič.

  10. Sam Sam

    Yes!!! Ja! This is one of the most useful things I have ever heard To je eden izmed najbolj uporabnih stvari, ki sem jih kdaj slišal

  11. Samik Samik

    Thanks! Hvala! This would help me a lot. To bi mi veliko pomagal.


Leave a Comment Pustite komentar




Leave your Pustite friendly prijazen comment here. comment here.

If you have a computer help question, Če imate računalnik pomagati vprašanje, click here to leave it on the forums kliknite tukaj, da ga pustijo na forumih instead. namesto.

Note: Your comment may not show up immediately on the site. Opomba: Tvoj komentar morda ne pokažejo takoj na mestu.

Our Friends Naši prijatelji
Getting Started Getting Started


About How-To Geek O Kako naj Geek
What Is That Process? Kaj je to proces?
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.