HPE 9000 and HPE e3000 Servers
1843979 Members
1880 Online
110226 Solutions
New Discussion

Re: Pls help me with a scripting question

 
Jigar lakhani
Advisor

Pls help me with a scripting question

I am working on cleaning up permissions on Oracle mountpoints and datafiles in unix. I am looking for a script or a scripting idea to 1st.

1. grep for owner oracle
2. ensure its a directory owned for oracle
3. chmod 750 on the oracle owned directory.
4. grep for oracle files, etc datfiles in that subdirectory and change permission to 640 on all datafiles.

thanks alot
Jigar
4 REPLIES 4
harry d brown jr
Honored Contributor

Re: Pls help me with a scripting question

Jigar,

1. grep for owner oracle

use "find", a man on find will reveal how to search by "owner"

find / -user oracle

2. ensure its a directory owned for oracle

This is subjective, and not something a script should or could do.

3. chmod 750 on the oracle owned directory.

using the "find" command you can do such, but I would caution against setting the directory to 750, as non owners might have issues. Check with a DBA first:

find / -user oracle -exec chmod 750 {} \;

4. grep for oracle files, etc datfiles in that subdirectory and change permission to 640 on all datafiles.

find / -type f -name "*.dat" -user oracle -exec chmod 640 {} \;


live free or die
harry
Live Free or Die
OneNeck UNIXSA
Frequent Advisor

Re: Pls help me with a scripting question

find / -user oracle -exec chmod 750 {} \;

I would rather use:
find / -user oracle -type d -exec chmod 750 {} \; as it will get the directory only.

Bill Hassell
Honored Contributor

Re: Pls help me with a scripting question

Just a note about permissions...there may be hundreds of other directories and files that need to be changed because umask is set to 00, a very bad situtation. Use find to locate bad permissions as in:


# find /etc /usr /opt /dev /sbin /stand -perm -002

This will show both directories as well as files that are world-writable and therefore unsecure.


Bill Hassell, sysadmin
Sukant Naik
Trusted Contributor

Re: Pls help me with a scripting question

Hi Jigar,

Just a precautionary note.

There are some execuatable files like "oracle" in the bin directory which you mustn't touch. I have had problems of Oracle instance not coming up after doing such wholesale file permission changes. Please check with your DBA again.

I would rather suggest you to use commands like

chmod +640 for your datafiles.

Regards,

Sukant
Who dares he wins