[SOLVED] I did chown -R root:root /usr - did I screw it up?
SlackwareThis Forum is for the discussion of Slackware 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.
I did chown -R root:root /usr - did I screw it up?
I just realized I have installed some packages where I was the owner of all files and folders, and now I am the owner of those folders in the system. So I tried to fix it by just chown one directory at a time to root:root, started with /usr. After I did that I realized there might have been files that should not have root as both owner and group-owner... Is there a way to find out and fix this?
Bad hackers sometimes try to set permissions on everything so it is globally accessible. Due to this many secure programs actually expect a certain level of permission/ownership/group and if they don't have it will fail on the theory you've been hacked.
How to fix it depends on your distro. Many of the package managers include information about what permissions/ownership/groups files within the package should have after installation.
Is it possible to fix it if I reinstall all packages from the official repository? Is there a way to do that in one command? Or mount the iso and install those groups of packages I chosed during installation?
Which is the easiest way to fix this, or should I just reinstall from scratch?
I'm not sure exactly which packages I have installed that I have build myself. I try to remember to save them if I need to reinstall, but I have forgotten some. Is there a way to check /var/log/packages/ and find which of those does not exist in the official repository? I miss a log-file that says what packages I have installed/upgraded/removed, and at what date... (Comming from Arch, I just loved Pacman...)
"slackpkg clean-system" will prompt you for removing your added packages (if you don't have upgraded anything provided with slackware), obviously this is only for you to have a list, not for actually removing them (I don't think you want that).
you should also use the TAG variable when building your packages (use the BUILD one when rebuilding the official slackware packages), so that they are named ...lennie, for example, and you can do a "ls -la /var/log/packages/*lennie" and see your modifications.
the log you're looking for is the folder /var/log/packages (and /var/log/scripts too).
Quote:
Which is the easiest way to fix this, or should I just reinstall from scratch?
I have a vague memory that I have seen other threads with similar titles, and that I used to think "How can one even think of doing such a stupid thing..." I can't understand I did this... Just laughing at it now...
So it's easier to reinstall the whole system from scratch, than try to fix it by forcing it to reinstall all packages? Shouldn't that set ownership right? *hoping someone gives another answer* But if I backup my /home and save those unofficial packages that have the right ownership, then it shouldn't be too much work to start over again.
Okay, tomorrow... Now I'm to tired. I guess I shouldn't do anything more as root now. (I can't do anything with sudo, but su still works...) And I guess I should be careful what I'm doing as user with my /home, and my Data-partition...
The code snippet below is stolen to the SeTconfig script in Slackware's installer:
Code:
# These next lines are intended to clean up any permissions
# problems that could be caused by a bad package. We don't
# intend to make any bad packages here, but it never hurts
# to be safe. :^)
( cd $T_PX ; chmod 755 ./ )
( cd $T_PX ; chmod 755 ./var )
if [ -d $T_PX/usr/src/linux ]; then
chmod 755 $T_PX/usr/src/linux
fi
if [ ! -d $T_PX/proc ]; then
mkdir $T_PX/proc
chown root.root $T_PX/proc
fi
if [ ! -d $T_PX/sys ]; then
mkdir $T_PX/sys
chown root.root $T_PX/sys
fi
chmod 1777 $T_PX/tmp
if [ ! -d $T_PX/var/spool/mail ]; then
mkdir -p $T_PX/var/spool/mail
chmod 755 $T_PX/var/spool
chown root.mail $T_PX/var/spool/mail
chmod 1777 $T_PX/var/spool/mail
fi
In this code snippet '$T_PX' stands for /mnt which will be the root of the new Slackware distribution.
So my guess (only a guess) is if you run the 'chmod' commands with $T_PX="" you will get back the standard Slackware permissions.
This does not solve the ownership problem but I believe that
in /usr almost everything is owned by root.root. <standard disclaimer here>.
EDIT On an almost vanilla full Slackware 14 installation:
I didn't try it myself, but this script was mentioned several times before on similar occasions. It shoul be able to restore your permissions from the Manifest file that is found on the Slackware CD/DVD.
You must do that as root if you install it in the intended places, e.g. /usr/bin for binaries, as theses directories are writable only by root. If you install it in some non standard place like your home instead you can do that as a regular user depending on the ownership/permissions of that place but:
(1) some additional steps are required in that case to have the binaries or the libraries accessible.
(2) this is generally not recommended as it makes maintenance of applications and libraries problematic.
So, just use the packages management tools included in Slackware for installation and do that as root.
If asking the question you had that in mind: yes, generally speaking there is a risk in issuing a command as root, that's why you should only install packages from a trusted source: primarily packages included in the Slackware Linux distribution itself, then packages provided by one of the main Slackware contributors and packages you make yourself using a SlackBuild provided by one of the aforementioned sources or by http://slackbuilds.org.
And avoid as much as you can to install packages whose source code is not available, for safety concerns.
Last edited by Didier Spaier; 11-07-2012 at 10:38 AM.
Thank you all who tried to help me. I ended up reinstalling, it was actually the easiest and quickest way to get up and running again. Lesson learned - I hope...
You must do that as root if you install it in the intended places, e.g. /usr/bin for binaries, as theses directories are writable only by root. If you install it in some non standard place like your home instead you can do that as a regular user depending on the ownership/permissions of that place but:
(1) some additional steps are required in that case to have the binaries or the libraries accessible.
(2) this is generally not recommended as it makes maintenance of applications and libraries problematic.
...
Thank you all who tried to help me. I ended up reinstalling, it was actually the easiest and quickest way to get up and running again. Lesson learned - I hope...
Yep. There are two types of Administrator. Those that have screwed their systems up at least once and those that lie and say they never have.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.