- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- is there a way to reset default file/directory per...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2007 07:13 AM
04-27-2007 07:13 AM
Is there any tool we can use to go through a system and reset directories/files back to their standard (default) permissions?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2007 07:26 AM
04-27-2007 07:26 AM
Re: is there a way to reset default file/directory permissions?
If you have a second system with the same configuration, you can clone permissions from it.
System 2
============
find /filesystem -print | xargs ll -d | awk '{print $9,$3,$4}' > /tmp/perm.out
System 1
============
# cat fixperm.sh
#!/usr/bin/sh
while :
do
read f u g
echo ${u}:${g} ${f}
chown ${u}:${g} ${f}
done < perm.out
exit 0
If you have a backup of the affected filesystem, you could use a similar method.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2007 07:34 AM
04-27-2007 07:34 AM
Re: is there a way to reset default file/directory permissions?
# swverify -F \*
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2007 07:37 AM
04-27-2007 07:37 AM
SolutionLet's try this again...
System 2
============
find /filesystem -print | xargs perl -e 'printf("%04o %s\n",(stat($ARGV[0]))[2]&07777,$ARGV[0]);' > /tmp/perm.out
System 1
============
# cat fixperm.sh
#!/usr/bin/sh
while :
do
read p f
echo "Attempting: chmod ${p} ${f}"
chmod ${p} ${f}
done < perm.out
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2007 07:46 AM
04-27-2007 07:46 AM
Re: is there a way to reset default file/directory permissions?
swverify -F \*
although that will not work for anything (e.g. oracle) that was not installed via the standard HP-UX installation tools.
There is no assurance that another "good" machine is either "good" or compatible/applicable to your target machine.
What you should have done before the dreaded 777 disease struck was done something like a find exec'ing ls -l to produce a list of file modes, owner, and groups before you starting "fixing" the system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2007 07:57 AM
04-27-2007 07:57 AM
Re: is there a way to reset default file/directory permissions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2007 02:12 AM
04-30-2007 02:12 AM
Re: is there a way to reset default file/directory permissions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2007 02:27 AM
04-30-2007 02:27 AM
Re: is there a way to reset default file/directory permissions?
You really need a backup image to compare against. Depending upon the types of backup you do, it is probably easy to get a listing showing file ownerships, groups, and modes without actually doing a restore. You then can scan the list and compare those values
to those as they now exist on your system and make any changes. This sounds a whole lot like a script is needed. Perl? Awk?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2007 03:00 AM
04-30-2007 03:00 AM
Re: is there a way to reset default file/directory permissions?
The /var filesystem is for variable content, logs and such and can be changed by a script.
There is no automatic, magic wand to solve this problem.
A number of commands were used to create it and a number of poor systems administrations practices led to it.
Suggestion:
1) Make umask consistent for all users including root.
2) Go through the /var filesystem manually and set rational permissions.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2007 03:57 AM
04-30-2007 03:57 AM
Re: is there a way to reset default file/directory permissions?
1) getting the permissions from our Ignite backup (gunzip/tar commands) (we make Ignite backups a lot so we know we have a good restore path)
2) wrote a script to run through this list and look for the same file in /var and update the permissions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2007 12:16 AM
05-01-2007 12:16 AM
Re: is there a way to reset default file/directory permissions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2007 12:20 AM
05-01-2007 12:20 AM
Re: is there a way to reset default file/directory permissions?
In the future, please be more specific as to what directories and/or files you have butchered. Asking "Is there a way to reset default file/directory permissions" infers that you mean standard HP-UX ones convered by the Software Distributer (SD) tools. Hence our offering of 'swverify -F'. Had you not had a similar server to compare to, you might have found that useful knowledge.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2007 12:21 AM
05-01-2007 12:21 AM
Re: is there a way to reset default file/directory permissions?
>needed. Perl? Awk?
Schedule the following script to run nightly:
# cat rebuild_locate_db.sh
#!/usr/bin/sh
LOCDB=/var/opt/locate/loc.db
find / -local -exec ls -ld {} \; 1> ${LOCDB} 2> /dev/null
exit 0
And then to search for a file:
# locate '\/ls$'
-r-xr-xr-x 7 bin bin 28672 May 5 2003 /usr/bin/ls
# alias locate
locate='cat /var/opt/locate/loc.db | grep'
'loc.db' should also be integrated into your backup routine, as it can be used to recover file attributes.
PCS