LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Irritation Removed: You Do Everything As Root And Hate Manually Removing Sudo From Copy-Paste Commands

sudo sandwichOn LowEndTalk, we’ve been having a conversation about how the venerable sudo command is coming to Windows.  Personally, I think that’s a bit weird.  Not that Windows might need some terminal equivalent to sudo, but why call it sudo?  That’s a very non-Windows name.  But whatever.

For the unfamiliar, sudo allows you to run a command as another user, often root.  A typical scenario is where a user needs to run one command as root, but the system administrator doesn’t want to give away all the keys to the kingdom.  Using sudo they can give the user permission to run one command and only one command.

That’s great for sudo’s original intent: multi-user systems with segregated privileges.

For the hobbyist, it’s often burdensome.

Of course, there’s a class of nerds who are going to insist you should do everything as an unprivileged user and never ever login or do things as root.  I saw a passionately argued article some years ago where the author excoriated those who’d download a tarball and compile/install as root.  You’re supposed to untar and compile as an unprivileged user and then type ‘sudo make install’.  OK, dude, but that really isn’t buying you anything.

As a hobbyist, I disable root logins, but once I’m on the box I ‘su -‘ and do a lot of work as root.  Partly that’s because I’ve ben sysadminning systems since the early 90s, partly because I’m careful, and partly because it’s my own stuff and it’s not like I’m going to scram the reactor if I type reboot in the wrong window.

Typically I don’t even install sudo and I think that’s pretty common among hobbyists.  LowEndTalk member @darkimmortal commented:

I keep it uninstalled on all my systems and don’t miss it except for the annoyance of editing it out of copy+pasted commands

Indeed.  If you’re installing something and following along a GitHub README, often times the commands will be prefixed by ‘sudo’.  If you don’t have sudo installed, these commands will fail.  @Erisa asked:
I wonder if you could replace sudo with a basic alias or shell script which shims the behaviour expected by other scripts by replacing it with other equivalent commands? Or if you were running this commands as root anyway, an even more basic shim that just runs the command as-is.
I thought about this and here’s what I’ve come up with:
alias sudo='/usr/bin/true && '
With that alias in place,if you then type something like
sudo make install
it is expanded to
/usr/bin/true && make install
This means “first run the true(1) command.  If it succeeds, run make install”.  Since true(1) always succeeds, this alias is essentially a NOP (“no operation” – does nothing).  This allows you to copy-paste commands that are prefixed with ‘sudo’ without having to first edit them.
sudo nuke


  1. What will happen if you use an empty string?

    alias sudo=’ ‘

    February 27, 2024 @ 11:39 am | Reply
  2. James Stroud:

    I have similar experience as you and do the same thing on my own home systems except if the commands ask for sufo I just preface all of the commands with the following.

    dnf install Sudo -y
    apt install sudo —y

    Especially if it’s a docker container

    As you know when you tar and extractor file as root if that file has malicious code, it could do more harm if it’s run as the root user

    March 27, 2024 @ 12:36 am | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

Your email address will not be published. Required fields are marked *