You are not logged in.

#1 2016-01-11 10:51:47

2kanaa
Member
Registered: 2016-01-11
Posts: 2

Any way to recover after running false chown script?

Hello!

Is there any chance to manually or some other way to recover the system after running (as root) a uncompleted script:

--------------------------------------------------------------------
#!/bin/bash
dokuwikipath='/usr/share/webapps/dokuwiki'
htuser='http'
htgroup='http'

find ${wppath}/ -type f -print0 | xargs -0 chmod 0640
find ${wppath}/ -type d -print0 | xargs -0 chmod 0750

chown -R root:${htuser} ${wppath}/
chown -R ${htuser}:${htgroup} ${wppath}/
--------------------------------------------------------------------

Because the dokuwikipath was not specified correctly on the last two section of the script, it was interpreted as a root folder of the whole system "/" and now my system does not boot anymore (and right after running the script even the root user did not have rights to make for example "ls" command etc. I can still access the system offline with booting to rescue system from another media.  Any advice how to recover the system if that is possible?

Thanks!

Offline

#2 2016-01-11 11:15:44

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,737
Website

Re: Any way to recover after running false chown script?

You can use pacman's -k query option twice to find files which have incorrect permissions. You will then need to manually fix the permissions.

       -k --check
           Check that all files owned by the given package(s) are present on the system. If
           packages are not specified or filter flags are not provided, check all installed
           packages. Specifying this option twice will perform more detailed file checking
           (including permissions, file sizes, and modification times) for packages that contain
           the needed mtree file.

Since you can't boot, you will need to do this from a live environment. If you use the Arch installation image, you can use pacman's --root option to check the broken system without chrooting in.

It would be faster to simply reinstall.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2016-01-11 13:10:13

mouseman
Member
From: Outta nowhere
Registered: 2014-04-04
Posts: 298

Re: Any way to recover after running false chown script?

you can check all install packages with pacman -Qkk $(pacman -Qq). Optionally dump it to a file.

But as said, reinstall would be much faster. If you save your home and etc dirs it might be easier restoring settings if you made a lot of customizations. Also, you can use the pacman -Qq command to dump the installed packages and make reinstallation quicker.

Offline

#4 2016-01-11 13:23:38

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,737
Website

Re: Any way to recover after running false chown script?

mouseman wrote:

you can check all install packages with pacman -Qkk $(pacman -Qq)

There's no need for the subshell command -- since this is a query, if you don't specify the package(s) you want to check, pacman checks all installed packages.

       -Q, --query
           Query the package database. This operation allows you to view installed packages and
           their files, as well as meta-information about individual packages (dependencies,
           conflicts, install date, build date, size). This can be run against the local package
           database or can be used on individual package files. In the first case, if no package
           names are provided in the command line, all installed packages will be queried.
           Additionally, various filters can be applied on the package list. See Query Options
           below.

Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2016-01-11 13:50:10

2kanaa
Member
Registered: 2016-01-11
Posts: 2

Re: Any way to recover after running false chown script?

Ok, thanks for your quick replies! I will proceed with the reinstallation option here.

Offline

Board footer

Powered by FluxBB