Re: chmod 666 ///

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>  I had to deal with a similar scenario where ownership was changed with
>  -R.  Fortunately I used an identical system (benefits of a classroom
>  environment) to create a baseline file containing the list of files on
>  the system and their ownersand groups.  Pumped that through a simple
>  script and restored ownership on all the files.  You could do
>  something similar with permissions if you had a baseline system.
>
>  But Andrew's suggestion sounds easier if that will work.
>
>  Jacques B.
>

A quick test and I have the following suggestion if you can't find any
other suitable one.  Run the following find command (as root)on your
system folders (i.e. /etc, /boot, /bin, /var).

find /etc -printf "%h/%f*%m\n" >/path-to-removable-drive/etc_files.txt
2>/dev/null

Note the asterisk (*) after the %f.  This is used by the awk command
as a field delimiter later on in the script.  I used * because it
could not be part of a file name so perfect for this scenario.

Repeat the above for other folders (changing the /etc to the
appropriate path, and the file name etc_files.txt to appropriate
name).

Take that thumb drive over to your messed up system and run the
following script from the thumb drive where the text files are located
(makes it easier).  Save the script as changeperms.sh.  Run it as:
./changeperms.sh etc_files.txt
Repeat for each of the files you created.

#!/bin/bash
for i in $(cat %1)
do
   tpermissions=`echo $i | awk -F* '{print $2}'`
   tfile=`echo $i | awk -F* '{print $1}'`
   echo "Changing file permissions on $tfile to $tpermissions"
   chmod $tpermissions $tfile && echo "changed..." || echo "did not change!!!"
   echo "-----------------------------------------------------------------------------------------"
done


Jacques B.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux