The Secret Superpowers of SUDO

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 71

  • @SlyEcho
    @SlyEcho 4 года назад +4

    4:22 visudo is not editing the sudoers directly, it is doing it through a temporary file that is checked for correctness on exiting, this is a protective measure since you may lose admin access if you mess up the file.

    • @GaryExplains
      @GaryExplains  4 года назад +1

      Yes, as it says in the man page: visudo locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors.

  • @paulalmquist5683
    @paulalmquist5683 4 года назад +10

    I used to teach Unix/Linux system administration. In those days logging in as root was acceptable practice. Then it was log in as an ordinary user then su to root. 2 different passwords had to be known. Now it's log in as ordinary user and sudo with same password. Seems less secure to me. I'm retired now. On my home network I use sudo -i to become root instead of keying sudo for every command. bash history logs all of the commands.
    FYI, doing rm -r /* as root is not instantaneous disaster as some claim. It takes a long time to wipe out a system because there are thousands of files to remove.
    Of course as root one must ALWAYS work carefully. Make backup of config files before changing them. Document your changes in the config file and a separate log file. For any command that is potentially destructive key your command, read it carefully a couple of times, think about it, edit as necessary, think again before pressing enter. Accuracy comes with practice but never get over confident. Sometimes the fingers, eyes and brain do not correctly coordinate.
    I enjoy your videos. Thanks for investing all of those heartbeats into them.

    • @angelcaru
      @angelcaru 3 года назад

      You need to be listed on the /etc/sudoers file in order to use sudo.

  • @catsoften
    @catsoften 4 года назад +6

    Did you know that those "incidents" get reported to Santa.

    • @12Q46HPRN
      @12Q46HPRN 4 года назад +1

      xkcd to the rescue!

  • @wallyhare8616
    @wallyhare8616 4 года назад +4

    And this whole time I just been retyping. Thank you sudo !!

    • @akkesm
      @akkesm 4 года назад +3

      Also !* stands for the arguments of the previous command, !:- for the previous command without arguments, !c for the last command that starts with c, and !n for the nth command in your history.
      History navigation is a more useful skill than most people think.

    • @codingsaroj18
      @codingsaroj18 4 года назад

      @@akkesm Wow, thanks for the info. I probably didn't know that until now.

    • @wallyhare8616
      @wallyhare8616 4 года назад

      I’m learning all kind of goodys today

    • @priit7777
      @priit7777 3 года назад

      Your keyboard doesn't come with UP arrow and HOME key? , , sudo, has worked for decades.

  • @lorrewatkins5925
    @lorrewatkins5925 3 года назад

    I just wanted to say thank U Gary ! I learn so much from your vids, and I hope U continue doing these great GE's stuff, because I think I'm not alone learning something new from your vids either novas or power-user, I think there's something to learn from all levels of users, so thanks again Gary and keep up the good vids !

  • @aryanghasemi
    @aryanghasemi 4 года назад +1

    Thank you Gary, I love sysadmin-related videos.

  • @hassanawodi5888
    @hassanawodi5888 4 года назад

    Superb Gary.

  • @venkateshhariharan4341
    @venkateshhariharan4341 4 года назад +1

    Great video, thank you

  • @JanJeronimus
    @JanJeronimus 3 года назад +1

    One important thing of sudo in a multi user system is the logging so you can trace important changes.
    However you also should limit commands that can be executed using sudo. Perhaps an idea to explain this in a next video.
    Be warned: It is also possible to do something like 'sudo csh' to start a cshell as root.

    • @tomsmansvards
      @tomsmansvards 3 года назад

      Yes, the idea of limiting sudo for certain commands for certain users/groups is something that seemed so "wow" for me when I first read about it in some manuals. However, me being the single user for my machines I have not found a use for that, but the idea is still something very interesting and I would like to hear how system administrators use it.

    • @JanJeronimus
      @JanJeronimus 3 года назад

      @@tomsmansvards Also as singe user on a system you should protect your system. Run (maintence) cron jobs ony with te rights needed to protect the system for errors. E g. an archiver needs read rights to a lot of locationd, however only write to the current backup/archive location. As user it is nice of you can read and copy the archive. However you can protect it by preventing delete/modify. You procect yourself for errors with the archive/backup (also in scripts) by limiting rights.

  • @D3ND
    @D3ND 4 года назад

    I really enjoyed this... Didn't know sudo was that configurable.
    What about the fields with ALL? Can we restrict some commands on specific groups? Or maybe some repositories? I would love a bit more advanced video on sudo

  • @cynodont7391
    @cynodont7391 4 года назад

    Another nice feature is the ability to allow users to execute specific commands as root without a password. For instance on my Debian machine, dmesg can only be used by root (because of the read access on /proc/kmsg) so I have the following sudoers rule to allow my user foobar to do a 'sudo dmesg' without a password:
    foobar ALL = (root) NOPASSWD: /bin/dmesg ""
    The empty argument "" after dmesg is there to prevent sudo from accepting additional arguments.
    WARNING: An attacker could abuse a command argument to read or write protected file.
    Other typical uses of that feature are load/unload of kernel modules and also write into protected /sys files (e.g. change the cpufreq governor, flush the disk caches before running a benchmark, ...).
    Also, users can run the command 'sudo -l' to get a summary of all relevant sudoers rules.

  •  4 года назад

    Nice! Thanks. I would be interested in a more in depth follow up.

  • @rubengutierrez2526
    @rubengutierrez2526 4 года назад +1

    Great video, I like the way you explain things. thanks Gary! ..question: I Am just starting to learn command lines, are there books or tutorials that you can recommend to really learn how to use command lines?? ... much appreciated.

    • @GaryExplains
      @GaryExplains  4 года назад +2

      I would suggest you start with this video ruclips.net/video/CpTfQ-q6MPU/видео.html and then watch all the videos in my Linux playlist.

    • @rubengutierrez2526
      @rubengutierrez2526 4 года назад

      @@GaryExplains thanks so much!!.. I will check them out, you see, there are are tons of people who know a lot , but not everyone knows how to explain things in a clear and concise way, not everyone knows how to teach

  • @alliejr
    @alliejr 4 года назад +1

    Brilliant! Never knew that “bang bang” was “pling pling”.

  • @1MarkKeller
    @1MarkKeller 4 года назад +1

    *GARY!!!*
    *Good Evening Professor!*
    *Good Evening Fellow Classmates!*
    Stay safe out there everyone!

  • @arisaardi7576
    @arisaardi7576 4 года назад +1

    Ah.. magical spell of sudo

  • @johnsimon8457
    @johnsimon8457 4 года назад

    There’s a lot of bits of Unix that make sense if you have a hundred users logged into a single system like the mini computers and dumb terminals of old.

  • @Chalisque
    @Chalisque 4 года назад +1

    On machines where security is not important, I like to 'sudo echo "ALL ALL = NOPASSWD: ALL" > /etc/sudoers.d/wideopen'

  • @YounesLayachi
    @YounesLayachi 4 года назад

    Very nice !

  • @send2gl
    @send2gl 4 года назад

    Very interesting, not sure I'll change anything as I am the only Linux user on my network.

  • @pirateman1966
    @pirateman1966 4 года назад

    Garry, "The sudo sorcerer".

  • @nitrovenom991
    @nitrovenom991 4 года назад

    Gary bro, what is task threshold and adaptive lmk?

  • @developerpranav
    @developerpranav 4 года назад

    Thank you! I wanted to setup a no password sudo account. This made it very easy :D

  • @muha0644
    @muha0644 3 года назад

    I can't believe you didn't mention the insults.
    TL;DR add "Defaults insults" and using sudo with sausage fingers becomes waaaay more entertaining.

    • @GaryExplains
      @GaryExplains  3 года назад

      Yeah, I skipped over that deliberately. I don't think insulting people for fun is a good idea.

  • @ivanguerra1260
    @ivanguerra1260 4 года назад

    Hey Gary, all this commands shit just look like years 70´s computing for me. When we are going to have implementations by one click on Linux ? Man, this is 21 century !

    • @ivanguerra1260
      @ivanguerra1260 4 года назад

      We are not going to be cliking keyboards for ever !

    • @GaryExplains
      @GaryExplains  4 года назад

      OK, I will fix that straight away. Just let me create world peace and solve world poverty and then I will be laser focused on this issue. 😂

  • @henrymach
    @henrymach 4 года назад

    Removing the sudo password was one of the worst ideas in the RasPi

  • @jimitsoni18
    @jimitsoni18 4 года назад +24

    "sudo make me a sandwich"

    • @pirateman1966
      @pirateman1966 4 года назад +6

      make: *** No rule to make target 'me'. Stop.

    • @JoelJosephReji
      @JoelJosephReji 4 года назад +7

      You are not in the sudoers file, this incident will be reported

    • @window.location
      @window.location 4 года назад +1

      bash: command not found

    • @ivanguerra1260
      @ivanguerra1260 4 года назад +1

      Undo´s brother !

    • @Neel631
      @Neel631 3 года назад

      .phony me:

  • @gigigigiotto1673
    @gigigigiotto1673 4 года назад +2

    i don't need sudo, I'M ROOT!!!!!!
    fun fact, in italian "io sudo" means "i sweat"

  • @anaywalunjkar
    @anaywalunjkar 3 года назад

    Not a Linux user, but sometimes I use Linux system and use cmd "sudo- su" what is that

    • @nevoyu
      @nevoyu 3 года назад

      Sudo su logs you into root
      Think it it this way.
      Superuser do switch user
      No user specified to you must be root who is the God of the system. For there must always be a user.

  • @codingsaroj18
    @codingsaroj18 4 года назад +9

    "sudo !!" will probably be the most useful one for me although I did something like up arrow then home then type "sudo " which is also very fast.
    Thanks for revealing the "super" powers.

    • @RonnieNissan
      @RonnieNissan 4 года назад +2

      `Ctrl+e` takes you to the end of the line, `Ctrl+a` takes you to the beginning. `Ctrl+f` takes you forward one character, `alt+f` takes you forward one word, same commands with `b` will do the reverse. Because the shell uses emacs key bindings.

  • @Chalisque
    @Chalisque 4 года назад

    Also sudo su - username is another way to accomplish sudo -i -u username

  • @WDCallahan
    @WDCallahan 4 года назад

    Su does stand for substitute user. Saying switch user is also acceptable. But claiming that it stands for superuser is unacceptable because 90% of the time we use it, we're already root and we are becoming someone else to test that's users environment permissions. Sudo is almost universally preferable to actually becoming root.

    • @GaryExplains
      @GaryExplains  4 года назад +5

      Sorry, but "90% of the time we use it, we're already root" might be true for you, but that has never been true for me. When I started using Unix back in 90s it was common for people around me to call su superuser because you substitute user to root who is the superuser. PS. I love your confidence is declaring what is acceptable and what is not acceptable. LOL.

  • @android199ios25
    @android199ios25 4 года назад

    David can edit sudoers and disable lecture...

  • @Psop-mq8si
    @Psop-mq8si 4 года назад +1

    OpenDoas > sudo

  • @Mnogojazyk
    @Mnogojazyk 4 года назад

    sudo -- the magic wand of Linux
    Sorry for my quip.

  • @bbq1423
    @bbq1423 4 года назад

    visudo opening nano 🤔

    • @GaryExplains
      @GaryExplains  4 года назад

      There are details in the visudo man page about how it chooses the editor. The term "visomethingorother" comes from the vipw legacy.

  • @priit7777
    @priit7777 3 года назад

    not in sudo group, but can sudo just fine...

    • @angelcaru
      @angelcaru 3 года назад

      You can list individual users on the sudoers file.

  • @ichisadashioko
    @ichisadashioko 4 года назад

    666 likes, 6 dislikes, and 6100 views

  • @OmDahake
    @OmDahake 4 года назад +2

    My second comment

  • @bondthefifth
    @bondthefifth 3 года назад

    sudo is pronounced sudo and not sudo

  • @slinkypinky2012
    @slinkypinky2012 4 года назад +1

    Wow, my first "First!" comment