Civilloquy
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Waffelson@lemmy.world to linuxmemes@lemmy.world · 1 year ago

When you realized you forgot sudo

lemmy.world

message-square
11
fedilink
282

When you realized you forgot sudo

lemmy.world

Waffelson@lemmy.world to linuxmemes@lemmy.world · 1 year ago
message-square
11
fedilink
alert-triangle
You must log in or register to comment.
  • kmirl@lemmy.world
    link
    fedilink
    English
    arrow-up
    36
    arrow-down
    1
    ·
    1 year ago
    fuck() {
        sudo $(fc -ln -1)
    } 
    

    This function takes the last command and puts sudo in front of it. Actually used it in a zoom call at work without thinking and it took a second to realize why everyone was laughing. Not my invention–came across it years ago on stackoverflow or someplace and thought it was funny/useful.

    kmirl@tux:~$ ls /root
    ls: cannot open directory '/root': Permission denied
    kmirl@tux:~$ fuck
    [sudo] password for kmirl: 
    bin  debs  docs  Mail 
    
    • folkrav@lemmy.ca
      link
      fedilink
      arrow-up
      22
      ·
      1 year ago

      Considering the function name, here’s an obligatory thefuck plug

    • Rustmilian@lemmy.world
      link
      fedilink
      English
      arrow-up
      13
      ·
      edit-2
      1 year ago
      alias fuck='sudo $(fc -ln -1)'
      
    • Esca@lemmy.one
      link
      fedilink
      arrow-up
      13
      ·
      1 year ago

      Isn’t this the same effect as just running ‘sudo !!’ ?

      • subtext@lemmy.world
        link
        fedilink
        arrow-up
        10
        ·
        1 year ago

        According to this super user question, someone said that !! won’t work in a function, so you must use the fc -ln -1 command in a subshell instead. Note the response that says eval shouldn’t be used (not sure why)

        • Esca@lemmy.one
          link
          fedilink
          arrow-up
          6
          arrow-down
          1
          ·
          1 year ago

          Yeah but instead of a function you just make it an alias.

          • subtext@lemmy.world
            link
            fedilink
            arrow-up
            1
            arrow-down
            1
            ·
            1 year ago

            Oh good point, I didn’t think about that

      • Cinnamon3431@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        no because it takes the previous command and adds sudo to it right?

        • subtext@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          edit-2
          1 year ago

          !! is a shortcut for whatever the last command was is it not?

          E: https://devhints.io/bash#history

  • RoyaltyInTraining@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    One of the many reasons why I use micro

  • ѕєχυαℓ ρσℓутσρє@lemmy.sdf.org
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    1 year ago

    Use suda.vim for automatically dealing with such cases. Works with neovim as well.

    I’ll also recommend adding the following to your init.lua or some config file because suda doesn’t play nicely with nvim -d or vimdiff.

    -- Disable Suda in diff views
    if not vim.api.nvim_win_get_option(0, 'diff') then
        vim.g.suda_smart_edit = 1
    end
    

    The vimscript version of the same would be:

    " Disable Suda in diff views
    if ! &diff
        let g:suda_smart_edit = 1
    endif
    
  • ordellrb@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    deleted by creator

  • AMDIsOurLord@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    deleted by creator

  • 👍Maximum Derek👍@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    deleted by creator

linuxmemes@lemmy.world

linuxmemes@lemmy.world

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !linuxmemes@lemmy.world

Hint: :q!


Sister communities:
  • !tech_memes@lemmy.world
  • !memes@lemmy.world
  • !lemmyshitpost@lemmy.world
  • !risa@startrek.website

Community rules (click to expand)

1. Follow the site-wide rules
  • Instance-wide TOS: https://legal.lemmy.world/tos/
  • Lemmy code of conduct: https://join-lemmy.org/docs/code_of_conduct.html
2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack users for any reason. This includes using blanket terms, like “every user of thing”.
  • Don’t get baited into back-and-forth insults. We are not animals.
  • Leave remarks of “peasantry” to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn, no politics, no trolling or ragebaiting.
4. No recent reposts
  • Everybody uses Arch btw, can’t quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
5. 🇬🇧 Language/язык/Sprache
  • This is primarily an English-speaking community. 🇬🇧🇦🇺🇺🇸
  • Comments written in other languages are allowed.
  • The substance of a post should be comprehensible for people who only speak English.
  • Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
6. (NEW!) Regarding public figures

We all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations.

  • Keep discussions polite and free of disparagement.
  • We are never in possession of all of the facts. Defamatory comments will not be tolerated.
  • Discussions that get too heated will be locked and offending comments removed.

 

Please report posts and comments that break these rules!


Important: never execute code or follow advice that you don’t understand or can’t verify, especially here. The word of the day is credibility. This is a meme community – even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don’t remove France.

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 695 users / day
  • 2.41K users / week
  • 5.98K users / month
  • 15.7K users / 6 months
  • 1 local subscriber
  • 26K subscribers
  • 1.43K Posts
  • 56.2K Comments
  • Modlog
  • mods:
  • Kevin@lemmy.world
  • zephyr@lemmy.world
  • rtxn@lemmy.world
  • BE: 0.19.5
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org