sudo is a powerful utility that lets you run commands in a child process. This process will have your own user ID (UID) and set the appropriate security context for the command.

This can be useful if you need to configure a secure server or perform an elevated command, like installing an application. You would then run this server as the user who created it, with the setuid bit set so it can execute commands.

Usually, this is done by creating a new file or directory owned by the user who wants to run programs, and puttingsudo on it. Then, the program owner can add sudo to their shell’s startup options so they can run programs directly without having to type its name first.

Find the line that starts with “# User…”

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

There are two lines that start with this hashtag, so do not worry about checking both of them. The first one is for Sudo, the line that starts with “# User…” and the second one is for Setuid, the line that starts with “# User…”.

Sudo is used to run commands as a specific user. This user must have permission to run commands on the system.

SetUID accounts can be useful for performing some privileged actions on the system, such as installing an application or changing a configuration setting. These accounts should always be protected with setpiked and sudoers, as well as using caution when running commands.

Change the line to match your user

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

If you want to run a different uid/uid pair for your user, then you can set the sudoers line to say your user’s uid and password. This will override the uid/password match in sudoers.

To do this, change the line in your .sudoers file from Uid${USERNAME}.${USERPW}@[email protected]$( Piper ) to Uid0/${USERNAME}.${USERPW}@[email protected]$( Piper ).

Now whenever a user with that username and account settings login, their sudon will be changed to their own user’s account instead of the default admin account.

Save and close the file

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

If you’re running an automated system, make sure to save and close the sudoers file. This helps ensure your system continues to run as intended despite changes to the file.

If you are running a human-operated system, make sure to test your configuration by entering the empty command. You should be able to change your user’s su permissions and run some commands as expected.

Run the following command to make sure your user is in the sudoers file

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

If you see the entry for your user, then you’re ready to proceed! If not, then you need to make your entry.

To make your entry, type the following command and then press Return:

sudo visudo \ | egrep ‘^sudou’ | cut -d”:” – all | sort -z

This command searches the file called sudoers for a line that starts with sudo and contains your user name. It then uses the cut command to remove any spaces between the sudo and your user name. Finally, it converts all instances of sudo into whatever your user’s reassignment of privileges needs to be.

Run the following command to check if setuid bit is set

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

The setuid bit needs to be set on sudo so that you can run the su command. To check if the setuid bit is set, we can use the setu command.

setu is a shell function that will do this for us. We will use it in our sudoedit flows later on in this article.

Run the following command to check if /usr/bin/sudo is owned by uid 0

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

If the ownership is not set, then you can make it so with the following command.

# chown root:0 /usr/bin/sudo

This changes the group ID for /usr/bin/sudo to 0, making it owned by uid 0 and having the setuid bit set.

# chmod 0775 /usr/bin/sudo

And that’s it! You have successfully made your superuser able to run commands using sudo.

LEAVE A REPLY

Please enter your comment!
Please enter your name here