UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hello ive been messing around with my linux and by accident i did this:
chmod -R 777 /*
now im getting errors like
"cant set gid" "cant set uid" or something, which are preventing me from switching to root, or using "sudo".
i'm running ubuntu 7.04
how do i undo this mess?
There's no "undo" function for that. You should be aware of running recursive commands like that, especially on the root of the filesystem. Usually user permissions would prevent you from doing things like that (for other files than those you own), but seems like you ran the command with higher privileges; maybe with sudo. Anyway, it can't be just undone, you have two choices: either review a working system, see what the permissions should be per each file you changed and use chmod to change the permissions back (takes a veeeeeeeeeeeery long time, or even longer) OR reinstall the thing. In the latter case, take a backup of your /home/username homedirectory, install the OS again (overwriting the existing installation) and put the backup back. Then make sure your _own_ files' permissions in your homedirectory are set up correctly, by running chmod recursively on your _own_ home directory (to take away the 7-rights from other users than you to your files).
This is why root account usage is dangerous, if it's "just done" and not thought about twice
hehe i noticed later that there is a very clear flag to prevent this...
my system is broken anyhow so a reinstall would be fine...
thanks anyway guys :P
Check if your package system has the equivalent of rpm's --setperms and --setugids options. You may be able to fix the permission problems that way. Start with the package that supplies the filesystem. It might be called base or filesystem, however I'm not familiar with Ubuntu to say. In the future, leave things outside your home directory alone. Making system directories world writable is very dangerous. When windows did it with the C: drive viruses could spread like wildfire.
Unless you have a good reason, leave all the permissions they way they are setup at installation.
More generic answer: Set the permissions according to how your system is going to be used. Only you know who should have permission to do what. With applications (base or otherwise), the execute permission is the important one. Do you have users that you don't want to have access to certain applications? ...Do you want to be forced to su to root in order to mount something?
If you mount an external drive, for storage, you might want to make yourself the owner and group owner of the drive and use 770 permissions on all of the directories. If you are setting up a directory to share on the network, and it is globally writable, the set the sticky bit on the directory. The ownership's and permissions on system directories should stay the way the system sets them up. Usually the owner and group owner is root. Files like /etc/passwd need to be read by programs running as a user, while other files may be private to root or owned by a system users such as mysql.
For some services, like sshd, you will want to make some changes to the configuration files to make the service more secure. Mysql comes with a large manual, and there is a chapter on securing it.
ok i understand the security issues, but i have a problem - i cant run sudo or su at all!
why is that?
how can i fix that?
i will deal with the security later, i need a root shell right now though...
ok i understand the security issues, but i have a problem - i cant run sudo or su at all!
why is that?
how can i fix that?
i will deal with the security later, i need a root shell right now though...
Based on the earlier description, I suggested re-installing. If you don't want to do that, you can maybe recover control by booting into single-user mode, or by editing the /etc/passwd file.
single-user mode:
reboot, and then stop the grub countdown with the tab key. Get into edit mode and enter "single" at the end of the kernel line. then boot.
edit passwd:
boot from live CD (eg you install CD) and mount the partition where / is mounted. Edit the /etc/passwd file to remove the first "x" in the entry for <username>. reboot and you should be able to log in without a password.
You can also do this to the root entry to enable root login, but it probably will still not allow root to log in to the GUI.
If you don't want to reinstall or can't or can't restore from a backup, this list from my system might help you get started fixing the permissions. You will probably need to boot up with a rescue disk at first.
hey guys just to make myself perfectly clear:
i backed up ALL my data before i started joshing around with my system.
this whole shindig is for educational purposes only!
right now im learning linux by trial and error, and i wanted to know why i get setuid and setgid errors after i changed the root dir permissions.
Quote:
Your failure to use sudo may be to to resetting the suid bit:
update: thanks for the tips, i managed to fix su and sudo, by resetting the sid and gid bit for /usr/bin/sudo and setting the gid bit for /bin/su, all through single user mode boot.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.