288
je11zi
8y

"sudo !!" Will rerun your last command with sudo privileges in a Linux environment.

You're welcome.

Comments
  • 66
    Alt+. will copy the last argument of your previous command (and the ones before if you use it several times in a row).

    mkdir jsjsnshejdjdkfnrbrb
    cd <alt+.>

    You're welcome.
  • 36
    I've been using linux for years and never knew these whY DOES NOBODY TALK ABOUT THIS
  • 18
    @Notebookdeviant go to memrise.com and take shell-fu.
  • 4
    OMG these are really lifesaving tips! Thanks @je11zi & @Gauthier !!!
  • 21
    My personal favourite stupid one:
    alias fucking="sudo"
    :)
  • 6
    @alyx doing this immediately thank you
  • 5
    Control+Shift+R in bash lets you search for previously used commands. You're welcome
  • 8
    @Cube189 you're playing a dangerous game
  • 11
    @Cube189 you forgot the --no-preserve-root ;-)
  • 2
    @Rocket3G Ubuntu-proofing
  • 5
    Mates and matettes (?):
    https://github.com/nvbn/thefuck

    Works like a charm!
  • 5
    `!*` will return all arguments of the previous command eg:

    $ vi ~/.bash_profile
    $ source !*

    to edit your .bash_profile and source it
  • 2
    sudo apt-get update
    ^update^upgrade

    I think that still works...
  • 1
    @nmunro, yes: ^replaceThisPhraseFromLastCommand^withThisPhrase^ works in Bash
  • 2
    @RagnarRedbeard what does the shift do? Regex? I'm always happy with Ctrl+R
  • 2
    In the middle of a complex command, and you wish you'd type it in an editor? Ctrl+x Ctrl+e
  • 3
    @stable-penguin ^x^y works only for the first occurrence though. To replace all occurrences:
    !!:gs/this/that/
  • 2
    @Gauthier very true, thanks for catching that!
  • 0
    @Gauthier I'll have to try it without shift next time I'm at my computer!
  • 1
    So many great tips
  • 2
  • 1
    @Cube189 o believe me this is still very effective against Ubuntu I speak from experience
  • 0
    you can also do apt install, apt update and apt upgrade instead of apt-get
  • 2
    alias fuck='sudo $(history -p \!\!)'

    You are welcome
  • 1
    Have a stress ball sir.
  • 1
    @inpothet late post.. someone else commented and brought it back to life : )

    Anyways I think I heard something security related to apt-get? and people should he using apt? I'll double check -- your post made me think about it. Has anyone else heard about it?
  • 1
    Edit: I found it -- apt does a full upgrade while apt-get could leave you missing security/kernel updates depending on your config. Or that's what my 5 min research said 🙂 I personally use pacman which is one you'll never forget!
  • 0
    @stable-penguin I just use apt as it does the same as apt-get but is shorter been using it for about 3 months now and I haven't seen to mush differences
  • 1
    @inpothet and it's all shiny with colors and shine and progress bars, shiny. 💎👑🎇🎉🎖️💎
  • 1
    @inpothet I'm the unofficial family sys admin, especially since I convinced them all to switch -- they're all on Ubuntu Mate and I feel like I should have know this but actually learned the real reason today. I too was just using apt for the brevity.

    If you ever want to pull your hair out or nuke your 'buntu box try doing anything with the ncurses aptitude. I've tried a couple of times and always end up ctrl-c'ing my way out! Maybe it works for some people.
  • 0
    @inpothet also I think it's fair to say that with the right flags or configs yes they obviously can achieve the same.

    Like many *nix tools I think the devil is in the details, and if they're debian details, they were written at least today+=5 yrs ago! (the Debian documentation constant 😝)

    I think what I was remembering, and found, was that given a choice, with the defaults, we should prefer apt for security if nothing else. 😇
  • 0
    @stable-penguin I never changed a config and so far haven't nukes by box but I will watch out now
  • 1
    @inpothet I think it tells you if something was skipped. I'm sure you're fine
Add Comment