You are not logged in.

#1 2023-03-17 18:53:36

Emmmmllll
Member
Registered: 2023-03-17
Posts: 2

[SOLVED] Recover from "chown -R root:root /"

-- context (if interested / not necessary):

I accidentally broke my grub config file and had to recover it. During so I thought it would be a nice Idea to make a backup of my system disk. Smart me: instead of copying files, i moved them to another disk and copied them back. After that I reinstalled all packages, but every file now belongs to root (though luckily every file kept its permissions). After fixing grub when I booted in back in my system sddm showed a message that it couldn't write to '/var/lib/sddm/.config/[name of file]'. (continue in -- steps)

-- system Information:

# uname -srvmo
Linux 6.2.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 13 Mar 2023 17:02:08 +0000 x86_64 GNU/Linux

DE:
KDE Plasma Version: 5.27.3

Graphics Platform:
X11
xorg-server 21.1.7-1
libx11 1.8.4-1

-- steps:

I fixed my /var/lib ownerships by so (fixed sddm warnings)
# pacman -Qo $(find /var/lib -maxdepth 1)

also I recursively set my home directory to its user
# chown -R [username]:[usergroup] /home/[username]

still when I login in any other user than root the screen freezes and I can either change tty or reboot. Since I don't know if only plasma has a issue with the ownerships or other apps do as well, I would like to know the default ownerships which need to be set for proper running (or how to recover all of them if possible).

Kind regards
Emmmmllll

Last edited by Emmmmllll (2023-03-20 18:22:32)

Offline

#2 2023-03-17 20:41:28

twelveeighty
Member
From: Alberta, Canada
Registered: 2011-09-04
Posts: 1,081

Re: [SOLVED] Recover from "chown -R root:root /"

If I am reading your last sentence correctly, you may have undone some of your fixes by logging in as root into KDE. Don't ever do that. Instead, redo your fixes, then attempt to log in as a regular user. If it hangs again, switch to a TTY and try to log in as a regular user there as well - if that works, use that user or (if needed) elevate via sudo to locate logs (journal, X, etc.). If the TTY login as a regular user also doesn't work, log into the TTY as root and troubleshoot from there.

Offline

#3 2023-03-18 11:39:08

Emmmmllll
Member
Registered: 2023-03-17
Posts: 2

Re: [SOLVED] Recover from "chown -R root:root /"

Thanks for the hint of looking at the jounal,

# strace -fp $(pidof sddm) --target=file

gave me nothing, though thanks to the journal I could find the files needed for the first login. For the second login after a lock the journal was also helpful: this time the ownership wasn't the problem, but the set uid bit on /usr/bin/unix_chkpwd was missing.
When I checked

# ls -l $(which passwd)
-rwxr-xr-x 1 root root [some File Size] Mar 16 18:09 /usr/bin/passwd

I realized all set uid bits are reset.

Anyways: (Sorry I ckecked it only now)
I looked at my backup (reference to --context) and anyhow there are all set uid bits and ownerships how they should be. Seemingly moving files keeps the ownership and permission properties and copying them sets them to the user who copies them (probably since new files are created).

Now I'll write a script which sets the permissions and ownerships of my backup to my current files, but before I run that I would like to know:
Is it safe to set every permission/ownership of my backup to my current files/directories or should I leave certain files/directories out? (I already made some mistakes, so being careful this time)

Last edited by Emmmmllll (2023-03-18 11:41:29)

Offline

#4 2023-03-18 21:37:50

loqs
Member
Registered: 2014-03-06
Posts: 16,850

Re: [SOLVED] Recover from "chown -R root:root /"

I would suggest Tips_and_tricks#Reinstalling_all_packages which will fix the attributes on files and warn about differences detected in the attributes of directories.
That would then leave you with files / directories not managed by pacman to address.

Offline

Board footer

Powered by FluxBB