sudo command is not working in ubuntu 14.04 - ubuntu-14.04

In my machine sudo command is not working and it is giving following message.
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
When I tried
ls -l /usr/bin/sudo it is giving
-rwxr-xr-x 1 'whoami' root 155008 Aug 28 2015 /usr/bin/sudo

It looks like, at some point, someone tried to take over ownership of the sudo executable but used single quotes rather than backticks:
chown 'whoami' /usr/bin/sudo # The wrong way
chown `whoami` /usr/bin/sudo # The right way
chown $(whoami) /usr/bin/sudo # Another right way
Note that I say "right way" but it's probably not something anyone should be doing anyway.
You're going to have to figure out some other way of getting into the root account (such as booting in single user mode) and changing the ownership and permissions back to what they should be:
chown root /usr/bin/sudo
chmod u+s /usr/bin/sudo
After that, it should be back at the correct:
-rwsr-xr-x 1 root root 155008 Aug 28 2015 /usr/bin/sudo

Related

/usr/bin/crontab execution failed: must be privileged to use -u System error: crontab execution error

I want to create a new cronjob via Plesk. After submit the configuration i get the error from my topic.
I have tried chmod and chown to the crontabmng without success.
my crontabmng owner is
root:root and the permission is -rwxr-xr-x
Check for suid bit 's' on /usr/bin/crontab:
# ls -la /usr/bin/crontab
-rwsr-xr-x. 1 root root 57552 Mar 31 2016 /usr/bin/crontab
SOLVED i think with the following:
service psa stopall
chown root.psaadm /usr/local/psa/admin/sbin/wrapper
chmod 4110 /usr/local/psa/admin/sbin/wrapper
chown root.psaadm /usr/local/psa/admin/sbin/mod_wrapper
chmod 4110 /usr/local/psa/admin/sbin/mod_wrapper
and the last step takes some time
service psa start
for now its all running and i get no errors.
hope it helps.

Edit file with shell script that is in the same group but not the caller user

I would like to edit a file with a shell script which is in the same group but not the "caller" user.
-rwsr-xr-x 1 root root 4896 Oct 21 00:59 /usr/bin/luxus
-rw-rw-r-- 1 root root 4096 Oct 20 23:01 <path>/file1
lrwxrwxrwx 1 root root 0 Oct 20 23:00 <path>/dir1
/usr/bin/luxus: the shell script
file1: the file to edit
dir1: file1's parent directory (symlink)
In the shell script, this is the line where the permission issue is:
echo "string" > /usr/bin/tee <path>/file1
Output:
/usr/bin/tee: <path>/file1: Permission denied
I am trying to create an AUR package for the shell script. The latter is meant to be install on the system from a PKGBUILD. In vain, I attempted to give enough permissions to the script to edit the targeted file.
This is a PKGBUILD's sample:
install -Dm755 src/${pkgname} "${pkgdir}/usr/bin/${pkgname}"
chown root.root "${pkgdir}/usr/bin/${pkgname}"
chmod 4755 "${pkgdir}/usr/bin/${pkgname}"
After investigating, I think it is quite simply impossible because of security or because of the parent dir's rights.
Nevertheless I am asking you for a solution.
As you said "you can't do anything".
The following post quite simply explains why it won't work:
https://unix.stackexchange.com/questions/364/allow-setuid-on-shell-scripts

sudo must be setuid root error already tried everything

I am getting following error while trying to switch to root.
[~]# sudo su -
sudo: must be setuid root
and I have confirmed the permission of sudo file set to correct
[~]# ls -l /usr/bin/sudo
---s--x--x 2 root root 190904 Mar 10 2014 /usr/bin/sudo*
also the user is already wheels group. please help
Please make sure that the user has normal jail access

sudo must be setuid root error

I am getting the following error while switching to root user
[~]# sudo su -
sudo: must be setuid root
The current permission of sudo is
[~]# ls -l /usr/bin/sudo
---s--x--x 2 root root 190904 Mar 10 2014 /usr/bin/sudo*
It's may CLOUDLINUX 5.11 x86_64 cPanel live server. Any suggestions on how to fix this?
Try to Enter system with recovery mode.(maybe Esc or Shift when start.)
Then choose the content row with 'root' in recovery menu.
Then:
#mount -o remount,rw /
#chown root:root /usr/bin/sudo
#chmod 4755 /usr/bin/sudo
now, restart...
try:
sudo ls
but if following exception raise:
#sudo: /usr/lib/sudo/sudoers.so must be owned by uid 0
#sudo: fatal error, unable to load plugins
Then you need entering recovery mode again and try:
#chown root /usr/lib/sudo/sudoers.so
restart...
I have fixed it my self. Currently the user is set to jailed shell and now I changed it to normal shell and could switch to root. – Techiescorner

Permission denied writing in directories with g+w mode on ubuntu

On ubuntu 10.04.4 server, I did this:
sudo mkdir -p /data/somedir
sudo chown -R www-data.www-data /data/somedir
sudo chmod -R g+w /data/somedir
sudo usermod -a -G www-data john ##john is current login user.
. With these operations done, I suppose to have write permission in /data/somedir. But when I did this:
echo "123" > /data/somedir/123
, I got:
-bash: /data/somedir/123: Permission denied
The ls -l output:
$ ls -l /data/
total 4
drwxrwxr-x 2 www-data www-data 4096 2012-04-24 22:30 somedir
Question is: why? Is there something I still need to do after that?
Changes made with usermod only take effect on following logins; your existing login session does not yet have the www-data group, as you can verify with id. It is not easy to alter the identity of running processes (newgrp might work); the easiest way to deal is to log out and back in.

Resources