#Changed ownership of / directory

16 messages · Page 1 of 1 (latest)

sinful quartz
#

A bash program i created didn't work correctly and changed every owner of my / directory to my user ... recursive
I already fixed the problem that sudo doesn't work when the files aren't owned by root, by reinstalling sudo via a live usb sick and arch-chroot.

Now I want to change the perms back that root owns everything but it doesn't work

A quick overview of my cmd

emil@arch~$ ls -l /
total 52
lrwxrwxrwx   1 emil emil     7 Nov 21 09:56 bin -> usr/bin
drwxr-xr-x   4 root root  4096 Jan  1  1970 boot
drwxr-xr-x  21 root root  4780 Mar 23 20:25 dev
drwxr-xr-x  76 emil emil  4096 Mar 23 20:39 etc
drwxr-xr-x   3 root root  4096 Mar  8 16:08 home
lrwxrwxrwx   1 emil emil     7 Nov 21 09:56 lib -> usr/lib
lrwxrwxrwx   1 emil emil     7 Nov 21 09:56 lib64 -> usr/lib
drwx------  20 emil emil 16384 Mar  8 16:04 lost+found
drwxr-xr-x   3 emil emil  4096 Mar  8 16:57 mnt
drwxr-xr-x   5 emil emil  4096 Mar 11 18:00 opt
dr-xr-xr-x 601 root root     0 Mar 23 20:24 proc
drwx------   6 root emil  4096 Mar 23 16:46 root
drwxr-xr-x  24 root root   580 Mar 23 20:25 runA
lrwxrwxrwx   1 emil emil     7 Nov 21 09:56 sbin -> usr/bin
drwxr-xr-x   4 emil emil  4096 Mar  8 16:06 srv
dr-xr-xr-x  13 root root     0 Mar 23 20:27 sys
drwxrwxrwt  15 root root   540 Mar 23 20:47 tmp
drwxr-xr-x   9 emil emil  4096 Mar 23 20:30 usr
drwxr-xr-x  12 emil emil  4096 Mar 23 17:02 var

emil@arch~$ sudo chown root:root /etc/
chown: changing ownership of '/etc/': Operation not permitted

emil@arch~$ sudo su
[root@arch emil]# chown root:root /etc/
chown: changing ownership of '/etc/': Operation not permitted
serene hawk
#

i reckon just chroot and

chown -R root:root / && chown -R emil:emil /home/emil
vocal marten
#

You could restore dirs other than home from your backup

#

Or write a script which iterates over the backup files,dirs and saves the filename,owner,group to a file and reapplies them

sinful quartz
#

Okay, reinstalling will it be. Thanks a lot for your help.

A quick question bevor I start:
I have an second SSD on which I am installing the new system and mount the old ssd for copying. But what exactly do I have to backup (besides the home folder) for keeping my programms, or at least get a list of my programms from flatpak, pacman and yay so i can reinstall them automaticly? And how can i keep my programm and system Settings/where are they stored?

vocal marten
#

Dunno about flatpak

#

but those will be enough for official repos and aur

#

Use rsync -aAXv /old/home/* /mnt/home to copy the files from your home to the new home

sinful quartz
#

Thxxx, will that copy my Settings as well?

serene hawk
#

if your stuff is in ~/.config it should come
but there might be some default configurations you altered in other locations

vocal marten
sinful quartz
#

Thxxx, will that copy my Settings as well?

serene hawk
#

lol

#

well youre using plasma so i think so