Recently, due to some messy stuff with master boot record, I have to re-install my Ubuntu. Before doing that, I back up all folder (exclude root, bin, sbin, tmp, media, mnt) to a NTFS partition. After installation of Ubuntu, I copied back all the folder using a nautilus (running by sudo nautilus). After that, I reboot my computer. And boom, now I cannot run sudo any more, my network services cannot run. When I run sudo from a terminal, I ge "must be setuid root" error. In ubuntu, root account is disabled by default, I don't know why all these files is no longer under ownership of my account. How would I recover back?
4 Answers
sudo command must have setuid permission bit set on it's executable. But in Ubuntu you currently cannot become root. I think you can boot from emergency disk and set this bit on sudo using chmod.
-
chmod? My account was not in the account list of the rescue ubuntu, how can I recover my ownership? Feb 4, 2010 at 12:04
-
chmod
is not about ownership, but about file permissions. you meanchown
.chmod
can be used without specifying an account. Feb 4, 2010 at 12:50 -
You cannot chmod protected files like sudo being not root. You need to use chmod, not chown to set permission bit "setuid" en.wikipedia.org/wiki/Setuid Feb 9, 2010 at 8:01
As Fractalizer said, this is an issue with the setuid bit on sudo. A detailed explanation of how to fix it can be found here: http://ubuntuforums.org/showthread.php?t=219767
There's a pretty good chance there will be other issues beyond this program. So you may find other things blowing up once you resolved the specific problem with sudo. Unfortunately, cp'ing to an NFS share isn't going to retain all the permissions you'll need for a fully functioning system. Especially in places like /usr/bin.
your files no longer belong to your account, because you copied them as root. this way root became the owner.
to get back to sudo, mount your root partition from a rescue environment and edit etc/group
. add your user account to the admin group and you should have sudo access again.
after that you can change ownership of the copied files. do you have another ubuntu installation where to look for the correct ownership?
-
My account was the same across two installation (i.e. phuongnd08). Even the password are same. I checked /etc/group and saw my account was set as adm (I guess it is administration). Feb 4, 2010 at 12:04
-
when you have another machine with the same accounts: boot your "failed" machine with a working network in rescue mode and do a
rsync -av <working host>:'/root /bin /sbin /tmp /media /mnt' /mnt/.
this way you will get the files with correct ownership and permissions. Feb 4, 2010 at 12:56
As the others have already said, this is a permissions issue.
First, you copied to a NTFS partition, which has different permissions, so yo are likely to lose some information in the process, although I have never tried it.
Second, you probably should have copied the files with cp -p
to preserve mode and ownership.
The best option is to use tar
(or equivalent) and I guess you mistyped the command with its options. A simple way to do a backup is something like
tar cf /path/to/backup.tar /usr /bin /var
Also, as others have mentioned, rsync
is a valid option.
tar
when you dotar -czf file.tar.gz
. It is a good thing too, since you meant to typetar -xf file.tar.gz
to extract the stuff from the archive.