LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   directory permissions incorrectly set (https://www.linuxquestions.org/questions/linux-security-4/directory-permissions-incorrectly-set-131112/)

DutchBoy 01-03-2004 07:11 AM

directory permissions incorrectly set
 
My linux knowledge will be apparent from this post. I ran a chmod incorrectly on the / and /etc directories. I ran the follwing

chmod 700 /
chmod 700 /etc

of course the result of these actions were severe. I rebooted into text mode and ran

chmod 777 /
chmod 777 /etc

so that I could start X and get things working. Now I would like to know which directories I need to have 777 access to and which need lower level access for users other than root.

Thanks for any help.:Pengy:

unSpawn 01-03-2004 10:18 AM

Code:

#!/bin/bash
# Purpose: Restore filesystem permissions from RPM database
#            distro's that don't do package management suck major.
#            *Make sure yer RPM database is sane...
# Args: none or package name
# Deps: Bash, GNU utils, rpm
# Run from: manual, emergency only

case "$#" in
0) rpmopt="a"; unset pkg;;
*) unset rpmopt; pkg="$1";;
esac

rpm -q${rpmopt} --dump ${pkg}|while read t; do
        t=( ${t} ); for i in 3 4; do
        case "${#t[$i]}" in
        7) echo "${t[$i]:3:4} ${t[0]}";;
        esac; done
done

Save this as "/tmp/rpm-perms" and make executable.
Running it as "/tmp/rpm-perms > /tmp/rpm-perms.log" should give you the log. Check the contents for errors, then running it as "/tmp/rpm-perms|while read perm file; do chmod ${perm} ${file}; done" should restore all permissions.


If you want to test it, you can also supply a packagename: "/tmp/rpm-perms adore" for instance would list the files and filepermissions of the Adore package.

DutchBoy 01-05-2004 04:10 AM

bad interpreter
 
I apologize for the questions but I am new to Linux. I made the script in the /tmp folder and made it executable. Then user ./rpm-perms > rpm-perms.log but I got the error [bad interpreter: No such file or directory]. I checked and I have a /bin/bash file. Might I have the wrong version?

unSpawn 01-05-2004 09:40 AM

I apologize for the questions but I am new to Linux.
No need to apologise. Asking questions isn't stupid. NOT asking is.

[bad interpreter: No such file or directory]
- You can only use "./" syntax when you're in the same dir as the script: cd to /tmp first, else use the full path.


All times are GMT -5. The time now is 05:00 PM.